The game is finished

Dependencies:   mbed Gamepad N5110 mbed-rtos

Committer:
RexRoshan
Date:
Thu May 09 14:23:35 2019 +0000
Revision:
14:c7302ffe6eab
Parent:
5:016a7315b75d
Final Modification

Who changed what in which revision?

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