Nemesis game, stats

Committer:
musallambseiso
Date:
Sun Apr 02 17:47:38 2017 +0000
Revision:
6:fb678d095e0a
Parent:
Ship1.cpp@5:b822aaa6200d
Added framework for bullet, still minimal progress

Who changed what in which revision?

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