Nemesis game, first enemy

Committer:
musallambseiso
Date:
Tue May 02 22:13:59 2017 +0000
Revision:
7:3d951a743dbe
Child:
8:2ced844d8292
Added Doxygen, tidied code

Who changed what in which revision?

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