From ed29e6ef5b41f02fa5583db1ab86e4528acee0f3 Mon Sep 17 00:00:00 2001 From: slack Date: Fri, 24 Jul 2009 23:38:28 +0200 Subject: [PATCH] added forward/backward movement to player --- lolailo.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/lolailo.c b/lolailo.c index 6957041..9c21641 100644 --- a/lolailo.c +++ b/lolailo.c @@ -24,6 +24,11 @@ float drawbuf[BUFFER_SIZE]; FILE *fout; #endif +extern uint8 cur_pos; +extern uint8 cur_row; +extern uint32 rows_played; +extern float current_time; +extern float row_duration; #ifdef DEBUG int main(int argc, char *argv[]) @@ -64,12 +69,31 @@ void _start() { if (ev.type == SDL_KEYDOWN) { - if (ev.key.keysym.sym == SDLK_SPACE) { + switch (ev.key.keysym.sym) { + case SDLK_SPACE: paused = !paused; SDL_PauseAudio(paused); + break; + + case SDLK_LEFT: + cur_pos-=2; + cur_row=TRACK_LENGTH-1; + rows_played = cur_pos*TRACK_LENGTH; + current_time = rows_played*row_duration; + printf("cur_pos = %d\n", cur_pos+1); + break; + + case SDLK_RIGHT: + if (cur_row == TRACK_LENGTH-1) cur_pos++; + cur_row=TRACK_LENGTH-1; + rows_played = cur_pos*TRACK_LENGTH; + current_time = rows_played*row_duration; + printf("cur_pos = %d\n", cur_pos+1); + break; + + default: + goto end; } - else - goto end; } if (ev.type == SDL_QUIT) goto end; -- 2.34.1