Nemesis game, second enemy

Committer:
musallambseiso
Date:
Tue May 02 22:14:15 2017 +0000
Revision:
7:56bb2fb8b9f3
Child:
8:722dec08a18c
Added Doxygen, tidied code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
musallambseiso 7:56bb2fb8b9f3 1 #include "Enemy2.h"
musallambseiso 7:56bb2fb8b9f3 2
musallambseiso 7:56bb2fb8b9f3 3 Enemy2::Enemy2()
musallambseiso 7:56bb2fb8b9f3 4 {
musallambseiso 7:56bb2fb8b9f3 5
musallambseiso 7:56bb2fb8b9f3 6 }
musallambseiso 7:56bb2fb8b9f3 7
musallambseiso 7:56bb2fb8b9f3 8 Enemy2::~Enemy2()
musallambseiso 7:56bb2fb8b9f3 9 {
musallambseiso 7:56bb2fb8b9f3 10
musallambseiso 7:56bb2fb8b9f3 11 }
musallambseiso 7:56bb2fb8b9f3 12
musallambseiso 7:56bb2fb8b9f3 13 void Enemy2::init(int speed)
musallambseiso 7:56bb2fb8b9f3 14 {
musallambseiso 7:56bb2fb8b9f3 15 int x = rand() % 63 + 84;
musallambseiso 7:56bb2fb8b9f3 16 _x = x;
musallambseiso 7:56bb2fb8b9f3 17 _y = 7;
musallambseiso 7:56bb2fb8b9f3 18
musallambseiso 7:56bb2fb8b9f3 19 _velocity.x = -speed;
musallambseiso 7:56bb2fb8b9f3 20 _velocity.y = 0;
musallambseiso 7:56bb2fb8b9f3 21 }
musallambseiso 7:56bb2fb8b9f3 22
musallambseiso 7:56bb2fb8b9f3 23 void Enemy2::draw(N5110 &lcd)
musallambseiso 7:56bb2fb8b9f3 24 {
musallambseiso 7:56bb2fb8b9f3 25 lcd.drawLine(_x,_y,_x,_y+5,1);
musallambseiso 7:56bb2fb8b9f3 26 lcd.drawLine(_x-1,_y,_x-1,_y+5,1);
musallambseiso 7:56bb2fb8b9f3 27 lcd.drawLine(_x-2,_y+1,_x-2,_y+4,1);
musallambseiso 7:56bb2fb8b9f3 28 lcd.drawLine(_x-3,_y+1,_x-3,_y+4,1);
musallambseiso 7:56bb2fb8b9f3 29 lcd.drawLine(_x-4,_y+2,_x-4,_y+3,1);
musallambseiso 7:56bb2fb8b9f3 30 }
musallambseiso 7:56bb2fb8b9f3 31
musallambseiso 7:56bb2fb8b9f3 32 void Enemy2::update()
musallambseiso 7:56bb2fb8b9f3 33 {
musallambseiso 7:56bb2fb8b9f3 34 _x += _velocity.x;
musallambseiso 7:56bb2fb8b9f3 35 _y += _velocity.y;
musallambseiso 7:56bb2fb8b9f3 36 }
musallambseiso 7:56bb2fb8b9f3 37
musallambseiso 7:56bb2fb8b9f3 38 Vector2D Enemy2::get_pos()
musallambseiso 7:56bb2fb8b9f3 39 {
musallambseiso 7:56bb2fb8b9f3 40 Vector2D p = {_x,_y};
musallambseiso 7:56bb2fb8b9f3 41 return p;
musallambseiso 7:56bb2fb8b9f3 42 }