test: keyboard camera controls
This commit is contained in:
parent
a994e54639
commit
1b0fd6dc04
@ -13,7 +13,8 @@ extern "C" {
|
||||
EXPORT void DECL update_keyboard(int up, int down, int left, int right,
|
||||
int w, int s, int a, int d,
|
||||
int t, int g, int f, int h,
|
||||
int i, int k, int j, int l);
|
||||
int i, int k, int j, int l,
|
||||
int q, int e);
|
||||
EXPORT void DECL update_mouse(int x, int y);
|
||||
EXPORT void DECL update_joystick(int joystick_index,
|
||||
float lx, float ly, float rx, float ry, float tl, float tr,
|
||||
|
||||
8
main.lua
8
main.lua
@ -20,7 +20,8 @@ void draw();
|
||||
void update_keyboard(int up, int down, int left, int right,
|
||||
int w, int s, int a, int d,
|
||||
int t, int g, int f, int h,
|
||||
int i, int k, int j, int l);
|
||||
int i, int k, int j, int l,
|
||||
int q, int e);
|
||||
void update_mouse(int x, int y);
|
||||
void update_joystick(int joystick_index,
|
||||
float lx, float ly, float rx, float ry, float tl, float tr,
|
||||
@ -129,10 +130,13 @@ local update = function(time)
|
||||
local k = love.keyboard.isDown("k")
|
||||
local j = love.keyboard.isDown("j")
|
||||
local l = love.keyboard.isDown("l")
|
||||
local q = love.keyboard.isDown("q")
|
||||
local e = love.keyboard.isDown("e")
|
||||
test.update_keyboard(up, down, left, right,
|
||||
w, s, a, d,
|
||||
t, g, f, h,
|
||||
i, k, j, l);
|
||||
i, k, j, l,
|
||||
q, e)
|
||||
|
||||
test.update(time)
|
||||
end
|
||||
|
||||
57
src/test.cpp
57
src/test.cpp
@ -215,26 +215,6 @@ void load(const char * source_path)
|
||||
flame::load_texture();
|
||||
}
|
||||
|
||||
void update_keyboard(int up, int down, int left, int right,
|
||||
int w, int s, int a, int d,
|
||||
int t, int g, int f, int h,
|
||||
int i, int k, int j, int l)
|
||||
{
|
||||
//float forward = (0.1f * up + -0.1f * down);
|
||||
//float strafe = (-0.1f * left + 0.1f * right);
|
||||
//view::third_person::apply_translation(forward, strafe, 0);
|
||||
/*
|
||||
collision_scene::update(up, down, left, right,
|
||||
w, s, a, d,
|
||||
t, g, f, h,
|
||||
i, k, j, l);
|
||||
*/
|
||||
boids_scene::update(up, down, left, right,
|
||||
w, s, a, d,
|
||||
t, g, f, h,
|
||||
i, k, j, l);
|
||||
}
|
||||
|
||||
void check_collisions(collision::Sphere const & sphere, XMVECTOR const & direction,
|
||||
collision::state & state)
|
||||
{
|
||||
@ -312,6 +292,43 @@ void minecraft_view_update(XMVECTOR direction)
|
||||
view::state.eye = view::state.at - view::state.direction * view::at_distance;
|
||||
}
|
||||
|
||||
void update_keyboard(int up, int down, int left, int right,
|
||||
int w, int s, int a, int d,
|
||||
int t, int g, int f, int h,
|
||||
int i, int k, int j, int l,
|
||||
int q, int e)
|
||||
{
|
||||
//float forward = (0.1f * up + -0.1f * down);
|
||||
//float strafe = (-0.1f * left + 0.1f * right);
|
||||
//view::third_person::apply_translation(forward, strafe, 0);
|
||||
/*
|
||||
collision_scene::update(up, down, left, right,
|
||||
w, s, a, d,
|
||||
t, g, f, h,
|
||||
i, k, j, l);
|
||||
*/
|
||||
/*
|
||||
boids_scene::update(up, down, left, right,
|
||||
w, s, a, d,
|
||||
t, g, f, h,
|
||||
i, k, j, l);
|
||||
*/
|
||||
|
||||
float forward = (w - s) * 0.5;
|
||||
float strafe = (d - a) * 0.5;
|
||||
float elevation = (q - e) * 0.5;
|
||||
float delta_yaw = (left - right) * -0.035;
|
||||
float delta_pitch = (down - up) * -0.035;
|
||||
|
||||
XMVECTOR direction = view::third_person::apply_transform(forward, strafe, elevation,
|
||||
delta_yaw, delta_pitch);
|
||||
view::apply_fov(0.01 * up + -0.01 * down);
|
||||
|
||||
if (true) {
|
||||
minecraft_view_update(direction);
|
||||
}
|
||||
}
|
||||
|
||||
void update_joystick(int joystick_index,
|
||||
float lx, float ly, float rx, float ry, float tl, float tr,
|
||||
int up, int down, int left, int right,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user