Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 7:ffbc921c20f7
- Parent:
- 6:478f81e79d9b
- Child:
- 8:421f94b816c4
--- a/main.cpp Tue May 07 15:19:56 2019 +0000 +++ b/main.cpp Tue May 07 15:33:17 2019 +0000 @@ -16,6 +16,8 @@ N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad pad; Options opt; +Donkey dky; +GameEngine eng; int fps = 24; int direction; @@ -24,14 +26,24 @@ // Game State-------------------------------------------------------------- -void game_engine_run() { +GameEngine::GameEngine() +{ + +} + +GameEngine::~GameEngine() +{ + +} + +void GameEngine::gameengine_run(Gamepad &pad, N5110 &lcd) { wait_ms(250); while (pad.check_event(Gamepad::BACK_PRESSED) == false) { //printf("Game State"); lcd.clear(); lcd.printString("Game",0,0); - donkeykong_x_movement(); + dky.donkeykong_movement(pad, lcd); wait_ms(1.0f/fps); } } @@ -41,24 +53,32 @@ int donkeykong_x = 0; int donkeykong_y = 32; int donkey_kong_speed = 25; -void donkeykong_x_movement() { + +Donkey::Donkey() +{ + +} +Donkey::~Donkey() +{ + +} + +void Donkey::donkeykong_movement(Gamepad &pad, N5110 &lcd) { direction = pad.get_direction(); if (direction == NE || direction == E || direction == SE) { donkeykong_x = donkeykong_x + 1; lcd.drawSprite(donkeykong_x,donkeykong_y,16,16,(int *)game_dk_walking_right_1); wait_ms(donkey_kong_speed); - lcd.refresh(); } else if (direction == NW || direction == W || direction == SW) { donkeykong_x = donkeykong_x - 1; lcd.drawSprite(donkeykong_x,donkeykong_y,16,16,(int *)game_dk_walking_left_1); wait_ms(donkey_kong_speed); - lcd.refresh(); } else { lcd.drawSprite(donkeykong_x,donkeykong_y,16,16,(int *)game_dk_stationary); - lcd.refresh(); } + lcd.refresh(); if (donkeykong_x > 68) { donkeykong_x = 68; } @@ -222,7 +242,7 @@ if (pad.check_event(Gamepad::A_PRESSED) == true) { if (menu_option_pos == 0) { // printf("GameEngine"); - game_engine_run(); + eng.gameengine_run(pad, lcd); } if (menu_option_pos == 1) { // printf("Controls");