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: lib/Donkey/Donkey.cpp
- Revision:
- 10:28575a6eaa13
- Child:
- 11:b288d01533cc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/Donkey/Donkey.cpp Tue May 07 22:49:13 2019 +0000
@@ -0,0 +1,104 @@
+/*
+ELEC2645 Project
+Donkey.cpp
+Class file for Donkey Kong in Donkey Kong game.
+*/
+#include "Donkey.h"
+
+
+
+Donkey::Donkey()
+{
+
+}
+Donkey::~Donkey()
+{
+
+}
+
+void Donkey::donkey_init() {
+ int donkeykong_x = 0;
+ int donkeykong_y = 32;
+ int donkey_kong_speed = 10;
+ int donkey_direction;
+
+}
+
+void Donkey::donkeykong_movement(Gamepad &pad, N5110 &lcd) {
+int game_dk_walking_right_1[16][16] = {
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,},
+ {1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,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,0,0,0,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},
+};
+ donkey_direction = pad.get_direction();
+ if (donkey_direction == NE || donkey_direction == E || donkey_direction == SE) {
+ donkeykong_x = donkeykong_x + 1;
+ lcd.drawSprite(donkeykong_x,donkeykong_y,16,16,(int *)game_dk_walking_right_1);
+ }
+ else if (donkey_direction == NW || donkey_direction == W || donkey_direction == SW) {
+ donkeykong_x = donkeykong_x - 1;
+ lcd.drawSprite(donkeykong_x,donkeykong_y,16,16,(int *)game_dk_walking_left_1);
+ }
+ else {
+ lcd.drawSprite(donkeykong_x,donkeykong_y,16,16,(int *)game_dk_stationary);
+ }
+ wait_ms(donkey_kong_speed);
+ lcd.refresh();
+ if (donkeykong_x > 68) {
+ donkeykong_x = 68;
+ }
+ if (donkeykong_x < 0) {
+ donkeykong_x = 0;
+ }
+}