ELEC2645 (2018/19) / Mbed 2 deprecated el17m2h_public

Dependencies:   mbed

Committer:
el17m2h
Date:
Thu May 09 11:39:59 2019 +0000
Revision:
33:de130e274391
Parent:
31:5c4acae51026
Child:
37:71f2cd073739
Changed trivial functions to one-line structure.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17m2h 20:a359092079b0 1 #include "Enemy.h"
el17m2h 29:15e9640646b7 2 Enemy::Enemy()
el17m2h 29:15e9640646b7 3 {
el17m2h 20:a359092079b0 4 }
el17m2h 29:15e9640646b7 5 Enemy::~Enemy()
el17m2h 29:15e9640646b7 6 {
el17m2h 29:15e9640646b7 7 }
el17m2h 29:15e9640646b7 8 void Enemy::update(Vector2D floor_pos) // sets its position
el17m2h 29:15e9640646b7 9 {
el17m2h 31:5c4acae51026 10 _position.x = floor_pos.x + 7 - 6; // the + 7 for the centre of the floor and the + 6 for the centre of the ghost
el17m2h 31:5c4acae51026 11 _position.y = floor_pos.y - 1 - 13; // the - 1 is so that it is on top of the floor's position
el17m2h 29:15e9640646b7 12 // and the + 15 is so that it considers the position of the feet of the ghost (not the top)
el17m2h 20:a359092079b0 13 }
el17m2h 20:a359092079b0 14
el17m2h 29:15e9640646b7 15 void Enemy::draw(N5110 &lcd)
el17m2h 29:15e9640646b7 16 {
el17m2h 30:863565e9859f 17 const int image [12][12] = {
el17m2h 29:15e9640646b7 18 {0,0,0,0,1,1,1,1,0,0,0,0},
el17m2h 29:15e9640646b7 19 {0,0,1,1,0,0,0,0,1,1,0,0},
el17m2h 29:15e9640646b7 20 {0,1,0,0,0,0,0,0,0,0,1,0},
el17m2h 30:863565e9859f 21 {1,0,0,1,0,0,0,0,1,0,0,1},
el17m2h 29:15e9640646b7 22 {1,0,1,1,1,0,0,1,1,1,0,1},
el17m2h 30:863565e9859f 23 {1,0,0,1,0,0,0,0,1,0,0,1},
el17m2h 29:15e9640646b7 24 {1,0,0,0,0,0,0,0,0,0,0,1},
el17m2h 29:15e9640646b7 25 {1,0,0,0,0,0,0,0,0,0,0,1},
el17m2h 29:15e9640646b7 26 {1,0,0,0,0,0,0,0,0,0,0,1},
el17m2h 29:15e9640646b7 27 {1,1,1,0,0,1,1,0,0,1,1,1},
el17m2h 29:15e9640646b7 28 {1,1,0,1,1,0,0,1,1,0,1,1},
el17m2h 29:15e9640646b7 29 {1,0,0,0,1,0,0,1,0,0,0,1},
el17m2h 23:9be87557b89a 30 };
el17m2h 30:863565e9859f 31 lcd.drawSprite(_position.x, _position.y, 12, 12,(int*)image);
el17m2h 20:a359092079b0 32 }
el17m2h 20:a359092079b0 33
el17m2h 33:de130e274391 34 // Called in floors file if enemy is meant to get erased (moves the ghost out of the screen's visibility
el17m2h 33:de130e274391 35 void Enemy::erase(){ _position.x = 90; _position.y = 50; }
el17m2h 20:a359092079b0 36
el17m2h 33:de130e274391 37 Vector2D Enemy::get_position(){ Vector2D p = {_position.x,_position.y}; return p; }