Kern Fowler / Mbed 2 deprecated Donkey_Kong_Game

Dependencies:   mbed

lib/Donkey/Donkey.cpp

Committer:
Kern_EL17KJTF
Date:
2019-05-08
Revision:
15:9e8d1b6fe81e
Parent:
12:50a7abf21f18
Child:
20:c4e6941c98e2

File content as of revision 15:9e8d1b6fe81e:

/*
ELEC2645 Project
Donkey.cpp
Class file for Donkey Kong in Donkey Kong game.
*/
#include "Donkey.h"



Donkey::Donkey()
{

}
Donkey::~Donkey()
{

}

    int donkeykong_x = 0;
    int donkeykong_y = 34;
    int donkey_kong_speed = 10;
    int donkey_direction;


void Donkey::donkeykong_movement(Gamepad &pad, N5110 &lcd) {
int game_dk_walking_right_1[14][16] = {
    {0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,},
    {0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,},
    {0,0,0,0,0,0,0,0,1,1,0,1,1,0,1,0,},
    {0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,},
    {0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,1,},
    {0,0,0,0,1,1,0,0,0,1,0,0,1,0,1,0,},
    {0,0,1,1,1,0,0,0,0,0,1,1,1,1,0,0,},
    {0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,},
    {0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,},
    {1,0,0,0,1,1,1,0,0,1,1,1,0,0,0,1,},
    {1,0,0,1,0,0,0,1,1,1,0,0,1,0,0,1,},
    {1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1,},
    {1,0,0,1,1,1,0,0,0,0,0,0,0,1,1,1,},
    {1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,},
};

int game_dk_walking_left_1[14][16] = {
    {0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,},
    {0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,},
    {0,1,0,1,1,0,1,1,0,0,0,0,0,0,0,0,},
    {1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,},
    {1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,},
    {0,1,0,1,0,0,1,0,0,0,1,1,0,0,0,0,},
    {0,0,1,1,1,1,0,0,0,0,0,1,1,1,0,0,},
    {0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,},
    {0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,},
    {1,0,0,0,1,1,1,0,0,1,1,1,0,0,0,1,},
    {1,0,0,1,0,0,1,1,1,0,0,0,1,0,0,1,},
    {1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,},
    {1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,1,},
    {1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,},
};

int game_dk_stationary[14][16] = {
    {0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,},
    {0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,},
    {0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,},
    {0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,0,},
    {0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,0,},
    {0,0,1,1,0,1,1,0,1,1,0,0,1,0,0,0,},
    {0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,},
    {0,0,1,0,1,0,0,0,0,0,1,0,0,1,0,0,},
    {0,1,0,0,0,1,1,1,1,1,0,0,0,0,1,0,},
    {0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,},
    {1,0,0,1,0,1,0,0,0,0,1,0,1,0,0,1,},
    {1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,},
    {1,0,1,0,1,0,0,1,1,0,0,1,0,1,0,1,},
    {0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,},
};
    donkey_direction = pad.get_direction();
        if (donkey_direction == NE || donkey_direction == E || donkey_direction == SE) {
            donkeykong_x = donkeykong_x + 3;
            lcd.drawSprite(donkeykong_x,donkeykong_y,14,16,(int *)game_dk_walking_right_1);
        } 
        else if (donkey_direction == NW || donkey_direction == W || donkey_direction == SW) {
            donkeykong_x = donkeykong_x - 3;
            lcd.drawSprite(donkeykong_x,donkeykong_y,14,16,(int *)game_dk_walking_left_1);
        } 
        else {
            lcd.drawSprite(donkeykong_x,donkeykong_y,14,16,(int *)game_dk_stationary);
        }
        lcd.refresh();
        if (donkeykong_x > 68) {
            donkeykong_x = 68;
        }
        if (donkeykong_x < 0) {
            donkeykong_x = 0;
        }
}