0xLeon

ZDK Space Key Press Example

Aug 30th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdbool.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <math.h>
  6. #include <time.h>
  7. #include "cab202_graphics.h"
  8. #include "cab202_sprites.h"
  9. #include "cab202_timers.h"
  10.  
  11. int main(int argc, char* argv[]) {
  12.     setup_screen();
  13.     clear_screen();
  14.    
  15.     char key;
  16.    
  17.     while (true) {
  18.         key = get_char();
  19.        
  20.         if (' ' == key) {
  21.             clear_screen();
  22.             draw_formatted(0, 0, "%s", "Space pressed");
  23.             show_screen();
  24.         }
  25.         else if ('q' == key) {
  26.             break;
  27.         }
  28.        
  29.         timer_pause(1L);
  30.     }
  31.    
  32.     cleanup_screen();
  33.    
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment