Prints objects on to a Nokia N5110 LCD display and makes them 'fall' down the display.
Dependents: Game_Controller_Project
Objects.cpp
- Committer:
- Nathanj94
- Date:
- 2017-03-23
- Revision:
- 3:0c79211fdfe0
- Parent:
- 2:3f42da6a4c89
- Child:
- 4:56ca80919a98
File content as of revision 3:0c79211fdfe0:
#include "Objects.h" Objects::Objects() { } Objects::~Objects() { } void Objects::init(int speed) { objects_speed = speed; y_ref = 8; srand(time(NULL)); objects_ep = rand() % 7; if(objects_ep == 0) { x_ref = 3; } else if (objects_ep == 1) { x_ref = 15; } else if (objects_ep == 2) { x_ref = 27; } else if (objects_ep == 3) { x_ref = 39; } else if (objects_ep == 4) { x_ref = 51; } else if (objects_ep == 5) { x_ref = 63; } else { x_ref = 75; } } void Objects::draw(N5110 &lcd) { lcd.drawLine(x_ref + 1, y_ref, x_ref + 4, y_ref, 1); lcd.drawLine(x_ref, y_ref + 1, x_ref, y_ref + 4, 1); lcd.drawLine(x_ref + 1, y_ref + 5, x_ref +4, y_ref + 5, 1); lcd.drawLine(x_ref + 5, y_ref + 1, x_ref + 5, y_ref + 4, 1); } void Objects::undraw(N5110 &lcd) { lcd.drawLine(x_ref + 1, y_ref, x_ref + 4, y_ref, 0); lcd.drawLine(x_ref, y_ref + 1, x_ref, y_ref + 4, 0); lcd.drawLine(x_ref + 1, y_ref + 5, x_ref +4, y_ref + 5, 0); lcd.drawLine(x_ref + 5, y_ref + 1, x_ref + 5, y_ref + 4, 0); } void Objects::move() { y_ref += objects_speed; } int Objects::get_x() { return x_ref; } int Objects::get_y() { return y_ref; }