void do_move() { if(keyboard_is_down(SDLK_UP)) camera_move_along_view(camfps, camvel*speed_factor); else if(keyboard_is_down(SDLK_DOWN)) camera_move_along_view(camfps, -camvel*speed_factor); if(keyboard_is_down(SDLK_LEFT)) camera_side_move(camfps, -camvel*speed_factor); else if(keyboard_is_down(SDLK_RIGHT)) camera_side_move(camfps, camvel*speed_factor); if(mouse_button_is_down(1)) printf("Button 1\n"); }
void process_input(void) { thing_t *dt = &game.things[game.dude_id]; if (game.input_timeout) { --game.input_timeout; return; } if (dt->type > dude_fall) return; if (keyboard_is_down(SDLK_LEFT)) handle_dude_left(dt); if (keyboard_is_down(SDLK_RIGHT)) handle_dude_right(dt); if (dt->type == dude_walk && ! game.input_timeout) { // no keys down and dude_walk becomes dude. dt->type = dude_stand; dt->current_frame = 0; } }
static void update(void) { brightness = 1.f - fabsf((float)rotate_timeout - (ROTATE_INTERVAL / 2)) / ((float)ROTATE_INTERVAL / 2); rotate_timeout -= 1; if (rotate_timeout == 0) { rotate_index = (rotate_index + 1) % 2; rotate_timeout = ROTATE_INTERVAL; } if (ticks_countup < game.ended_at_ticks) ticks_countup += 10; if (ticks_countup > game.ended_at_ticks) ticks_countup = game.ended_at_ticks; if (input_timeout == 0) { if (keyboard_is_down(SDLK_LEFT) && achievement_count > 0) { if (achievement_index == ach_no_left_arrow) { deactivate(); game.score.bprops[ach_no_no_left_arrow] = true; activate(); ticks_countup = game.ended_at_ticks; achievement_index = ach_no_no_left_arrow; audio_play("sfx/ach.wav"); } else { do { achievement_index = achievement_index - 1; if (achievement_index < 0) achievement_index = bp__last - 1; } while (! achieved_now[achievement_index]); } input_timeout = INPUT_INTERVAL; } if (keyboard_is_down(SDLK_RIGHT) && achievement_count > 0) { do { achievement_index = (achievement_index + 1) % bp__last; } while (! achieved_now[achievement_index]); input_timeout = INPUT_INTERVAL; } } else { --input_timeout; } if (keyboard_is_down(SDLK_ESCAPE)) { while (view_pop()) {} game_init(); } }