Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cab202_graphics.h"
- void running_zombie( void);
- int main( void ) {
- setup_screen( );
- running_zombie( );
- cleanup_screen( );
- return 0;
- }
- void running_zombie( void ) {
- // declare variables
- int width = screen_width( );
- int height = screen_height( );
- int count = 0;
- //int score = 0;
- int y = .4 * height;
- int x = .8 * width;
- draw_char( x, y, 'Z' );
- 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." );
- draw_string(30,0, "Score: ");
- draw_int(37, 0, count/8);
- show_screen( );
- int key = wait_char( );
- while ( key != 'q' && key >= 0 ) {
- if ( key == '4' ) { // west
- x = x - 1;
- }
- else if ( key == '1' ) { // south west
- x = x - 1;
- y = y + 1;
- }
- else if ( key == '3' ) { // south east
- x = x + 1;
- y = y + 1;
- }
- else if ( key == '7' ) { // north west
- x = x - 1;
- y = y - 1;
- }
- else if ( key == '9' ) { // north east
- x = x + 1;
- y = y - 1;
- }
- else if ( key == '8' ) { // north
- y = y - 1;
- }
- else if ( key == '2' ) { // south
- y = y + 1;
- }
- else if ( key == '6' ) { // east
- x = x + 1;
- }
- count++;
- clear_screen();
- draw_char( x, y, 'Z' );
- draw_string(30,0, "Score: ");
- draw_int(37, 0, count/8);
- 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." );
- show_screen();
- key = wait_char();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement