James Heavey / Mbed 2 deprecated 2665-Breakout-Game

Dependencies:   mbed

Committer:
jamesheavey
Date:
Tue Jan 05 01:14:11 2021 +0000
Revision:
0:92b180c8d407
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jamesheavey 0:92b180c8d407 1 #include "Life_Powerup.h"
jamesheavey 0:92b180c8d407 2
jamesheavey 0:92b180c8d407 3 Life_Powerup::Life_Powerup()
jamesheavey 0:92b180c8d407 4 {
jamesheavey 0:92b180c8d407 5
jamesheavey 0:92b180c8d407 6 }
jamesheavey 0:92b180c8d407 7
jamesheavey 0:92b180c8d407 8 Life_Powerup::~Life_Powerup()
jamesheavey 0:92b180c8d407 9 {
jamesheavey 0:92b180c8d407 10
jamesheavey 0:92b180c8d407 11 }
jamesheavey 0:92b180c8d407 12
jamesheavey 0:92b180c8d407 13 void Life_Powerup::init() // initialises the Life_Powerup off screen
jamesheavey 0:92b180c8d407 14 {
jamesheavey 0:92b180c8d407 15 _x = -10;
jamesheavey 0:92b180c8d407 16 _y = 0;
jamesheavey 0:92b180c8d407 17 _speed_y = 1; // -2 speed in the y direction, doesnt change even off screen
jamesheavey 0:92b180c8d407 18 }
jamesheavey 0:92b180c8d407 19
jamesheavey 0:92b180c8d407 20
jamesheavey 0:92b180c8d407 21 void Life_Powerup::draw(N5110 &lcd)
jamesheavey 0:92b180c8d407 22 {
jamesheavey 0:92b180c8d407 23 if (_x >= 0) { // only draw if on screen (more efficient?)
jamesheavey 0:92b180c8d407 24 Bitmap powerup(powerup_data, 9, 9); // assign the powerup sprite data
jamesheavey 0:92b180c8d407 25 powerup.render(lcd,_x,_y);
jamesheavey 0:92b180c8d407 26 }
jamesheavey 0:92b180c8d407 27 }
jamesheavey 0:92b180c8d407 28
jamesheavey 0:92b180c8d407 29
jamesheavey 0:92b180c8d407 30 void Life_Powerup::update() // updates the Life_Powerup's y coordinate according to its speed
jamesheavey 0:92b180c8d407 31 {
jamesheavey 0:92b180c8d407 32 _y += _speed_y;
jamesheavey 0:92b180c8d407 33 }
jamesheavey 0:92b180c8d407 34
jamesheavey 0:92b180c8d407 35
jamesheavey 0:92b180c8d407 36 int Life_Powerup::get_x() // retrieves the Life_Powerups's x coordinate
jamesheavey 0:92b180c8d407 37 {
jamesheavey 0:92b180c8d407 38 return _x;
jamesheavey 0:92b180c8d407 39 }
jamesheavey 0:92b180c8d407 40
jamesheavey 0:92b180c8d407 41
jamesheavey 0:92b180c8d407 42 int Life_Powerup::get_y() // retrieves the Life_Powerups's y coordinate
jamesheavey 0:92b180c8d407 43 {
jamesheavey 0:92b180c8d407 44 return _y;
jamesheavey 0:92b180c8d407 45 }
jamesheavey 0:92b180c8d407 46
jamesheavey 0:92b180c8d407 47
jamesheavey 0:92b180c8d407 48 void Life_Powerup::set_posx(int x) // sets the Life_Powerup's x coordinate
jamesheavey 0:92b180c8d407 49 {
jamesheavey 0:92b180c8d407 50 _x = x;
jamesheavey 0:92b180c8d407 51 }
jamesheavey 0:92b180c8d407 52
jamesheavey 0:92b180c8d407 53
jamesheavey 0:92b180c8d407 54 void Life_Powerup::set_posy(int y) // sets the Life_Powerups's y coordinate
jamesheavey 0:92b180c8d407 55 {
jamesheavey 0:92b180c8d407 56 _y = y;
jamesheavey 0:92b180c8d407 57 }