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 Gamepad N5110 mbed-rtos
Enemy/Enemy.cpp
- Committer:
- RexRoshan
- Date:
- 2019-05-05
- Revision:
- 4:4d673fb2d9dc
- Parent:
- 0:99fa5a619081
- Child:
- 6:1fcfd331c047
File content as of revision 4:4d673fb2d9dc:
#include "Enemy.h" // nothing doing in the constructor and destructor Enemy::Enemy() { } Enemy::~Enemy() { } // first enemy sprite int enemy1 [7][8] = { {0,1,1,0,0,0,0,1}, {0,0,0,1,1,1,1,1}, {0,0,1,0,0,1,1,0}, {0,1,0,0,1,1,1,0}, {0,0,1,0,0,1,1,0}, {0,0,0,1,1,1,1,1}, {0,1,1,0,0,0,0,1}, }; void Enemy::init(int a,int b) // initialising the x and y position of the enemy { _a = a; // x position of the enemy _b = b; // y position of the enemy _health = 0; // start health from zero } void Enemy::enemy(N5110 &lcd) { // draws the first enemy lcd.drawSprite(_a,_b,7,8,(int *)enemy1); } void Enemy::update() // moves the position of the enemy when the enemy dies { _speed = 2.0; // set at 2 so that it is not too fast _b+=_speed; // moves the y-position downwards } void Enemy::add_health() { // increments the value of health by 1 _health++; } int Enemy::get_health() { // gets the value of health return _health; } Vector2D Enemy::get_enemy_pos() { //gets the position of the first enemy Vector2D e = {_a,_b}; return e; }