diff options
Diffstat (limited to 'demos/games/justget10/jg10.c')
-rw-r--r-- | demos/games/justget10/jg10.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/demos/games/justget10/jg10.c b/demos/games/justget10/jg10.c index f9974fe1..7d5f8a46 100644 --- a/demos/games/justget10/jg10.c +++ b/demos/games/justget10/jg10.c @@ -17,12 +17,12 @@ GHandle jg10SelectionWidgetGCreate(GDisplay* g, jg10WidgetObject* wo, GWidgetIni typedef struct { // Node properties uint8_t num; // Node number - bool_t check; // Node needs to be checked or not - bool_t sel; // Node selected or not + gBool check; // Node needs to be checked or not + gBool sel; // Node selected or not } nodeProps; nodeProps jg10Field[JG10_FIELD_WIDTH][JG10_FIELD_HEIGHT]; // jg10 field array -bool_t jg10GameOver = FALSE; +gBool jg10GameOver = gFalse; const char *jg10Graph[] = {"background.bmp", "1.bmp","2.bmp","3.bmp","4.bmp","5.bmp","6.bmp","7.bmp","8.bmp", "9.bmp", "10.bmp", "11.bmp", "12.bmp", "13.bmp", "14.bmp", "15.bmp", "16.bmp", "17.bmp", "18.bmp", "19.bmp", "20.bmp"}; // 21 elements (0-20) gdispImage jg10Image[JG10_MAX_COUNT]; #define JG10_ANIM_IMAGES 5 @@ -33,7 +33,7 @@ uint8_t jg10MaxVal=4; // Max v font_t font; #if JG10_SHOW_SPLASH GTimer jg10SplashBlink; -bool_t jg10SplashTxtVisible = FALSE; +gBool jg10SplashTxtVisible = gFalse; gdispImage jg10SplashImage; #endif @@ -86,16 +86,16 @@ static int uitoa(unsigned int value, char * buf, int max) { return n; } -static bool_t inRange(int16_t x, int16_t y) { - if ((x >= 0) && (x < JG10_FIELD_WIDTH) && (y >= 0) && (y < JG10_FIELD_HEIGHT)) return TRUE; else return FALSE; +static gBool inRange(int16_t x, int16_t y) { + if ((x >= 0) && (x < JG10_FIELD_WIDTH) && (y >= 0) && (y < JG10_FIELD_HEIGHT)) return gTrue; else return gFalse; } static void clean_SelCheck(void) { uint16_t i ,j; for (i = 0; i < JG10_FIELD_WIDTH; i++) { for (j = 0; j < JG10_FIELD_HEIGHT; j++) { - jg10Field[i][j].check = FALSE; - jg10Field[i][j].sel = FALSE; + jg10Field[i][j].check = gFalse; + jg10Field[i][j].sel = gFalse; } } } @@ -121,7 +121,7 @@ static void remove_Selected(void) { for (i = 0; i < JG10_FIELD_WIDTH; i++) { for (j = 0; j < JG10_FIELD_HEIGHT; j++) { if (jg10Field[i][j].sel) { - jg10Field[i][j].sel = FALSE; + jg10Field[i][j].sel = gFalse; jg10Field[i][j].num = 0; } } @@ -148,9 +148,9 @@ static uint8_t jg10_randomer(uint8_t max, uint8_t th) { static void movePiecesDown(void) { uint8_t tmp = 0; - bool_t needToCheck = TRUE; + gBool needToCheck = gTrue; while (needToCheck) { - needToCheck = FALSE; + needToCheck = gFalse; for (int8_t y = (JG10_FIELD_HEIGHT-1); y >= 0; y--) { for (uint8_t x = 0; x < JG10_FIELD_WIDTH; x++) { if (jg10Field[x][y].num == 0) { @@ -164,7 +164,7 @@ static void movePiecesDown(void) { jg10Field[x][tmpy].num = jg10Field[x][tmpy-1].num; } jg10Field[x][0].num = 0; - needToCheck = TRUE; + needToCheck = gTrue; } } } @@ -172,9 +172,9 @@ static void movePiecesDown(void) { } gwinRedraw(mainWin); // Add new pieces - needToCheck = TRUE; + needToCheck = gTrue; while (needToCheck) { - needToCheck = FALSE; + needToCheck = gFalse; for (int8_t y = (JG10_FIELD_HEIGHT-1); y >= 0; y--) { for (uint8_t x = 0; x < JG10_FIELD_WIDTH; x++) { if (jg10Field[x][y].num == 0) { @@ -182,7 +182,7 @@ static void movePiecesDown(void) { jg10Field[x][tmpy].num = jg10Field[x][tmpy-1].num; } jg10Field[x][0].num = jg10_randomer(jg10MaxVal, 3); - needToCheck = TRUE; + needToCheck = gTrue; } } } @@ -191,8 +191,8 @@ static void movePiecesDown(void) { } } -static bool_t checkForPossibleMove(void) { - bool_t canMove = FALSE; +static gBool checkForPossibleMove(void) { + gBool canMove = gFalse; uint16_t i ,j; for (i = 0; i < JG10_FIELD_WIDTH; i++) { for (j = 0; j < JG10_FIELD_HEIGHT; j++) { @@ -200,7 +200,7 @@ static bool_t checkForPossibleMove(void) { (inRange(i-1,j) && jg10Field[i-1][j].num == jg10Field[i][j].num) || (inRange(i,j+1) && jg10Field[i][j+1].num == jg10Field[i][j].num) || (inRange(i+1,j) && jg10Field[i+1][j].num == jg10Field[i][j].num)) { - canMove = TRUE; + canMove = gTrue; return canMove; } } @@ -242,10 +242,10 @@ static DECLARE_THREAD_FUNCTION(thdJg10, msg) { (inRange(x-1,y) && jg10Field[x-1][y].num == jg10Field[x][y].num) || (inRange(x,y+1) && jg10Field[x][y+1].num == jg10Field[x][y].num) || (inRange(x+1,y) && jg10Field[x+1][y].num == jg10Field[x][y].num)) { - gwinSetVisible(Jg10SelectWidget, FALSE); + gwinSetVisible(Jg10SelectWidget, gFalse); clean_SelCheck(); - jg10Field[x][y].check = TRUE; - gwinSetVisible(Jg10SelectWidget, TRUE); + jg10Field[x][y].check = gTrue; + gwinSetVisible(Jg10SelectWidget, gTrue); } } else { // already selected section clicked... @@ -254,19 +254,19 @@ static DECLARE_THREAD_FUNCTION(thdJg10, msg) { jg10MaxVal = jg10Field[x][y].num; if (jg10MaxVal >= 10) printCongrats(); if (jg10MaxVal == 20) { // Just in case someone got so far :D I cannot imaginge though - jg10GameOver = TRUE; + jg10GameOver = gTrue; printGameOver(); } } - jg10Field[x][y].sel = FALSE; - gwinSetVisible(Jg10SelectWidget, FALSE); + jg10Field[x][y].sel = gFalse; + gwinSetVisible(Jg10SelectWidget, gFalse); remove_Selected(); movePiecesDown(); if (checkForPossibleMove()) { clean_SelCheck(); //gwinRedraw(mainWin); } else { - jg10GameOver = TRUE; + jg10GameOver = gTrue; printGameOver(); } } @@ -284,11 +284,11 @@ static void initField(void) { //jg10Field[x][y].num = 1; // good for animation testing //jg10Field[x][y].num = x+x+5; // good to get high score fast //jg10Field[x][y].num = x+y+5; // good demo to check out pieces :D - jg10Field[x][y].check = FALSE; - jg10Field[x][y].sel = FALSE; + jg10Field[x][y].check = gFalse; + jg10Field[x][y].sel = gFalse; } } - jg10GameOver = FALSE; + jg10GameOver = gFalse; printGameOver(); } @@ -304,21 +304,21 @@ static void mainWinDraw(GWidgetObject* gw, void* param) { static void jg10SelectionWidget_Draw(GWidgetObject* gw, void* param) { int16_t x, y; - bool_t needToCheck = TRUE; + gBool needToCheck = gTrue; (void)param; while (needToCheck) { - needToCheck = FALSE; + needToCheck = gFalse; for (x = 0; x < JG10_FIELD_WIDTH; x++) { for (y = 0; y < JG10_FIELD_HEIGHT; y++) { if (jg10Field[x][y].check && !jg10Field[x][y].sel) { - jg10Field[x][y].sel = TRUE; - jg10Field[x][y].check = FALSE; + jg10Field[x][y].sel = gTrue; + jg10Field[x][y].check = gFalse; // Up if (inRange(x, y-1) && !jg10Field[x][y-1].sel && (jg10Field[x][y-1].num == jg10Field[x][y].num)) { - jg10Field[x][y-1].check = TRUE; - needToCheck = TRUE; + jg10Field[x][y-1].check = gTrue; + needToCheck = gTrue; } else if (!inRange(x, y-1) || (inRange(x, y-1) && !jg10Field[x][y-1].sel)) { // We need longer line if this is wide corner inside shape if (inRange(x+1, y) && inRange(x+1, y-1) && (jg10Field[x][y].num == jg10Field[x+1][y].num) && (jg10Field[x][y].num == jg10Field[x+1][y-1].num)) { @@ -329,8 +329,8 @@ static void jg10SelectionWidget_Draw(GWidgetObject* gw, void* param) { } // Down if (inRange(x, y+1) && !jg10Field[x][y+1].sel && (jg10Field[x][y+1].num == jg10Field[x][y].num)) { - jg10Field[x][y+1].check = TRUE; - needToCheck = TRUE; + jg10Field[x][y+1].check = gTrue; + needToCheck = gTrue; } else if (!inRange(x, y+1) || (inRange(x, y+1) && !jg10Field[x][y+1].sel)) { // We need longer line if this is wide corner inside shape if (inRange(x-1, y) && inRange(x-1, y+1) && (jg10Field[x][y].num == jg10Field[x-1][y].num) && (jg10Field[x][y].num == jg10Field[x-1][y+1].num)) { @@ -341,8 +341,8 @@ static void jg10SelectionWidget_Draw(GWidgetObject* gw, void* param) { } // Left if (inRange(x-1, y) && !jg10Field[x-1][y].sel && (jg10Field[x-1][y].num == jg10Field[x][y].num)) { - jg10Field[x-1][y].check = TRUE; - needToCheck = TRUE; + jg10Field[x-1][y].check = gTrue; + needToCheck = gTrue; } else if (!inRange(x-1, y) || (inRange(x-1, y) && !jg10Field[x-1][y].sel)) { // We need longer line if this is wide corner inside shape if (inRange(x, y-1) && inRange(x-1, y-1) && (jg10Field[x][y].num == jg10Field[x][y-1].num) && (jg10Field[x][y].num == jg10Field[x-1][y-1].num)) { @@ -353,8 +353,8 @@ static void jg10SelectionWidget_Draw(GWidgetObject* gw, void* param) { } // Right if (inRange(x+1, y) && !jg10Field[x+1][y].sel && (jg10Field[x+1][y].num == jg10Field[x][y].num)) { - jg10Field[x+1][y].check = TRUE; - needToCheck = TRUE; + jg10Field[x+1][y].check = gTrue; + needToCheck = gTrue; } else if (!inRange(x+1, y) || (inRange(x+1, y) && !jg10Field[x+1][y].sel)) { // We need longer line if this is wide corner inside shape if (inRange(x, y+1) && inRange(x+1, y+1) && (jg10Field[x][y].num == jg10Field[x][y+1].num) && (jg10Field[x][y].num == jg10Field[x+1][y+1].num)) { @@ -422,7 +422,7 @@ static void createMainWin(void) { GWidgetInit wi; gwinWidgetClearInit(&wi); // Container - mainWin - wi.g.show = FALSE; + wi.g.show = gFalse; wi.g.x = 0; wi.g.y = 0; wi.g.width = gdispGetWidth(); @@ -435,7 +435,7 @@ static void createMainWin(void) { mainWin = gwinContainerCreate(0, &wi, 0); // create selection widget - wi.g.show = FALSE; + wi.g.show = gFalse; wi.g.x = 0; wi.g.y = 0; wi.g.width = 272; @@ -496,6 +496,6 @@ void jg10ShowSplash(void) { gdispImageOpenFile(&jg10SplashImage, "splash.bmp"); gdispImageDraw(&jg10SplashImage, (gdispGetWidth()/2)-150, (gdispGetHeight()/2)-100, 300, 200, 0, 0); gdispImageClose(&jg10SplashImage); - gtimerStart(&jg10SplashBlink, jg10SplashBlinker, 0, TRUE, 400); + gtimerStart(&jg10SplashBlink, jg10SplashBlinker, 0, gTrue, 400); } #endif
\ No newline at end of file |