class for obstacles in Car_race game
Diff: Obstacles.cpp
- Revision:
- 1:a735e7396af4
- Parent:
- 0:f8968ec0ec1b
- Child:
- 2:4430d4fd91c2
diff -r f8968ec0ec1b -r a735e7396af4 Obstacles.cpp --- a/Obstacles.cpp Mon Mar 13 16:08:28 2017 +0000 +++ b/Obstacles.cpp Tue Mar 14 10:13:40 2017 +0000 @@ -18,8 +18,9 @@ // and the other for drawing the obstacles as they are drawn in a time basis } -void Obstacles::draw(N5110 &lcd) +void Obstacles::draw(N5110 &lcd,int seed) { + _Obstacle_x = seed; switch(_Obstacle_x){ case 0: @@ -36,7 +37,26 @@ } } -void Obstacles::update(int seed) // adjust this function to be able to store all pixels values +void Obstacles::update(N5110 &lcd) // adjust this function to be able to store all pixels values { // then they are used to shift th screen - _Obstacle_x = seed; + // _Obstacle_x = seed; + char pixelstate[82][46]; + for (int i=0; i<82; i+=1) { + for (int j=0; j<46; j+=1) { + if (lcd.getPixel(i,j)) { + pixelstate[i][j]=1; + } + else { + pixelstate[i][j]=0; + } + } + } + for (int i=0; i<82; i+=1) { + for (int j=0; j<46; j+=1) { + if (pixelstate[i][j]) { + lcd.clearPixel(i,j); + lcd.setPixel(i,j+1); + } + } + } } \ No newline at end of file