Mercurial > sdl-ios-xcode
comparison test/nds-test-progs/general/source/main.c @ 2696:0b395a60deff gsoc2008_nds
Timers work now.
author | Darren Alton <dalton@stevens.edu> |
---|---|
date | Mon, 18 Aug 2008 07:29:52 +0000 |
parents | c1c7cb1b5a47 |
children | e1da92da346c |
comparison
equal
deleted
inserted
replaced
2695:c04a266c277a | 2696:0b395a60deff |
---|---|
30 | 30 |
31 int main(void) { | 31 int main(void) { |
32 SDL_Surface *screen; | 32 SDL_Surface *screen; |
33 SDL_Joystick *stick; | 33 SDL_Joystick *stick; |
34 SDL_Event event; | 34 SDL_Event event; |
35 SDL_Rect rect = {8,8,240,176}; | 35 SDL_Rect rect = {0,0,256,192}; |
36 int i; | 36 int i; |
37 | 37 |
38 consoleDemoInit(); puts("Hello world! Initializing FAT..."); | 38 consoleDemoInit(); puts("Hello world! Initializing FAT..."); |
39 fatInitDefault(); | 39 fatInitDefault(); |
40 if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) { | 40 if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) { |
66 | 66 |
67 while(1) | 67 while(1) |
68 while(SDL_PollEvent(&event)) | 68 while(SDL_PollEvent(&event)) |
69 switch(event.type) { | 69 switch(event.type) { |
70 case SDL_JOYBUTTONDOWN: | 70 case SDL_JOYBUTTONDOWN: |
71 switch(event.jbutton.which) { | 71 SDL_FillRect(screen, &rect, (u16)rand()|0x8000); |
72 case 0: | 72 SDL_Flip(screen); |
73 SDL_FillRect(screen, &rect, RGB15(31,0,0)|0x8000); | 73 if(rect.w > 8) { |
74 break; | 74 rect.x += 4; rect.y += 3; |
75 case 1: | 75 rect.w -= 8; rect.h -= 6; |
76 SDL_FillRect(screen, &rect, RGB15(0,31,0)|0x8000); | 76 } |
77 break; | 77 printf("button %d pressed at %d ticks\n", |
78 case 2: | 78 event.jbutton.which, SDL_GetTicks()); |
79 SDL_FillRect(screen, &rect, RGB15(0,0,31)|0x8000); | |
80 break; | |
81 case 3: | |
82 SDL_FillRect(screen, &rect, RGB15(0,0,0)|0x8000); | |
83 break; | |
84 default: break; | |
85 } | |
86 printf("joy_%d, at %d\n", event.jbutton.which, SDL_GetTicks()); | |
87 SDL_Flip(screen); | |
88 break; | 79 break; |
89 case SDL_QUIT: SDL_Quit(); return 0; | 80 case SDL_QUIT: SDL_Quit(); return 0; |
90 default: break; | 81 default: break; |
91 } | 82 } |
92 | 83 |