James Heavey / Mbed 2 deprecated EL17JH

Dependencies:   mbed

Committer:
jamesheavey
Date:
Mon May 06 22:57:04 2019 +0000
Revision:
91:c01a736fb0d9
Parent:
77:d50fb95c012f
Child:
93:18f81996ea89
paddle commented

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jamesheavey 28:d058f7f5885d 1 #include "Laser.h"
jamesheavey 28:d058f7f5885d 2
jamesheavey 28:d058f7f5885d 3 Laser::Laser()
jamesheavey 28:d058f7f5885d 4 {
jamesheavey 28:d058f7f5885d 5
jamesheavey 28:d058f7f5885d 6 }
jamesheavey 28:d058f7f5885d 7
jamesheavey 28:d058f7f5885d 8 Laser::~Laser()
jamesheavey 28:d058f7f5885d 9 {
jamesheavey 28:d058f7f5885d 10
jamesheavey 28:d058f7f5885d 11 }
jamesheavey 28:d058f7f5885d 12
jamesheavey 28:d058f7f5885d 13 void Laser::init(int x)
jamesheavey 28:d058f7f5885d 14 {
jamesheavey 91:c01a736fb0d9 15
jamesheavey 28:d058f7f5885d 16 _x = x;
jamesheavey 28:d058f7f5885d 17 _y = HEIGHT - 2;
jamesheavey 91:c01a736fb0d9 18
jamesheavey 28:d058f7f5885d 19 _velocity.x = 0;
jamesheavey 28:d058f7f5885d 20 _velocity.y = -2;
jamesheavey 91:c01a736fb0d9 21
jamesheavey 28:d058f7f5885d 22 }
jamesheavey 28:d058f7f5885d 23
jamesheavey 28:d058f7f5885d 24 void Laser::draw(N5110 &lcd)
jamesheavey 28:d058f7f5885d 25 {
jamesheavey 77:d50fb95c012f 26 if (_x >= 0) { // only draw if on screen (more efficient?)
jamesheavey 77:d50fb95c012f 27 lcd.drawRect(_x,_y,2,6,FILL_BLACK);
jamesheavey 77:d50fb95c012f 28 }
jamesheavey 28:d058f7f5885d 29 }
jamesheavey 28:d058f7f5885d 30
jamesheavey 28:d058f7f5885d 31 void Laser::update()
jamesheavey 28:d058f7f5885d 32 {
jamesheavey 28:d058f7f5885d 33 _x += _velocity.x;
jamesheavey 28:d058f7f5885d 34 _y += _velocity.y;
jamesheavey 28:d058f7f5885d 35 }
jamesheavey 28:d058f7f5885d 36
jamesheavey 28:d058f7f5885d 37
jamesheavey 28:d058f7f5885d 38
jamesheavey 91:c01a736fb0d9 39 int Laser::get_x()
jamesheavey 91:c01a736fb0d9 40 {
jamesheavey 91:c01a736fb0d9 41 return _x;
jamesheavey 36:cb73014d3a99 42 }
jamesheavey 36:cb73014d3a99 43
jamesheavey 91:c01a736fb0d9 44 int Laser::get_y()
jamesheavey 91:c01a736fb0d9 45 {
jamesheavey 91:c01a736fb0d9 46 return _y;
jamesheavey 28:d058f7f5885d 47 }
jamesheavey 28:d058f7f5885d 48
jamesheavey 36:cb73014d3a99 49
jamesheavey 36:cb73014d3a99 50 void Laser::set_posx(int x)
jamesheavey 28:d058f7f5885d 51 {
jamesheavey 36:cb73014d3a99 52 _x = x;
jamesheavey 36:cb73014d3a99 53 }
jamesheavey 36:cb73014d3a99 54
jamesheavey 36:cb73014d3a99 55 void Laser::set_posy(int y)
jamesheavey 36:cb73014d3a99 56 {
jamesheavey 36:cb73014d3a99 57 _y = y;
jamesheavey 28:d058f7f5885d 58 }