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.
Donkey.h
00001 #ifndef DONKEY_H 00002 #define DONKEY_H 00003 00004 #include "mbed.h" 00005 #include "N5110.h" 00006 #include "Gamepad.h" 00007 00008 /** External variables used inside and out of the class. */ 00009 extern int donkeykong_x; 00010 extern int donkeykong_y; 00011 extern int donkey_kong_speed; 00012 extern int donkey_direction; 00013 00014 /** Donkey Class 00015 *@brief This class is for spawning the player controlled model Donkey Kong. 00016 *@author Kern Fowler 00017 *@version 1.0 00018 *@date May 2019 00019 */ 00020 00021 class Donkey { 00022 00023 public: 00024 /** Donkey Constructor 00025 @brief Builds my default Donkey Kong constructor. 00026 @details This does not have any setup. 00027 */ 00028 Donkey(); 00029 /** Donkey Destructor 00030 @brief Builds my default Donkey Kong destructor. 00031 @details This does not have any setup. 00032 */ 00033 ~Donkey(); 00034 // Mutators 00035 00036 /** 00037 *@brief Spawns Donkey Kong model. 00038 *@param pad The Gamepad class is used. 00039 *@param lcd The N5110 class is used. 00040 *@return None. 00041 *@details Creates the player controlled unit Donkey Kong, then moves it left or right based on joystick input. Points on collision with bananas. Gameover on collision with barrels. 00042 *@code 00043 void Donkey::donkeykong_movement(Gamepad &pad, N5110 &lcd) { 00044 donkey_direction = pad.get_direction(); 00045 if (donkey_direction == NE || donkey_direction == E || donkey_direction == SE) { // If joystick moved right, the right position sprite will be loaded and donkey kong will move right. 00046 donkeykong_x = donkeykong_x + 3; 00047 lcd.drawSprite(donkeykong_x,donkeykong_y,14,16,(int *)game_dk_walking_right_1); 00048 } 00049 else if (donkey_direction == NW || donkey_direction == W || donkey_direction == SW) { // If joystick moved left, the left position sprite will be loaded and donkey kong will move left. 00050 donkeykong_x = donkeykong_x - 3; 00051 lcd.drawSprite(donkeykong_x,donkeykong_y,14,16,(int *)game_dk_walking_left_1); 00052 } 00053 else { // If joystick not moved, then stationary sprite will be loaded and no movement occurs. 00054 lcd.drawSprite(donkeykong_x,donkeykong_y,14,16,(int *)game_dk_stationary); 00055 } 00056 lcd.refresh(); 00057 if (donkeykong_x > 68) { // Stops donkey kong model going off screen. 00058 donkeykong_x = 68; 00059 } 00060 if (donkeykong_x < 0) { 00061 donkeykong_x = 0; 00062 } 00063 } 00064 @endocde 00065 */ 00066 void donkeykong_movement(Gamepad &pad, N5110 &lcd); 00067 }; 00068 00069 #endif
Generated on Tue Jul 12 2022 18:21:51 by
1.7.2