class for obstacles in Car_race game

Committer:
fy14aaz
Date:
Mon Mar 13 16:08:28 2017 +0000
Revision:
0:f8968ec0ec1b
Child:
1:a735e7396af4
created random obstacles

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fy14aaz 0:f8968ec0ec1b 1 #include "Obstacles.h"
fy14aaz 0:f8968ec0ec1b 2
fy14aaz 0:f8968ec0ec1b 3 Obstacles::Obstacles()
fy14aaz 0:f8968ec0ec1b 4 {
fy14aaz 0:f8968ec0ec1b 5
fy14aaz 0:f8968ec0ec1b 6 }
fy14aaz 0:f8968ec0ec1b 7
fy14aaz 0:f8968ec0ec1b 8 Obstacles::~Obstacles()
fy14aaz 0:f8968ec0ec1b 9 {
fy14aaz 0:f8968ec0ec1b 10
fy14aaz 0:f8968ec0ec1b 11 }
fy14aaz 0:f8968ec0ec1b 12
fy14aaz 0:f8968ec0ec1b 13 void Obstacles::init(int seed)
fy14aaz 0:f8968ec0ec1b 14 {
fy14aaz 0:f8968ec0ec1b 15 _Obstacle_x = seed;
fy14aaz 0:f8968ec0ec1b 16 // try to draw them here in this function as we need the draw function for another purpose
fy14aaz 0:f8968ec0ec1b 17 // are we done though? we might need to split the draw function into two, one for drawing the car
fy14aaz 0:f8968ec0ec1b 18 // and the other for drawing the obstacles as they are drawn in a time basis
fy14aaz 0:f8968ec0ec1b 19 }
fy14aaz 0:f8968ec0ec1b 20
fy14aaz 0:f8968ec0ec1b 21 void Obstacles::draw(N5110 &lcd)
fy14aaz 0:f8968ec0ec1b 22 {
fy14aaz 0:f8968ec0ec1b 23 switch(_Obstacle_x){
fy14aaz 0:f8968ec0ec1b 24
fy14aaz 0:f8968ec0ec1b 25 case 0:
fy14aaz 0:f8968ec0ec1b 26 lcd.drawRect(2,2,24,2,1);
fy14aaz 0:f8968ec0ec1b 27 break;
fy14aaz 0:f8968ec0ec1b 28
fy14aaz 0:f8968ec0ec1b 29 case 1:
fy14aaz 0:f8968ec0ec1b 30 lcd.drawRect(30,2,24,2,1);
fy14aaz 0:f8968ec0ec1b 31 break;
fy14aaz 0:f8968ec0ec1b 32
fy14aaz 0:f8968ec0ec1b 33 case 2:
fy14aaz 0:f8968ec0ec1b 34 lcd.drawRect(58,2,24,2,1);
fy14aaz 0:f8968ec0ec1b 35 break;
fy14aaz 0:f8968ec0ec1b 36 }
fy14aaz 0:f8968ec0ec1b 37 }
fy14aaz 0:f8968ec0ec1b 38
fy14aaz 0:f8968ec0ec1b 39 void Obstacles::update(int seed) // adjust this function to be able to store all pixels values
fy14aaz 0:f8968ec0ec1b 40 { // then they are used to shift th screen
fy14aaz 0:f8968ec0ec1b 41 _Obstacle_x = seed;
fy14aaz 0:f8968ec0ec1b 42 }