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-04-13
- Revision:
- 0:99fa5a619081
- Child:
- 4:4d673fb2d9dc
File content as of revision 0:99fa5a619081:
#include "Enemy.h" // nothing doing in the constructor and destructor Enemy::Enemy() { } Enemy::~Enemy() { } 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}, }; //int boss [13][13] = { //{0,0,0,0,0,1,1,1,1,1,0,0,0}, //{0,0,0,0,0,0,1,1,1,0,0,0,0}, //{0,0,1,1,1,1,1,1,1,1,1,1,1}, //{0,0,0,0,0,1,0,1,0,0,1,0,0}, //{0,0,0,0,1,0,1,0,1,0,1,0,0}, //{0,0,0,1,0,0,0,1,0,1,1,0,0}, //{1,1,1,1,0,1,0,1,0,1,1,0,0}, //{0,0,0,1,0,0,0,1,0,1,1,0,0}, //{0,0,0,0,1,0,1,0,1,0,1,0,0}, //{0,0,0,0,0,1,0,1,0,0,1,0,0}, //{0,0,1,1,1,1,1,1,1,1,1,1,1}, //{0,0,0,0,0,0,1,1,1,0,0,0,0}, //{0,0,0,0,0,1,1,1,1,1,0,0,0}, //}; void Enemy::init(int a,int b) { _a = a; _b = b; _health = 0; // start health from zero } void Enemy::enemy(N5110 &lcd) { // draw the first enemy lcd.drawSprite(_a,_b,7,8,(int *)enemy1); } void Enemy::update() { _speed = 2.0; // scale is arbitrary, could be changed in future // update y value depending on direction of movement // North is decrement as origin is at the top-left so decreasing moves up _b+=_speed; } void Enemy::add_health() { _health++; } int Enemy::get_health() { return _health; } Vector2D Enemy::get_enemy_pos() { Vector2D e = {_a,_b}; return e; }