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.
Dependencies: mbed
Game/Game.cpp
- Committer:
- S_Tingle
- Date:
- 2019-05-06
- Revision:
- 15:a080c64cf301
- Parent:
- 14:d0650d0de063
- Child:
- 16:37d98c281eb3
File content as of revision 15:a080c64cf301:
#include "Game.h" Game::Game(){ } Game::~Game(){ } void Game::init(){ smiley.init(x,y); } void Game::dirmag(Gamepad &pad){ dir = pad.get_direction(); mag = pad.get_mag(); } void Game::drawSprite(N5110 &lcd){ maze.drawSprite(lcd); enemy1.drawSprite(lcd); enemy2.drawSprite(lcd); coin.drawSprite(lcd); smiley.drawSprite(lcd); } void Game::collect(Smiley smiley,Coin coin,N5110 &lcd){ int x_coin; int y_coin; if(smiley.northCollision(x_char, y_char, lcd) == true && coin.southCollision(x_char, y_char, lcd) == true){ x_coin = 100; y_coin = 100; } } void Game::movement(Gamepad &pad, N5110 &lcd){ smiley.movement(dir,lcd); enemy1.movement(lcd); enemy2.movement(lcd); } void Game::damage(int lives){ lives = 3; if(smiley.northCollision(x_char, y_char, lcd) == true && enemy1.southCollision(x_char, y_char, lcd) == true){ lives--; } else if(smiley.southCollision(x_char, y_char, lcd) == true && enemy1.northCollision(x_char, y_char, lcd) == true){ lives--; } else if(smiley.eastCollision(x_char, y_char, lcd) == true && enemy1.westCollision(x_char, y_char, lcd) == true){ lives--; } else if(smiley.westCollision(x_char, y_char, lcd) == true && enemy1.eastCollision(x_char, y_char, lcd) == true){ lives--; } }