ELEC2645 (2018/19) / Mbed 2 deprecated el17rrrs

Dependencies:   mbed Gamepad N5110 mbed-rtos

Committer:
RexRoshan
Date:
Thu May 09 09:49:35 2019 +0000
Revision:
0:d9cf94b41df3
Documentation has been completed and the code has been slightly modified

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RexRoshan 0:d9cf94b41df3 1 #include "Beam.h"
RexRoshan 0:d9cf94b41df3 2
RexRoshan 0:d9cf94b41df3 3 Beam::Beam()
RexRoshan 0:d9cf94b41df3 4 {
RexRoshan 0:d9cf94b41df3 5
RexRoshan 0:d9cf94b41df3 6 }
RexRoshan 0:d9cf94b41df3 7
RexRoshan 0:d9cf94b41df3 8 Beam::~Beam()
RexRoshan 0:d9cf94b41df3 9 {
RexRoshan 0:d9cf94b41df3 10
RexRoshan 0:d9cf94b41df3 11 }
RexRoshan 0:d9cf94b41df3 12
RexRoshan 0:d9cf94b41df3 13 void Beam::init(int size,int a, int b) // Initialise the size, x and y position of the beam
RexRoshan 0:d9cf94b41df3 14 {
RexRoshan 0:d9cf94b41df3 15 _size = size;
RexRoshan 0:d9cf94b41df3 16 _x = _size; // length of the beam
RexRoshan 0:d9cf94b41df3 17 _y = 1; // height of the beam
RexRoshan 0:d9cf94b41df3 18 _a = a + 11; // x position of the beam
RexRoshan 0:d9cf94b41df3 19 _b = b + 5; // y position of the beam
RexRoshan 0:d9cf94b41df3 20 }
RexRoshan 0:d9cf94b41df3 21
RexRoshan 0:d9cf94b41df3 22 void Beam::draw(N5110 &lcd)
RexRoshan 0:d9cf94b41df3 23 {
RexRoshan 0:d9cf94b41df3 24 lcd.drawRect(_a,_b,_x,_y,FILL_BLACK);
RexRoshan 0:d9cf94b41df3 25 }
RexRoshan 0:d9cf94b41df3 26
RexRoshan 0:d9cf94b41df3 27 void Beam::update()
RexRoshan 0:d9cf94b41df3 28 {
RexRoshan 0:d9cf94b41df3 29 _speed = 5.0; // sets the movement speed of the beam to be 5
RexRoshan 0:d9cf94b41df3 30
RexRoshan 0:d9cf94b41df3 31 _a+=_speed; // moves in the x direction
RexRoshan 0:d9cf94b41df3 32
RexRoshan 0:d9cf94b41df3 33 }
RexRoshan 0:d9cf94b41df3 34
RexRoshan 0:d9cf94b41df3 35 Vector2D Beam::get_pos()
RexRoshan 0:d9cf94b41df3 36 {
RexRoshan 0:d9cf94b41df3 37 // Gets the position of the beam
RexRoshan 0:d9cf94b41df3 38 Vector2D b = {_a,_b};
RexRoshan 0:d9cf94b41df3 39 return b;
RexRoshan 0:d9cf94b41df3 40 }
RexRoshan 0:d9cf94b41df3 41
RexRoshan 0:d9cf94b41df3 42 void Beam::set_pos(Vector2D p)
RexRoshan 0:d9cf94b41df3 43 {
RexRoshan 0:d9cf94b41df3 44 // Sets the position of the beam
RexRoshan 0:d9cf94b41df3 45 _a = p.x ;
RexRoshan 0:d9cf94b41df3 46 _b = p.y ;
RexRoshan 0:d9cf94b41df3 47 }