Advertisement
Ch4osCosmo

I GOT IT

Aug 6th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include "cab202_graphics.h"
  2.  
  3. void running_zombie( void);
  4.  
  5. int main( void ) {
  6. setup_screen( );
  7. running_zombie( );
  8. cleanup_screen( );
  9. return 0;
  10. }
  11.  
  12. void running_zombie( void ) {
  13. // declare variables
  14. int width = screen_width( );
  15. int height = screen_height( );
  16.  
  17. int count = 0;
  18. //int score = 0;
  19.  
  20. int y = .4 * height;
  21. int x = .8 * width;
  22.  
  23. draw_char( x, y, 'Z' );
  24. draw_string( 0, screen_height( ) - 1, "Menu: 8 = N; 2 = S; 6 = E; 4 = W; 9 = NE; 3 = SE; 7 = NW; 1 = SW; q = Quit." );
  25.  
  26. draw_string(30,0, "Score: ");
  27. draw_int(37, 0, count/8);
  28.  
  29. show_screen( );
  30. int key = wait_char( );
  31.  
  32. while ( key != 'q' && key >= 0 ) {
  33. if ( key == '4' ) { // west
  34. x = x - 1;
  35. }
  36. else if ( key == '1' ) { // south west
  37. x = x - 1;
  38. y = y + 1;
  39. }
  40. else if ( key == '3' ) { // south east
  41. x = x + 1;
  42. y = y + 1;
  43. }
  44. else if ( key == '7' ) { // north west
  45. x = x - 1;
  46. y = y - 1;
  47. }
  48. else if ( key == '9' ) { // north east
  49. x = x + 1;
  50. y = y - 1;
  51. }
  52. else if ( key == '8' ) { // north
  53. y = y - 1;
  54. }
  55. else if ( key == '2' ) { // south
  56. y = y + 1;
  57. }
  58. else if ( key == '6' ) { // east
  59. x = x + 1;
  60. }
  61. count++;
  62.  
  63. clear_screen();
  64. draw_char( x, y, 'Z' );
  65. draw_string(30,0, "Score: ");
  66. draw_int(37, 0, count/8);
  67. draw_string( 0, screen_height( ) - 1, "Menu: 8 = N; 2 = S; 6 = E; 4 = W; 9 = NE; 3 = SE; 7 = NW; 1 = SW; q = Quit." );
  68.  
  69. show_screen();
  70. key = wait_char();
  71.  
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement