Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: N5110 mbed PowerControl
Diff: GameScreen.cpp
- Revision:
- 11:c6c88617f7e7
- Parent:
- 10:d8ef8633bd98
- Child:
- 12:9ba4b21f8220
--- a/GameScreen.cpp Mon Apr 27 21:10:23 2015 +0000
+++ b/GameScreen.cpp Mon Apr 27 23:49:19 2015 +0000
@@ -134,11 +134,11 @@
{
for (int n = 0; n < numPlatforms_ ; n++)
{
- if (allPlatforms[n]->y > (platThickness_))
+ if (allPlatforms[n]->y > (platThickness_+6))
allPlatforms[n]->y = allPlatforms[n]->y - 1;
else
{
- allPlatforms[n]->y = maxY_ - platThickness_ + 1; //send back to bottom.
+ allPlatforms[n]->y = maxY_ - platThickness_ + 1+6; //send back to bottom.
allPlatforms[n]->x = rand() % (maxX_-platGapSize_ + 1) - 1; //select a new random position of gap!
}
@@ -170,29 +170,48 @@
// for example the number 4 font5x7 = 0x18,0x14,0x12,0x7F,0x10
// font7x5 = 0x02,0x06,0x10,0x12,0x1E,0x2,0x2
//then it is printed!
-void GameScreen::printString(const char * str,int x,int y)
+void GameScreen::printString(const char * str,int x,int y,bool invert)
{
+ if (invert){
+ for (int a = 0; a < 48; a ++)
+ {
+ for (int b = y; b < (y+9); b++)
+ {
+ setPixel(b,a);
+ }
+ }
+ }
+
while (*str)
{
+
//each byte in row
for (int i = 0; i < 5; i++)
{
//each bit in byte
for (int b = 0; b < 7; b++)
- {
+ {
+ if (invert)
+ setPixel(y+b+1,x-i+1);
+
if (font5x7[(*str - 32)*5 + i] & (1<<b)) //bitwise comparison to mask at desired pixel
{
- setPixel(y+b+1,x-i+1);
+ setPixel(y+b+1,x-i+1);
+ if (invert)
+ clearPixel(y+b+1,x-i+1);
}
else
{
- clearPixel(y+b+1,x-i+1);
+ if (!invert)
+ clearPixel(y+b+1,x-i+1);
}
}
}
str ++;
x -= 6;
}
+
+
refresh();
}
@@ -250,4 +269,19 @@
countdown.stop();
}
+void GameScreen::displayEndScreen(int lvl,int *cursor)
+{
+ clear();
+ char buffer [10];
+ sprintf(buffer,"lvl: %d",lvl);
+ printString("GameOver",maxX_ - 2,-1);
+ printString(" :( ",maxX_ - 2,7);
+ printString(buffer,maxX_ - 2,23);
+ printString("Reached!",maxX_ - 2,32);
+ printString("Record",maxX_ - 8,55,cursor[0]);
+ printString("View",maxX_ - 15,63,cursor[1]);
+ printString("Quit",maxX_ - 15,71,cursor[2]);
+ refresh();
+}
+