My platformer project

Dependencies:   Finalproject N5110 mbed

Fork of 2645_project_final by Levs Dumans

Files at this revision

API Documentation at this revision

Comitter:
lion152
Date:
Fri May 05 15:00:33 2017 +0000
Commit message:
Finished in one go

Changed in this revision

Character/Character.cpp Show annotated file Show diff for this revision Revisions of this file
Character/Character.h Show annotated file Show diff for this revision Revisions of this file
Enemy/Enemy.cpp Show annotated file Show diff for this revision Revisions of this file
Enemy/Enemy.h Show annotated file Show diff for this revision Revisions of this file
Gamepad.lib Show annotated file Show diff for this revision Revisions of this file
Map/Map.cpp Show annotated file Show diff for this revision Revisions of this file
Map/Map.h Show annotated file Show diff for this revision Revisions of this file
N5110.lib Show annotated file Show diff for this revision Revisions of this file
Platform/Platform.cpp Show annotated file Show diff for this revision Revisions of this file
Platform/Platform.h Show annotated file Show diff for this revision Revisions of this file
Rectangle/Rectangle.cpp Show annotated file Show diff for this revision Revisions of this file
Rectangle/Rectangle.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Character/Character.cpp	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,336 @@
+#include "Character.h"
+#include "N5110.h"
+#include "mbed.h"
+#include "Enemy.h"
+//Serial pc(USBTX, USBRX);
+
+//Constructor
+Character::Character(int x, int y)
+{
+    this->x=x;
+    this->y=y;
+    width=8;
+    height=10;
+    force=0.0f;
+    floatY=0.0f;
+}
+
+//Destructor
+Character::~Character()
+{
+    
+}
+
+//////////////DRAW - CHARACTER//////////////////////////////////////////////////
+/**
+@details Handles character drawing on the screen 
+*/
+void Character::draw(N5110 &lcd, int absoluteCoord, bool white )
+{
+    white = !white;
+    //pc.printf("%d\n",x);
+    //pc.printf("%d\n",y);
+    //head
+    lcd.setPixel(x-absoluteCoord,y-9, white);
+    lcd.setPixel(x+1-absoluteCoord,y-9, white);
+    lcd.setPixel(x+2-absoluteCoord,y-9, white);
+    lcd.setPixel(x+3-absoluteCoord,y-9, white);
+    lcd.setPixel(x+4-absoluteCoord,y-9, white);
+    lcd.setPixel(x+1-absoluteCoord,y-8, white);
+    lcd.setPixel(x+2-absoluteCoord,y-8, white);
+    lcd.setPixel(x+4-absoluteCoord,y-8, white);
+    lcd.setPixel(x+2-absoluteCoord,y-7, white);
+    lcd.setPixel(x+3-absoluteCoord,y-7, white);
+    lcd.setPixel(x+4-absoluteCoord,y-7, white);
+       
+    //body
+    lcd.setPixel(x+1-absoluteCoord,y-6, white);
+    lcd.setPixel(x+2-absoluteCoord,y-6, white);
+    lcd.setPixel(x+3-absoluteCoord,y-6, white);
+    lcd.setPixel(x+5-absoluteCoord,y-6, white);
+    lcd.setPixel(x+6-absoluteCoord,y-6, white);
+    lcd.setPixel(x+7-absoluteCoord,y-6, white);
+    lcd.setPixel(x+1-absoluteCoord,y-5, white);
+    lcd.setPixel(x+2-absoluteCoord,y-5, white);
+    lcd.setPixel(x+3-absoluteCoord,y-5, white);
+    lcd.setPixel(x+4-absoluteCoord,y-5, white);
+    lcd.setPixel(x+5-absoluteCoord,y-5, white);
+    lcd.setPixel(x+2-absoluteCoord,y-4, white);
+    lcd.setPixel(x+3-absoluteCoord,y-4, white);
+    lcd.setPixel(x+2-absoluteCoord,y-3, white);
+    lcd.setPixel(x+3-absoluteCoord,y-3, white);
+       
+    //legs
+    lcd.setPixel(x+1-absoluteCoord,y-2, white);
+    lcd.setPixel(x+4-absoluteCoord,y-2, white);
+    lcd.setPixel(x+1-absoluteCoord,y-1, white);
+    lcd.setPixel(x+4-absoluteCoord,y-1, white);
+    lcd.setPixel(x+1-absoluteCoord,y, white);
+    lcd.setPixel(x+2-absoluteCoord,y, white);
+    lcd.setPixel(x+4-absoluteCoord,y, white);
+    lcd.setPixel(x+5-absoluteCoord,y, white);
+}
+//////////////CHARACTERORENEMYDEATH - CHARACTER//////////////////////////////////////////////////
+/**
+@details function that decides does enemy or character dies
+*/
+void Character::characterOrEnemyDeath(deque<Enemy*>* enemyMap)
+{
+    if(force<0)
+    {
+        deque<Enemy*>::iterator it;
+        //enemy death
+        if((it = collisionEnemyS(enemyMap))!= enemyMap->end())
+        {
+            enemyMap->erase(it);
+            force=0.73;
+        }
+    }
+    //character death 
+    if(collisionEnemyW(enemyMap)||collisionEnemyE(enemyMap)||collisionEnemyN(enemyMap))
+    {
+        x=-20;
+        y=48;
+    }
+}
+//////////////RISE - CHARACTER//////////////////////////////////////////////////
+/**
+@details Function that handles character jumping and acceleration during jump 
+*/
+void Character::rise(deque<Platform*>* levelMap)
+{
+    if (collisionPlatformN(levelMap))
+    {
+        //pc.printf("%d",y);
+        force=-0.4f;
+    }
+    if(force>0.0f)
+    {
+        floatY-=force;
+        force-=0.11f;   
+        y=floor(floatY+0.5f);
+    }
+}
+
+//////////////FALL - CHARACTER//////////////////////////////////////////////////
+/**
+@details Function that handles character falling after the jump
+*/
+void Character::fall(deque<Platform*>* levelMap)
+{
+    if (collisionPlatformS(levelMap))
+    {
+        force=0.0f;
+    }
+    if(force<0.0f)
+    {
+        floatY-=force;
+        if(force>-1)
+        {
+            force-=0.11f;
+        }
+        y=floor(floatY+0.5f);    
+    }
+}
+
+//////////////RISE - CHARACTER//////////////////////////////////////////////////
+/**
+@details Function that handles character movement
+*in addition it increases absolute coordinate of the screen
+*/
+void Character::movement(Direction d, int* absoluteCoord, deque<Platform*>* levelMap, deque<Enemy*>* enemyMap)
+{
+    //pc.printf("%d\n",*absoluteCoord);
+    //pc.printf("move right \n");
+    if ((d==E)||(d==NE))
+    {
+        //pc.printf("move right \n");
+        if (!collisionPlatformE(levelMap))
+        {
+            x++;
+            if((x-(*absoluteCoord))>(28-width/2))
+            {
+                (*absoluteCoord)++;
+                //pc.printf("%d\n", (*absoluteCoord));
+            }
+        }
+    }
+    else if (((d==W)||(d==NW))&&((x-*absoluteCoord)>0))
+    {
+        if (!collisionPlatformW(levelMap))
+        {
+            x--;
+        }
+    }
+    if(force==0.0f)
+    {
+        if ((d==NW)||(d==N)||(d==NE))
+        {
+            force=1.5f;
+            floatY=y;
+        }
+    }
+    noPlatformFall(levelMap);
+    rise(levelMap);
+    fall(levelMap);
+    characterOrEnemyDeath(enemyMap);
+}
+
+//////////////NOPLATFORMFALL - CHARACTER//////////////////////////////////////////////////
+/**
+@details implements falling donw when character walks off the platform 
+*/
+void Character::noPlatformFall(deque<Platform*>* levelMap)
+{
+    if((!collisionPlatformS(levelMap)) && (force==0.0f))
+    {
+        force=-0.04f;   
+        floatY=y; 
+    }
+}
+
+//////////////COLLISIONPLATFORME - CHARACTER//////////////////////////////////////////////////
+/**
+@details Function that checks collision to the right of the character with each platform
+*/
+bool Character::collisionPlatformE(deque<Platform*>* levelMap)
+{
+    for(deque<Platform*>::iterator it=levelMap->begin(); it !=levelMap->end();)
+    {
+        Platform* p=*it;
+        if (collisionLeftUpE(*p))
+        {
+            return true;
+        }
+        it++;
+    }
+    return false;
+}
+
+//////////////COLLISIONPLATFORMW - CHARACTER//////////////////////////////////////////////////
+/**
+@details Function that checks collision to the left of the character with each platform
+*/
+bool Character::collisionPlatformW(deque<Platform*>* levelMap)
+{
+    for(deque<Platform*>::iterator it=levelMap->begin(); it !=levelMap->end();)
+    {
+        Platform* p=*it;
+        if (collisionLeftUpW(*p))
+        {
+            return true;
+        }
+        it++;
+    }
+    return false;
+}
+
+//////////////COLLISIONPLATFORMS - CHARACTER//////////////////////////////////////////////////
+/**
+@details Function that checks collision bellow the character with each platform
+*/
+bool Character::collisionPlatformS(deque<Platform*>* levelMap)
+{
+    for(deque<Platform*>::iterator it=levelMap->begin(); it !=levelMap->end();)
+    {
+        Platform* p=*it;
+        if (collisionLeftUpS(*p))
+        {
+            //pc.printf("ychar - %d\n", y);
+            //pc.printf("y-heightplatf - %d", p->getY() - p->getHeight());
+            return true;
+        }
+        it++;
+    }
+    return false;
+}
+
+//////////////COLLISIONPLATFORMN - CHARACTER//////////////////////////////////////////////////
+/**
+@details Function that checks collision above the character with each platform
+*/
+bool Character::collisionPlatformN(deque<Platform*>* levelMap)
+{
+    for(deque<Platform*>::iterator it=levelMap->begin(); it !=levelMap->end();)
+    {
+        Platform* p=*it;
+        if (collisionLeftUpN(*p))
+        {
+            return true;
+        }
+        it++;
+    }
+    return false;
+}
+
+//////////////COLLISIONENEMYE - CHARACTER//////////////////////////////////////////////////
+/**
+@details Function that checks collision to the right of the character with each enemy
+*/
+bool Character::collisionEnemyE(deque<Enemy*>* enemyMap)
+{
+    for(deque<Enemy*>::iterator it=enemyMap->begin(); it !=enemyMap->end();)
+    {
+        Enemy* e=*it;
+        if (touchLeftDownE(*e))
+        {
+            return true;
+        }
+        it++;
+    }
+    return false;
+}
+
+//////////////COLLISIONENEMYW - CHARACTER//////////////////////////////////////////////////
+/**
+@details Function that checks collision to the left of the character with each enemy
+*/
+bool Character::collisionEnemyW(deque<Enemy*>* enemyMap)
+{
+    for(deque<Enemy*>::iterator it=enemyMap->begin(); it !=enemyMap->end();)
+    {
+        Enemy* e=*it;
+        if (touchLeftDownW(*e))
+        {
+            return true;
+        }
+        it++;
+    }
+    return false;
+}
+
+//////////////COLLISIONENEMYS - CHARACTER//////////////////////////////////////////////////
+/**
+@details Function that checks collision bellow the character with each enemy
+*/
+deque<Enemy*>::iterator Character::collisionEnemyS(deque<Enemy*>* enemyMap)
+{
+    for(deque<Enemy*>::iterator it=enemyMap->begin(); it !=enemyMap->end();)
+    {
+        Enemy* e=*it;
+        if (touchLeftDownS(*e))
+        {
+            return it;
+        }
+        it++;
+    }
+    return enemyMap->end();
+}
+
+//////////////COLLISIONENEMYN - CHARACTER//////////////////////////////////////////////////
+/**
+@details Function that checks collision above the character with each enemy
+*/
+bool Character::collisionEnemyN(deque<Enemy*>* enemyMap)
+{
+    for(deque<Enemy*>::iterator it=enemyMap->begin(); it !=enemyMap->end();)
+    {
+        Enemy* e=*it;
+        if (touchLeftDownN(*e))
+        {
+            return true;
+        }
+        it++;
+    }
+    return false;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Character/Character.h	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,60 @@
+#ifndef CHARACTER_H
+#define CHARACTER_H 
+
+#include "mbed.h"
+#include "N5110.h"
+#include "Gamepad.h"
+#include "Rectangle.h"
+#include "Platform.h"
+#include <deque>
+#include "Enemy.h"
+
+/**Character class
+@brief Class that handles character movement and rendering
+@author Lev Duman
+@date May 4 2017
+*/
+
+
+class Character: public Rectangle
+{
+    
+    public:
+        /**Constructor*/
+        Character(int x, int y);
+        /**Destructor*/
+        ~Character();
+        /**Draws character*/
+        void draw(N5110 &lcd,int absoluteCoord, bool white);
+        /**Character movement*/
+        void movement(Direction d, int* absoluteCoord, deque<Platform*>* levelMap, deque<Enemy*>* enemyMap);
+        /**Character jump*/
+        void rise(deque<Platform*>* levelMap);
+        /**Character falling*/
+        void fall(deque<Platform*>* levelMap);
+        /**Character falling without prior jump*/
+        void noPlatformFall(deque<Platform*>* levelMap);
+        /**Collision with platform to the east*/
+        bool collisionPlatformE(deque<Platform*>* levelMap);
+        /**Collision with platform to the west*/
+        bool collisionPlatformW(deque<Platform*>* levelMap);
+        /**Collision with platform to the south*/
+        bool collisionPlatformS(deque<Platform*>* levelMap);
+        /**Collision with platform to the north*/
+        bool collisionPlatformN(deque<Platform*>* levelMap);
+        /**Collision with enemy to the east*/
+        bool collisionEnemyE(deque<Enemy*>* enemyMap);
+        /**Collision with enemy to the west*/
+        bool collisionEnemyW(deque<Enemy*>* enemyMap);
+        /**returns iterator or -1 depending on if enemy is killed*/
+        deque<Enemy*>::iterator collisionEnemyS(deque<Enemy*>* enemyMap);
+        /**Collision with enemy from north*/
+        bool collisionEnemyN(deque<Enemy*>* enemyMap); 
+        /**function that checks for enemy or character death*/
+        void characterOrEnemyDeath(deque<Enemy*>* enemyMap);
+    private:    
+        float force;
+        float floatY;
+        
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Enemy/Enemy.cpp	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,247 @@
+#include "Enemy.h"
+#include "N5110.h"
+#include "mbed.h"
+#include "math.h"
+#include "Platform.h"
+//Serial pc(USBTX, USBRX);
+
+Enemy::Enemy(int x, int y)
+{
+    this->x=x;
+    this->y=y;
+    width=8;
+    height=7;
+    force=0.0f;
+    floatY=0.0f;
+    directionW=true;
+    spawned=false;
+}
+
+Enemy::~Enemy()
+{
+    
+}
+
+//////////////DRAW - ENEMY//////////////////////////////////////////////////
+/**
+@details Handles enemy drawing on the screen 
+*/
+void Enemy::draw(N5110 &lcd, int absoluteCoord, bool white )
+{
+    white = !white;
+    //pc.printf("%d\n",x);
+    //pc.printf("%d\n",y);
+    //1st row
+    lcd.setPixel(x-absoluteCoord+2,y-6, white);
+    lcd.setPixel(x-absoluteCoord+3,y-6, white);
+    lcd.setPixel(x-absoluteCoord+4,y-6, white);
+    lcd.setPixel(x-absoluteCoord+5,y-6, white);
+    //2nd row
+    lcd.setPixel(x-absoluteCoord+1,y-5, white);
+    lcd.setPixel(x-absoluteCoord+2,y-5, white);
+    lcd.setPixel(x-absoluteCoord+3,y-5, white);
+    lcd.setPixel(x-absoluteCoord+4,y-5, white);
+    lcd.setPixel(x-absoluteCoord+5,y-5, white);
+    lcd.setPixel(x-absoluteCoord+6,y-5, white);
+    //3rd row
+    lcd.setPixel(x-absoluteCoord,y-4, white);
+    lcd.setPixel(x-absoluteCoord+1,y-4, white);
+    
+    lcd.setPixel(x-absoluteCoord+3,y-4, white);
+    lcd.setPixel(x-absoluteCoord+4,y-4, white);
+    
+    lcd.setPixel(x-absoluteCoord+6,y-4, white);
+    lcd.setPixel(x-absoluteCoord+7,y-4, white);
+    
+    //4th row
+    lcd.setPixel(x-absoluteCoord,y-3, white);
+    
+    lcd.setPixel(x-absoluteCoord+2,y-3, white);
+    lcd.setPixel(x-absoluteCoord+3,y-3, white);
+    lcd.setPixel(x-absoluteCoord+4,y-3, white);
+    lcd.setPixel(x-absoluteCoord+5,y-3, white);
+    
+    lcd.setPixel(x-absoluteCoord+7,y-3, white);
+    //5th row
+    lcd.setPixel(x-absoluteCoord,y-2, white);
+    lcd.setPixel(x-absoluteCoord+1,y-2, white);
+    lcd.setPixel(x-absoluteCoord+2,y-2, white);
+    lcd.setPixel(x-absoluteCoord+3,y-2, white);
+    lcd.setPixel(x-absoluteCoord+4,y-2, white);
+    lcd.setPixel(x-absoluteCoord+5,y-2, white);
+    lcd.setPixel(x-absoluteCoord+6,y-2, white);
+    lcd.setPixel(x-absoluteCoord+7,y-2, white);
+    //6th row
+    
+    lcd.setPixel(x-absoluteCoord+1,y-1, white);
+    lcd.setPixel(x-absoluteCoord+2,y-1, white);
+    
+    lcd.setPixel(x-absoluteCoord+4,y-1, white);
+    lcd.setPixel(x-absoluteCoord+5,y-1, white);
+    
+    //7th row
+    lcd.setPixel(x-absoluteCoord,y, white);
+    
+    
+    
+    
+    
+    
+    lcd.setPixel(x-absoluteCoord+7,y, white);
+}
+
+//////////////MOVEMENT - ENEMY//////////////////////////////////////////////////
+/**
+@details Handles enemy movement on the screen 
+*/
+bool Enemy::movement(int absoluteCoord, deque<Platform*>* levelMap)
+{
+    if(directionW)
+    {   
+        if(collisionPlatformW(levelMap))
+        {
+            directionW=false;   
+        }
+        else
+        {
+            x--;
+        }
+    }
+    else
+    {
+        if(collisionPlatformE(levelMap))
+        {
+            directionW=true;   
+        }
+        else
+        {
+            x++;
+        }
+    }
+    noPlatformFall(levelMap);
+    fall(levelMap);
+    
+    if(y>(47+height))
+    {
+        return true;
+    }
+    return false;
+}
+
+//////////////NOPLATFORMFALL - ENEMY//////////////////////////////////////////////////
+/**
+@details implements falling donw when enemy walks off the platform 
+*/
+void Enemy::noPlatformFall(deque<Platform*>* levelMap)
+{
+    if((!collisionPlatformS(levelMap)) && (force==0.0f))
+    {
+        force=-0.04f;   
+        floatY=y; 
+    }
+}
+
+//////////////FAll - ENEMY//////////////////////////////////////////////////
+/**
+@details Handles enemy falling gravity aspect
+*/
+void Enemy::fall(deque<Platform*>* levelMap)
+{
+    if (collisionPlatformS(levelMap))
+    {
+        force=0.0f;
+    }
+    if(force<0.0f)
+    {
+        floatY-=force;
+        if(force>-1)
+        {
+            force-=0.11f;
+        }
+        y=floor(floatY+0.5f);    
+    }
+}
+
+//////////////COLLISIONPLATFORME - ENEMY//////////////////////////////////////////////////
+/**
+@details Handles enemy collision with platform to the right
+*/
+bool Enemy::collisionPlatformE(deque<Platform*>* levelMap)
+{
+    for(deque<Platform*>::iterator it=levelMap->begin(); it !=levelMap->end();)
+    {
+        Platform* p=*it;
+        if (collisionLeftUpE(*p))
+        {
+            return true;
+        }
+        it++;
+    }
+    return false;
+}
+
+//////////////COLLISIONPLATFORMW - ENEMY//////////////////////////////////////////////////
+/**
+@details Handles enemy collision with platform to the left
+*/
+bool Enemy::collisionPlatformW(deque<Platform*>* levelMap)
+{
+    for(deque<Platform*>::iterator it=levelMap->begin(); it !=levelMap->end();)
+    {
+        Platform* p=*it;
+        if (collisionLeftUpW(*p))
+        {
+            return true;
+        }
+        it++;
+    }
+    return false;
+}
+
+//////////////COLLISIONPLATFORMS - ENEMY//////////////////////////////////////////////////
+/**
+@details Handles enemy collision with platform bellow
+*/
+bool Enemy::collisionPlatformS(deque<Platform*>* levelMap)
+{
+    for(deque<Platform*>::iterator it=levelMap->begin(); it !=levelMap->end();)
+    {
+        Platform* p=*it;
+        if (collisionLeftUpS(*p))
+        {
+            //pc.printf("ychar - %d\n", y);
+            //pc.printf("y-heightplatf - %d", p->getY() - p->getHeight());
+            return true;
+        }
+        it++;
+    }
+    return false;
+}
+
+//////////////COLLISIONPLATFORMN - ENEMY//////////////////////////////////////////////////
+/**
+@details Handles enemy collision with platform above
+*/
+bool Enemy::collisionPlatformN(deque<Platform*>* levelMap)
+{
+    for(deque<Platform*>::iterator it=levelMap->begin(); it !=levelMap->end();)
+    {
+        Platform* p=*it;
+        if (collisionLeftUpN(*p))
+        {
+            return true;
+        }
+        it++;
+    }
+    return false;
+}
+
+bool Enemy::getSpawned()
+{
+    return spawned;
+}
+
+void Enemy::setSpawned(bool spawned)
+{
+    this->spawned=spawned;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Enemy/Enemy.h	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,48 @@
+#ifndef ENEMY_H
+#define ENEMY_H 
+
+#include "mbed.h"
+#include "N5110.h"
+#include "Rectangle.h"
+#include "Platform.h"
+#include <deque>
+
+/**Enemy class
+@brief Class that handless enemy collisionand movement
+@author Lev Duman
+@date May 4 2017
+*/
+
+class Enemy: public Rectangle
+{ 
+    public:
+        /**Constructor*/
+        Enemy(int x, int y);
+        /**Destructor*/
+        ~Enemy();
+        /**Draws Enemy*/
+        void draw(N5110 &lcd,int absoluteCoord, bool white);
+        /**Collision with platform to the east*/
+        bool collisionPlatformE(deque<Platform*>* levelMap);
+        /**Collision with platform to the west*/
+        bool collisionPlatformW(deque<Platform*>* levelMap);
+        /**Collision with platform to the south*/
+        bool collisionPlatformS(deque<Platform*>* levelMap);
+        /**Collision with platform to the north*/
+        bool collisionPlatformN(deque<Platform*>* levelMap);
+        /**moves enemies*/
+        bool movement(int absoluteCoord, deque<Platform*>* levelMap);
+        /**fall for enemies*/
+        void fall(deque<Platform*>* levelMap);
+        /**triger for fall*/
+        void noPlatformFall(deque<Platform*>* levelMap);
+        bool getSpawned();
+        void setSpawned(bool);
+         
+    private:    
+        float force;
+        float floatY;
+        bool directionW;
+        bool spawned;   
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Gamepad.lib	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ELEC2645-201617/code/Finalproject/#e65a03646197
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Map/Map.cpp	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,123 @@
+#include "Map.h"
+#include <deque>
+#include "Gamepad.h"
+#include "Platform.h"
+#include "Enemy.h"
+#include "Character.h"
+#include "N5110.h"
+Serial pc(USBTX, USBRX);
+
+//constructor
+Map::Map(deque<Platform*>* levelMap, deque<Enemy*>* enemyMap, Character* character)
+:levelMap(levelMap), enemyMap(enemyMap), character(character)
+{
+    absoluteCoord = 0;
+}
+
+Map::~Map()  //destructor
+{
+
+}
+
+///////////////DRAW - MAP///////////////////////////////////////////////////////
+/**
+*@details  handles drawing of platforms, characters and enemies based on changing coordinates,
+*in addition deletes platofrms, and enemies that are unreachable
+*(map doesn't scroll left)
+*/
+void Map::draw(N5110 &lcd, bool white)
+{
+    //pc.printf("%d\n", absoluteCoord)
+    //pc.printf("drawing started");
+    character->draw(lcd, absoluteCoord, white);
+    //pc.printf("character finished drawing");
+    for(deque<Platform*>::iterator it=levelMap->begin(); it !=levelMap->end();)
+    {
+       Platform* p=*it;
+        if (((p->getX()+p->getWidth()-1-absoluteCoord)>=0)&&((p->getX()-absoluteCoord)<84))
+        {
+            p->draw(lcd, absoluteCoord, white); 
+            it++;  
+        }
+        else if ((p->getX()+p->getWidth()-1-absoluteCoord)<0)
+        {
+            levelMap->erase(it);   
+            it=levelMap->begin(); 
+        }
+        else
+        {
+            it++;
+        }
+    }
+    //pc.printf("Pre-cycle!");
+    for(deque<Enemy*>::iterator it=enemyMap->begin(); it !=enemyMap->end();)
+    {
+        Enemy* e=*it;
+        //pc.printf("Inside cycle! %d\n", it);
+        if (((e->getX()+e->getWidth()-1-absoluteCoord)>=0)&&((e->getX()-absoluteCoord)<84))
+        {
+            e->setSpawned(true);
+            //pc.printf("Drawing enemy!");
+            e->draw(lcd, absoluteCoord, white); 
+            it++;  
+        }
+        else if ((e->getX()+e->getWidth()-1-absoluteCoord)<0)
+        {
+            //pc.printf("Deleting enemy!");
+            enemyMap->erase(it);   
+            it=enemyMap->begin(); 
+        }
+        else
+        {
+            it++;   
+        } 
+    } 
+    //pc.printf("Past cycle!");
+}
+///////////////MOVEENEMIES - MAP///////////////////////////////////////////////////////
+/**
+*@details function that handles enemy movement
+*/
+void Map::moveEnemies()
+{
+    for(deque<Enemy*>::iterator it=enemyMap->begin(); it !=enemyMap->end();)
+    {
+        Enemy* e=*it;
+        if(e->getSpawned())
+        {
+            if(e->movement(absoluteCoord, levelMap))
+            {
+                enemyMap->erase(it);   
+                it=enemyMap->begin();
+            }
+            else
+            {
+                it++; 
+            }
+        }
+        else
+        {
+            it++;   
+        }
+    }
+}
+
+int* Map::getAbsoluteCoord()
+{
+    return &absoluteCoord;
+}
+
+Character* Map::getCharacter()
+{
+    return character;
+}
+
+deque<Platform*>* Map::getLevelMap()
+{
+    return levelMap;
+}
+
+deque<Enemy*>* Map::getEnemyMap()
+{
+    return enemyMap;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Map/Map.h	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,43 @@
+#ifndef MAP_H    
+#define MAP_H
+
+#include "mbed.h"
+#include "N5110.h"
+#include "Gamepad.h"
+#include "Platform.h"
+#include "Enemy.h"
+#include "Character.h"
+#include <deque>
+
+/**Map class
+@brief class that handles drawing and clearing of the map
+@author Lev Duman
+@date May 4 2017
+*/
+class Map
+{
+    
+public:
+    /**Constructor*/
+    Map(deque<Platform*>* levelMap, deque<Enemy*>* enemyMap, Character* character);
+    /**Destructor*/
+    ~Map();
+    /**Draws the map*/
+    void draw(N5110 &lcd,bool white);
+    /**Getter for absolute coordinate*/
+    int* getAbsoluteCoord();
+    /**Getter for character object*/
+    Character* getCharacter();
+    /**Getter for Map dequeue*/
+    deque<Platform*>* getLevelMap();
+    /**Getter for Enemy dequeue*/
+    deque<Enemy*>* getEnemyMap();
+    /**Function to move enemies*/
+    void moveEnemies();
+private:
+    deque<Platform*>* levelMap;
+    deque<Enemy*>* enemyMap;
+    Character* character;
+    int absoluteCoord;
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/N5110.lib	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/eencae/code/N5110/#c2598020fcac
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Platform/Platform.cpp	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,58 @@
+#include "Platform.h"
+#include "N5110.h"
+
+//Serial pc(USBTX, USBRX);
+Platform::Platform(int x, int y, int width, int height, FillType fill) //constructor
+{
+    //Stores values from the arguments into the constructed object fields
+    this->x = x;           
+    this->y = y;
+    this->width = width;
+    this->height = height;
+    this->fill = fill;
+}
+
+Platform::~Platform() // destructor
+{
+
+}
+
+///////////////////DRAW - PLATFORM//////////////////////////////////////////////
+/**
+@details converts platform's absolute coordinates into relative screen coordinates
+*and then draws the platform
+*/
+void Platform::draw(N5110 &lcd,int absoluteCoord, bool white)
+{
+     if((x-absoluteCoord)<0)
+     {  
+        if(white)
+        {
+            lcd.drawRect(0, y, width-absoluteCoord+x, height, FILL_WHITE);  
+        }
+        else
+        {
+            lcd.drawRect(0, y, width-absoluteCoord+x, height, fill);
+        }
+     }
+     else
+     {
+        if(white)
+        {
+            lcd.drawRect(x-absoluteCoord, y, width, height, FILL_WHITE);     
+        }
+        else
+        {
+            lcd.drawRect(x-absoluteCoord, y, width, height, fill);
+        }
+     }
+}
+
+////////////////////GETFILL - PLATFORM//////////////////////////////////////////////
+/**
+@details getter for fill type of platform
+*/
+FillType Platform::getFill()
+{
+    return fill;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Platform/Platform.h	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,32 @@
+#ifndef PLATFORM_H    
+#define PLATFORM_H
+
+
+#include "N5110.h"
+#include "Rectangle.h"
+
+/** Platform class
+@brief class that draws out single platforms
+@author Lev Duman
+@date May 4 2017
+*/
+
+
+class Platform: public Rectangle
+{
+    
+    public:
+        /**Constructor*/
+        Platform(int x, int y, int width, int height, FillType fill);
+        /**Destructor*/
+        ~Platform();
+        /**Draws the platform*/
+        void draw(N5110 &lcd, int absoluteCoord, bool white);
+        /**Getter for Fill type*/
+        FillType getFill();
+        
+    private:
+        FillType fill;
+    
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Rectangle/Rectangle.cpp	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,165 @@
+#include "Rectangle.h"
+//Serial pc(USBTX, USBRX);
+
+//////////////COLLISIONLEFTUPS - RECTANGLE//////////////////////////////////////////////////
+/**
+@details collision condition between given object and passed object
+* (This function is when passed object has origins point at top left corner)
+*/
+bool Rectangle::collisionLeftUpS(Rectangle a)
+{
+    if (y==(a.y-1))
+    {
+        if (((x+width-1)>=a.x)&&(x<=(a.x+a.width-1)))
+        {
+            return true;
+        }
+    }
+    return false;
+}    
+
+//////////////COLLISIONLEFTUPN - RECTANGLE//////////////////////////////////////////////////
+/**
+@details collision condition between given object and passed object
+* (This function is when passed object has origins point at top left corner)
+*/
+bool Rectangle::collisionLeftUpN(Rectangle a)
+{
+    if ((y-height+1)==(a.y+a.height))
+    {
+        if (((x+width-1)>=a.x)&&(x<=(a.x+a.width-1)))
+        {
+            //pc.printf("Collision S\n");
+            //pc.printf("x - %d width - %d y - %d height - %d\n", x, width, y, height);
+            //pc.printf("Ax - %d width - %d y - %d height - %d\n", a.x, a.width, a.y, a.height);
+            return true;
+        }
+    }
+    return false;
+}
+
+//////////////COLLISIONLEFTUPW - RECTANGLE//////////////////////////////////////////////////
+/**
+@details collision condition between given object and passed object
+* (This function is when passed object has origins point at top left corner)
+*/
+bool Rectangle::collisionLeftUpW(Rectangle a)
+{
+    if (x==(a.x+a.width))
+    {
+        if ((y>=a.y)&&((y-height+1)<=(a.y+a.height-1)))
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+//////////////COLLISIONLEFTUPE - RECTANGLE//////////////////////////////////////////////////
+/**
+@details collision condition between given object and passed object
+* (This function is when passed object has origins point at top left corner)
+*/
+bool Rectangle::collisionLeftUpE(Rectangle a)
+{
+    if ((x+width)==(a.x))
+    {
+        if ((y>=a.y)&&((y-height+1)<=(a.y+a.height-1)))
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+//////////////TOUCHLEFTDOWNN - RECTANGLE//////////////////////////////////////////////////
+/**
+@details touching condition between given object and passed object
+* (This function is when passed object has origins point at bottom left down)
+*/
+bool Rectangle::touchLeftDownN(Rectangle a)
+{
+    if((y-height+1)==a.y)
+    {
+        if(((x+width-1)>=a.x)&&(x<=(a.x+a.width-1)))
+        {
+            return true;
+        }   
+    }
+    return false;
+}
+
+//////////////TOUCHLEFTDOWNS - RECTANGLE//////////////////////////////////////////////////
+/**
+@details touching condition given object and passed object
+* (This function is when passed object has origins point at bottom left down)
+*/
+bool Rectangle::touchLeftDownS(Rectangle a)
+{
+    if(y==(a.y-a.height+1))
+    {
+        if(((x+width-1)>=a.x)&&(x<=(a.x+a.width-1)))
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+//////////////TOUCHLEFTDOWNW - RECTANGLE//////////////////////////////////////////////////
+/**
+@details touching condition given object and passed object
+* (This function is when passed object has origins point at bottom left down)
+*/
+bool Rectangle::touchLeftDownW(Rectangle a)
+{
+    if(x==(a.x+a.width-1))
+    {
+        if(((y-height+1)<=a.y)&&(y>=(a.y-a.height+1)))
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+//////////////TOUCHLEFTDOWNE - RECTANGLE//////////////////////////////////////////////////
+/**
+@details touching condition given object and passed object
+* (This function is when passed object has origins point at bottom left down)
+*/
+bool Rectangle::touchLeftDownE(Rectangle a)
+{
+    if(x+width-1==a.x)
+    {
+        if(((y-height+1)<=a.y)&&(y>=(a.y-a.height+1)))
+        {
+            return true;
+        }   
+    }
+    return false;
+}
+
+//getter of variable X
+int Rectangle::getX()
+{
+    return x;       
+}
+
+//getter of variable Y
+int Rectangle::getY()
+{    
+    return y;   
+}
+
+//getter of variable Width
+int Rectangle::getWidth()
+{
+    return width;          
+}
+
+//getter of variable Height
+int Rectangle::getHeight()
+{
+    return height;                
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Rectangle/Rectangle.h	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,40 @@
+#ifndef RECTANGLE_H
+#define RECTANGLE_H 
+
+#include "mbed.h"
+
+/**Rectangle class
+@brief Abstract class that defines collision between rectangles
+@author Lev Duman
+@date May 4 2017
+*/
+class Rectangle 
+{
+    public:
+        /**Coollion to the north*/
+        bool collisionLeftUpN(Rectangle a);
+        /**Coollion to the south*/
+        bool collisionLeftUpS(Rectangle a);
+        /**Coollion to the west*/
+        bool collisionLeftUpW(Rectangle a);
+        /**Coollion to the east*/
+        bool collisionLeftUpE(Rectangle a);
+        /**Coollion to the north*/
+        bool touchLeftDownN(Rectangle a);
+        /**Coollion to the south*/
+        bool touchLeftDownS(Rectangle a);
+        /**Coollion to the west*/
+        bool touchLeftDownW(Rectangle a);
+        /**Coollion to the east*/
+        bool touchLeftDownE(Rectangle a);
+        int getX();
+        int getY();
+        int getWidth();
+        int getHeight();
+    protected:
+        int x;
+        int y;
+        int height;
+        int width;
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,221 @@
+#include "mbed.h"
+#include "Gamepad.h"
+#include "N5110.h"
+#include <deque>
+#include "Platform.h"
+#include "Map.h"
+#include "Character.h"
+#include "Enemy.h"
+
+//Serial pc(USBTX, USBRX);
+
+//create lcd object
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+//create gamepad object
+Gamepad pad;
+
+//create timer object
+Timer t;
+
+// booleans for win/loose/start conditions
+bool win = false;
+bool loose = false;
+bool start = false;
+
+//function to initialise everything needed
+void init()
+{
+    //Initialise gamepad and LCD
+    lcd.init();
+    pad.init();
+}
+
+//function that displays welcoming screen 
+void welcome()
+{
+   lcd.printString("Welcome",20,1);
+   lcd.refresh();
+   pad.leds_on();
+   wait(2.0);
+   lcd.clear();
+}
+
+//function that displays press start
+void pressStart()
+{
+   lcd.printString("Press start",10,1);
+   lcd.printString("to begin",15,3);
+   lcd.refresh();
+   pad.leds_off();
+}
+
+//function that displays game over screen 
+void gameOver()
+{
+    lcd.printString("Game Over",17,1);
+    lcd.refresh(); 
+    wait(1.0);
+    lcd.clear();   
+}
+
+//function do display win screen
+void winner()
+{
+    lcd.printString("You Won",20,1);
+    lcd.refresh();
+    wait(4.0);
+    lcd.clear();    
+}
+
+// function to create platform list
+deque<Platform*>* createLevel()
+{
+    //declare new queue named levelMap
+    deque <Platform*>* levelMap = new deque<Platform*>;
+    //create new platform
+    Platform* p = new Platform(0,44,30,3,FILL_BLACK);
+    //insert new platofrm into queue
+    levelMap->push_back(p);
+     //create new platform
+    //p = new Platform(40,37,10,3,FILL_BLACK);
+    //insert new platofrm into queue
+    //levelMap->push_back(p);
+     //create new platform
+    p = new Platform(40,35,10,3,FILL_BLACK);
+    //insert new platofrm into queue
+    levelMap->push_back(p);
+    p = new Platform(70,44,40,3,FILL_BLACK);
+    //insert new platofrm into queue
+    levelMap->push_back(p);
+    p = new Platform(70,41,3,3,FILL_BLACK);
+    levelMap->push_back(p);
+    p = new Platform(130,44,50,3,FILL_BLACK);
+    levelMap->push_back(p);
+    p = new Platform(130,41,3,3,FILL_BLACK);
+    levelMap->push_back(p);
+    p = new Platform(177,41,3,3,FILL_BLACK);
+    levelMap->push_back(p);
+    p = new Platform(190,30,10,3,FILL_BLACK);
+    levelMap->push_back(p);
+    p = new Platform(230,44,30,3,FILL_BLACK);
+    levelMap->push_back(p);
+    p = new Platform(260,35,20,3,FILL_BLACK);
+    levelMap->push_back(p);
+    p = new Platform(290,25,20,3,FILL_BLACK);
+    levelMap->push_back(p);
+    p = new Platform(230,41,3,3,FILL_BLACK);
+    levelMap->push_back(p);
+      
+    return levelMap;
+}
+
+// function to create enemy list
+deque<Enemy*>* createEnemies()
+{
+    //declare new queue named enemyMap
+    deque <Enemy*>* enemyMap = new deque<Enemy*>;
+    //create new enemy
+    Enemy* e = new Enemy(105,43);
+    //insert new enemy into queue
+    enemyMap->push_back(e);
+    //create new enemy
+    e = new Enemy(140,43);
+    //insert new enemy into queue
+    enemyMap->push_back(e);
+    e = new Enemy(250,43);
+    enemyMap->push_back(e);
+    e = new Enemy(270,43);
+    enemyMap->push_back(e);
+    e = new Enemy(30,43);
+    enemyMap->push_back(e);
+          
+    return enemyMap;
+}
+
+int main()
+{
+    init();
+    //clear lcd
+    lcd.clear();
+    Direction d;
+    int lastAction=-50;
+    int monsterMove=-100;
+    //reset timer
+    t.reset();
+    //start timer
+    t.start();
+    //welcome screen 
+    welcome();
+    while(true)
+    {
+        pressStart();
+        while(!start)
+        {
+            if(pad.check_event(pad.START_PRESSED))
+            {
+                start=true;   
+            }
+        }
+        //create map object
+        Map map1(createLevel(), createEnemies(), new Character(5,40));
+        start=false;
+        //clear lcd
+        lcd.clear();
+        //draw buffer to screen 
+        lcd.refresh();
+        
+        //game loop
+        while(!win && !loose)
+        {
+            if((t.read_ms()-lastAction)>50)
+            {
+                lastAction=t.read_ms();
+                //get direction from joystick
+                d = pad.get_direction();
+                //draw map
+                map1.draw(lcd, true);
+                //if((t.read_ms()-monsterMove)>100)
+                //{
+                    monsterMove=t.read_ms();
+                    //move all enemies 
+                    map1.moveEnemies();
+                //}
+                //mov and draw characters
+                map1.getCharacter()->movement(d, map1.getAbsoluteCoord(), map1.getLevelMap(), map1.getEnemyMap());
+                //loosing condition
+                if ((map1.getCharacter()->getY()>47) || pad.check_event(pad.BACK_PRESSED))
+                {
+                    loose=true;
+                    wait(0.3);
+                }
+                //clear map
+                else
+                {
+                    map1.draw(lcd, false);
+                }
+                //wining condition
+                if (map1.getCharacter()->getX()==300)
+                {
+                    win=true;   
+                }
+                //refresh screen 
+                lcd.refresh();
+            }
+        }
+        lcd.clear();
+        lcd.refresh();
+        //display loosing screen 
+        if (loose)
+        {
+            gameOver();  
+        }
+        //display wining screen 
+        else
+        {
+           winner();         
+        }
+        //reset booleans
+        win=false;
+        loose=false;
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 05 15:00:33 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/794e51388b66
\ No newline at end of file