Nemesis game, stats

Committer:
musallambseiso
Date:
Sat Apr 01 11:43:25 2017 +0000
Revision:
5:b822aaa6200d
Fixed collisions, works perfectly

Who changed what in which revision?

UserRevisionLine numberNew contents of line
musallambseiso 5:b822aaa6200d 1 #include "Ship1.h"
musallambseiso 5:b822aaa6200d 2
musallambseiso 5:b822aaa6200d 3 Ship1::Ship1()
musallambseiso 5:b822aaa6200d 4 {
musallambseiso 5:b822aaa6200d 5
musallambseiso 5:b822aaa6200d 6 }
musallambseiso 5:b822aaa6200d 7
musallambseiso 5:b822aaa6200d 8 Ship1::~Ship1()
musallambseiso 5:b822aaa6200d 9 {
musallambseiso 5:b822aaa6200d 10
musallambseiso 5:b822aaa6200d 11 }
musallambseiso 5:b822aaa6200d 12
musallambseiso 5:b822aaa6200d 13 void Ship1::init(int size,int speed)
musallambseiso 5:b822aaa6200d 14 {
musallambseiso 5:b822aaa6200d 15 _size = size;
musallambseiso 5:b822aaa6200d 16
musallambseiso 5:b822aaa6200d 17 int x = rand() % 63 + 84;
musallambseiso 5:b822aaa6200d 18 _x = x;
musallambseiso 5:b822aaa6200d 19 _y = 1;
musallambseiso 5:b822aaa6200d 20
musallambseiso 5:b822aaa6200d 21 _velocity.x = -speed;
musallambseiso 5:b822aaa6200d 22 _velocity.y = 0;
musallambseiso 5:b822aaa6200d 23 }
musallambseiso 5:b822aaa6200d 24
musallambseiso 5:b822aaa6200d 25 void Ship1::draw(N5110 &lcd)
musallambseiso 5:b822aaa6200d 26 {
musallambseiso 5:b822aaa6200d 27 lcd.drawLine(_x,_y,_x,_y+5,1);
musallambseiso 5:b822aaa6200d 28 lcd.drawLine(_x-1,_y,_x-1,_y+5,1);
musallambseiso 5:b822aaa6200d 29 lcd.drawLine(_x-2,_y+1,_x-2,_y+4,1);
musallambseiso 5:b822aaa6200d 30 lcd.drawLine(_x-3,_y+1,_x-3,_y+4,1);
musallambseiso 5:b822aaa6200d 31 lcd.drawLine(_x-4,_y+2,_x-4,_y+3,1);
musallambseiso 5:b822aaa6200d 32 }
musallambseiso 5:b822aaa6200d 33
musallambseiso 5:b822aaa6200d 34 void Ship1::update()
musallambseiso 5:b822aaa6200d 35 {
musallambseiso 5:b822aaa6200d 36 _x += _velocity.x;
musallambseiso 5:b822aaa6200d 37 _y += _velocity.y;
musallambseiso 5:b822aaa6200d 38 }
musallambseiso 5:b822aaa6200d 39
musallambseiso 5:b822aaa6200d 40 void Ship1::set_velocity(Vector2D v)
musallambseiso 5:b822aaa6200d 41 {
musallambseiso 5:b822aaa6200d 42 _velocity.x = v.x;
musallambseiso 5:b822aaa6200d 43 _velocity.y = v.y;
musallambseiso 5:b822aaa6200d 44 }
musallambseiso 5:b822aaa6200d 45
musallambseiso 5:b822aaa6200d 46 Vector2D Ship1::get_velocity()
musallambseiso 5:b822aaa6200d 47 {
musallambseiso 5:b822aaa6200d 48 Vector2D v = {_velocity.x,_velocity.y};
musallambseiso 5:b822aaa6200d 49 return v;
musallambseiso 5:b822aaa6200d 50 }
musallambseiso 5:b822aaa6200d 51
musallambseiso 5:b822aaa6200d 52 Vector2D Ship1::get_pos()
musallambseiso 5:b822aaa6200d 53 {
musallambseiso 5:b822aaa6200d 54 Vector2D p = {_x,_y};
musallambseiso 5:b822aaa6200d 55 return p;
musallambseiso 5:b822aaa6200d 56 }
musallambseiso 5:b822aaa6200d 57
musallambseiso 5:b822aaa6200d 58 void Ship1::set_pos(Vector2D p)
musallambseiso 5:b822aaa6200d 59 {
musallambseiso 5:b822aaa6200d 60 _x = p.x;
musallambseiso 5:b822aaa6200d 61 _y = p.y;
musallambseiso 5:b822aaa6200d 62 }