ELEC2645 (2018/19) / Mbed 2 deprecated el17m2h_public

Dependencies:   mbed

Committer:
el17m2h
Date:
Thu May 09 08:59:39 2019 +0000
Revision:
30:863565e9859f
Parent:
29:15e9640646b7
Child:
31:5c4acae51026
Changed the size of the enemy and updated the new values in the floors cpp. I also added the test code for the doodler's movement and called it on the main cpp.

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 29:15e9640646b7 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 30:863565e9859f 11 _position.y = floor_pos.y - 2 - 13; // the - 2 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 29:15e9640646b7 34 void Enemy::erase() // decides if it gets erased
el17m2h 29:15e9640646b7 35 {
el17m2h 29:15e9640646b7 36 _position.x = 90; // the ghost's is no longer shown on the screen
el17m2h 29:15e9640646b7 37 _position.y = 50;
el17m2h 20:a359092079b0 38 }
el17m2h 20:a359092079b0 39
el17m2h 29:15e9640646b7 40 Vector2D Enemy::get_position()
el17m2h 29:15e9640646b7 41 {
el17m2h 20:a359092079b0 42 Vector2D p = {_position.x,_position.y};
el17m2h 20:a359092079b0 43 return p;
el17m2h 20:a359092079b0 44 }