added forward/backward movement to player
authorslack <slack@codemaniacs.com>
Fri, 24 Jul 2009 21:38:28 +0000 (23:38 +0200)
committerslack <slack@codemaniacs.com>
Fri, 24 Jul 2009 21:38:28 +0000 (23:38 +0200)
lolailo.c

index 69570417ee690fb16de36c324dc3d74c4f27be6a..9c21641b704b0d78116d692d555dff11e6e39996 100644 (file)
--- 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;