void keyPressed(unsigned char key, int x, int y) { switch(key) { case 'd': move_camera(cam, RIGHT); break; case 'a': move_camera(cam, LEFT); break; case 'w': move_camera(cam, FORWARD); break; case 's': move_camera(cam, BACKWARD); break; case 'f': turn_camera(cam, LEFT); break; case 'h': turn_camera(cam, RIGHT); break; case 't': turn_camera(cam, UP); break; case 'g': turn_camera(cam, DOWN); break; } glutPostRedisplay(); }
void perspective_strafe(int direction) { turn_camera(phi, theta + M_PI_2); x += direction * lx * 2.5; z += direction * lz * 2.5; turn_camera(phi, theta); position_camera(); }
void move(t_env *env) { if (env->key.go) go_camera(env); if (env->key.back) back_camera(env); if (env->key.turn) turn_camera(env); if (env->key.left) { if (env->map.map[(int)(env->vec.pos_x - env->vec.plane_x *\ env->key.walk_speed)][(int)(env->vec.pos_y)] == '0') env->vec.pos_x -= env->vec.plane_x * env->key.walk_speed; if (env->map.map[(int)(env->vec.pos_x)][(int)(env->vec.pos_y -\ env->vec.plane_y * env->key.walk_speed)] == '0') env->vec.pos_y -= env->vec.plane_y * env->key.walk_speed; } if (env->key.right) { if (env->map.map[(int)(env->vec.pos_x + env->vec.plane_x *\ env->key.walk_speed)][(int)(env->vec.pos_y)] == '0') env->vec.pos_x += env->vec.plane_x * env->key.walk_speed; if (env->map.map[(int)(env->vec.pos_x)][(int)(env->vec.pos_y +\ env->vec.plane_y * env->key.walk_speed)] == '0') env->vec.pos_y += env->vec.plane_y * env->key.walk_speed; } }
void perspective_turn(float p, float t) { turn_camera(p, t); position_camera(); }
void perspective_load() { turn_camera(phi, theta); position_camera(); }