From e4cb9a7af881e5a8e877e09a84e1a78516d59e2c Mon Sep 17 00:00:00 2001 From: Jon Thysell Date: Thu, 16 Dec 2021 12:57:00 -0800 Subject: [PATCH] Added sound menu item and other optimizations * Added sound menu which keeps in sync with pressing sound button * Changed navigation behavior between scenes to go straight to next level if it hasn't been beaten, otherwise return to level select so the player can view their progress in the set * More drawing optimizations --- src/GameEndScene.c | 32 +++++++++------- src/GameEngine.c | 31 ++++++---------- src/GameEngine.h | 14 +++++-- src/GameWindow.c | 8 ++++ src/GameWindow.h | 6 +++ src/LevelEndScene.c | 69 +++++++++++++++++++++++++---------- src/LevelSelectScene.c | 4 ++ src/Levels.c | 1 - src/MacLO.c | 81 ++++++++++++++++++++++++++++++----------- src/MacLO.h | 5 +++ src/MacLO.pi.bin | Bin 20224 -> 20224 bytes src/MacLO.pi.rsrc.bin | Bin 36096 -> 36096 bytes src/PlayScene.c | 6 ++- src/Sounds.c | 6 +-- src/TitleScene.c | 49 ++++++++++++++++++++----- 15 files changed, 220 insertions(+), 92 deletions(-) diff --git a/src/GameEndScene.c b/src/GameEndScene.c index e729f66..49d3188 100644 --- a/src/GameEndScene.c +++ b/src/GameEndScene.c @@ -46,23 +46,29 @@ void GameEndScene_Init(GameWindow *pGameWindow) void GameEndScene_Draw(const GameWindow *pGameWindow, bool fullRefresh) { // Draw set - MoveTo(pGameWindow->GameEndScene.SetRect.left, pGameWindow->GameEndScene.SetRect.top); - DrawScaledPic(pGameWindow->Bitmaps.StarPicts[StarPictCount - 1], SetTextScale); - if (pGameWindow->Engine.SetB) + if (fullRefresh) { - Bitmaps_DrawBChar(&(pGameWindow->Bitmaps), SetTextScale); + MoveTo(pGameWindow->GameEndScene.SetRect.left, pGameWindow->GameEndScene.SetRect.top); + DrawScaledPic(pGameWindow->Bitmaps.StarPicts[StarPictCount - 1], SetTextScale); + if (pGameWindow->Engine.SetB) + { + Bitmaps_DrawBChar(&(pGameWindow->Bitmaps), SetTextScale); + } + else + { + Bitmaps_DrawAChar(&(pGameWindow->Bitmaps), SetTextScale); + } + DrawScaledPic(pGameWindow->Bitmaps.StarPicts[StarPictCount - 1], SetTextScale); } - else - { - Bitmaps_DrawAChar(&(pGameWindow->Bitmaps), SetTextScale); - } - DrawScaledPic(pGameWindow->Bitmaps.StarPicts[StarPictCount - 1], SetTextScale); // Draw score - MoveTo(pGameWindow->GameEndScene.ScoreRect.left, pGameWindow->GameEndScene.ScoreRect.top); - Bitmaps_DrawNumber(&(pGameWindow->Bitmaps), GameEngine_GetTotalScore(&(pGameWindow->Engine)), ScoreTextScale); - Bitmaps_DrawSlashChar(&(pGameWindow->Bitmaps), ScoreTextScale); - Bitmaps_DrawNumber(&(pGameWindow->Bitmaps), PerfectScore, ScoreTextScale); + if (fullRefresh) + { + MoveTo(pGameWindow->GameEndScene.ScoreRect.left, pGameWindow->GameEndScene.ScoreRect.top); + Bitmaps_DrawNumber(&(pGameWindow->Bitmaps), GameEngine_GetTotalScore(&(pGameWindow->Engine)), ScoreTextScale); + Bitmaps_DrawSlashChar(&(pGameWindow->Bitmaps), ScoreTextScale); + Bitmaps_DrawNumber(&(pGameWindow->Bitmaps), PerfectScore, ScoreTextScale); + } } void GameEndScene_Click(GameWindow *pGameWindow, const Point *pPosition) diff --git a/src/GameEngine.c b/src/GameEngine.c index 67a69c3..2f61333 100644 --- a/src/GameEngine.c +++ b/src/GameEngine.c @@ -7,8 +7,8 @@ * This file provides implementations for GameEngine.h. */ -#include "Common.h" #include "GameEngine.h" +#include "Common.h" const int8_t PuzzleSize = 5; @@ -62,22 +62,8 @@ void GameEngine_Init(GameEngine *pGameEngine) void GameEngine_NewGame(GameEngine *pGameEngine, const bool setB) { - int8_t level, startLevel; - pGameEngine->SetB = setB; - - startLevel = 0; - for (level = 0; level < LevelCount; level++) - { - // Find the first uncompleted level - if (GameEngine_GetScore(pGameEngine, level) == 0) - { - startLevel = level; - break; - } - } - - GameEngine_StartLevel(pGameEngine, startLevel); + GameEngine_StartLevel(pGameEngine, 0); } void GameEngine_ResetGame(GameEngine *pGameEngine) @@ -115,7 +101,7 @@ void GameEngine_NextLevel(GameEngine *pGameEngine) { if (GameEngine_IsCompleted(pGameEngine)) { - GameEngine_StartLevel(pGameEngine, pGameEngine->Level + 1); + GameEngine_StartLevel(pGameEngine, (pGameEngine->Level + 1) % LevelCount); } } @@ -146,7 +132,7 @@ bool GameEngine_GetLight(const GameEngine *pGameEngine, const int8_t x, const in bool GameEngine_IsEnabled(const GameEngine *pGameEngine, const int8_t level) { - return level == 0 || (level < LevelCount && GameEngine_GetScore(pGameEngine, level - 1) > 0); + return level == 0 || (level < LevelCount && GameEngine_HasPlayedLevel(pGameEngine, level - 1)); } bool GameEngine_IsCompleted(const GameEngine *pGameEngine) @@ -154,9 +140,14 @@ bool GameEngine_IsCompleted(const GameEngine *pGameEngine) return pGameEngine->Lights == 0; } -bool GameEngine_IsGameOver(const GameEngine *pGameEngine) +bool GameEngine_IsLastLevel(const GameEngine *pGameEngine) { - return pGameEngine->Level >= LevelCount; + return pGameEngine->Level == LevelCount - 1; +} + +bool GameEngine_HasPlayedLevel(const GameEngine *pGameEngine, const int8_t level) +{ + return GameEngine_GetScore(pGameEngine, level) > 0; } uint8_t GameEngine_GetHalfStars(const GameEngine *pGameEngine) diff --git a/src/GameEngine.h b/src/GameEngine.h index 2fc10ca..7a7676d 100644 --- a/src/GameEngine.h +++ b/src/GameEngine.h @@ -110,11 +110,19 @@ bool GameEngine_IsCompleted(const GameEngine *pGameEngine); bool GameEngine_IsEnabled(const GameEngine *pGameEngine, const int8_t level); /** - * Gets whether or not the last level has just been completed. + * Gets whether the current level is the last of a set. * @param pGameEngine The GameEngine. - * @return Whether or not the game is over. + * @return Whether the current level is the last of a set. */ -bool GameEngine_IsGameOver(const GameEngine *pGameEngine); +bool GameEngine_IsLastLevel(const GameEngine *pGameEngine); + +/** + * Gets whether the given level has been completed before. + * @param pGameEngine The GameEngine. + * @param level The level. + * @return Whether the given level has been completed before. + */ +bool GameEngine_HasPlayedLevel(const GameEngine *pGameEngine, const int8_t level); /** * Gets the number of half-stars the user stands to earn given the current diff --git a/src/GameWindow.c b/src/GameWindow.c index 3a89e94..58cd53a 100644 --- a/src/GameWindow.c +++ b/src/GameWindow.c @@ -8,6 +8,7 @@ */ #include "GameWindow.h" +#include "MacLO.h" #include "TitleScene.h" #include "LevelSelectScene.h" #include "PlayScene.h" @@ -145,6 +146,13 @@ void GameWindow_Show(const GameWindow *pGameWindow) ShowWindow(pGameWindow->Window); } +void GameWindow_ToggleSound(GameWindow *pGameWindow) +{ + pGameWindow->Sounds.Enabled = !pGameWindow->Sounds.Enabled; + MacLO_UpdateMenus(); + GameWindow_Draw(pGameWindow, false); +} + void GameWindow_ClearScores(GameWindow *pGameWindow) { if (ShowConfirm("\pAre you sure you want to clear all scores?")) diff --git a/src/GameWindow.h b/src/GameWindow.h index 14d6376..981cad3 100644 --- a/src/GameWindow.h +++ b/src/GameWindow.h @@ -75,6 +75,12 @@ void GameWindow_SetScene(GameWindow *pGameWindow, const SceneId sceneId); */ void GameWindow_Show(const GameWindow *pGameWindow); +/** + * Toggles whether sound is enabled/disabled for the GameWindow. + * @param pGameWindow The GameWindow. + */ +void GameWindow_ToggleSound(GameWindow *pGameWindow); + /** * Resets the level scores of the GameWindow. * @param pGameWindow The GameWindow. diff --git a/src/LevelEndScene.c b/src/LevelEndScene.c index a17aca0..73ffbf2 100644 --- a/src/LevelEndScene.c +++ b/src/LevelEndScene.c @@ -64,54 +64,83 @@ void LevelEndScene_Init(GameWindow *pGameWindow) void LevelEndScene_Draw(const GameWindow *pGameWindow, bool fullRefresh) { // Draw level - MoveTo(pGameWindow->LevelEndScene.LevelRect.left, pGameWindow->LevelEndScene.LevelRect.top); - if (pGameWindow->Engine.SetB) + if (fullRefresh) { - Bitmaps_DrawBChar(&(pGameWindow->Bitmaps), LevelTextScale); + MoveTo(pGameWindow->LevelEndScene.LevelRect.left, pGameWindow->LevelEndScene.LevelRect.top); + if (pGameWindow->Engine.SetB) + { + Bitmaps_DrawBChar(&(pGameWindow->Bitmaps), LevelTextScale); + } + else + { + Bitmaps_DrawAChar(&(pGameWindow->Bitmaps), LevelTextScale); + } + Bitmaps_DrawNumber(&(pGameWindow->Bitmaps), 1 + pGameWindow->Engine.Level, LevelTextScale); } - else - { - Bitmaps_DrawAChar(&(pGameWindow->Bitmaps), LevelTextScale); - } - Bitmaps_DrawNumber(&(pGameWindow->Bitmaps), 1 + pGameWindow->Engine.Level, LevelTextScale); // Draw half-stars - MoveTo(pGameWindow->LevelEndScene.HalfStarsRect.left, pGameWindow->LevelEndScene.HalfStarsRect.top); - Bitmaps_DrawHalfStars(&(pGameWindow->Bitmaps), GameEngine_GetHalfStars(&(pGameWindow->Engine)), MaxStars, HalfStarScale); + if (fullRefresh) + { + MoveTo(pGameWindow->LevelEndScene.HalfStarsRect.left, pGameWindow->LevelEndScene.HalfStarsRect.top); + Bitmaps_DrawHalfStars(&(pGameWindow->Bitmaps), GameEngine_GetHalfStars(&(pGameWindow->Engine)), MaxStars, HalfStarScale); + } // Draw score - MoveTo(pGameWindow->LevelEndScene.ScoreRect.left, pGameWindow->LevelEndScene.ScoreRect.top); - Bitmaps_DrawNumber(&(pGameWindow->Bitmaps), GameEngine_GetTotalScore(&(pGameWindow->Engine)), ScoreTextScale); - Bitmaps_DrawSlashChar(&(pGameWindow->Bitmaps), ScoreTextScale); - Bitmaps_DrawNumber(&(pGameWindow->Bitmaps), PerfectScore, ScoreTextScale); + if (fullRefresh) + { + MoveTo(pGameWindow->LevelEndScene.ScoreRect.left, pGameWindow->LevelEndScene.ScoreRect.top); + Bitmaps_DrawNumber(&(pGameWindow->Bitmaps), GameEngine_GetTotalScore(&(pGameWindow->Engine)), ScoreTextScale); + Bitmaps_DrawSlashChar(&(pGameWindow->Bitmaps), ScoreTextScale); + Bitmaps_DrawNumber(&(pGameWindow->Bitmaps), PerfectScore, ScoreTextScale); + } // Draw retry button - DrawPicture(pGameWindow->Bitmaps.RetryButtonPict, &(pGameWindow->LevelEndScene.RetryButtonRect)); + if (fullRefresh) + { + DrawPicture(pGameWindow->Bitmaps.RetryButtonPict, &(pGameWindow->LevelEndScene.RetryButtonRect)); + + } // Draw next button - DrawPicture(pGameWindow->Bitmaps.NextButtonPict, &(pGameWindow->LevelEndScene.NextButtonRect)); + if (fullRefresh) + { + DrawPicture(pGameWindow->Bitmaps.NextButtonPict, &(pGameWindow->LevelEndScene.NextButtonRect)); + } } void LevelEndScene_Click(GameWindow *pGameWindow, const Point *pPosition) { if (PtInRect(*pPosition, &(pGameWindow->LevelEndScene.RetryButtonRect))) { + // Clicked on retry button GameEngine_ResetLevel(&(pGameWindow->Engine)); GameWindow_SetScene(pGameWindow, Play); Sounds_PlayRetrySnd(&(pGameWindow->Sounds)); } else if (PtInRect(*pPosition, &(pGameWindow->LevelEndScene.NextButtonRect))) { - GameEngine_NextLevel(&(pGameWindow->Engine)); - - if (GameEngine_IsGameOver(&(pGameWindow->Engine))) + // Clicked on next button + if (GameEngine_IsLastLevel(&(pGameWindow->Engine))) { + // Finished the last level, go to game end scene GameWindow_SetScene(pGameWindow, GameEnd); Sounds_PlayDoneSnd(&(pGameWindow->Sounds)); } else { - GameWindow_SetScene(pGameWindow, Play); + if (GameEngine_HasPlayedLevel(&(pGameWindow->Engine), pGameWindow->Engine.Level + 1)) + { + // Next level has been played before, assume they're + // replaying old levels and return to level select scene + GameWindow_SetScene(pGameWindow, LevelSelect); + } + else + { + // First time for next level, load and go to play scene + GameEngine_NextLevel(&(pGameWindow->Engine)); + GameWindow_SetScene(pGameWindow, Play); + Sounds_PlayRetrySnd(&(pGameWindow->Sounds)); + } } } } diff --git a/src/LevelSelectScene.c b/src/LevelSelectScene.c index 4a9c7f3..21a88fb 100644 --- a/src/LevelSelectScene.c +++ b/src/LevelSelectScene.c @@ -202,8 +202,10 @@ void LevelSelectScene_Click(GameWindow *pGameWindow, const Point *pPosition) if (PtInRect(*pPosition, &levelRect)) { + // Clicked on level button GameEngine_StartLevel(&(pGameWindow->Engine), level); GameWindow_SetScene(pGameWindow, Play); + Sounds_PlayRetrySnd(&(pGameWindow->Sounds)); break; } } @@ -211,6 +213,7 @@ void LevelSelectScene_Click(GameWindow *pGameWindow, const Point *pPosition) } else if (PtInRect(*pPosition, &(pGameWindow->LevelSelectScene.PrevButtonRect))) { + // Clicked on previous button, go to previous page or title scene if (pGameWindow->LevelSelectScene.PageNumber > 0) { pGameWindow->LevelSelectScene.PageNumber--; @@ -223,6 +226,7 @@ void LevelSelectScene_Click(GameWindow *pGameWindow, const Point *pPosition) } else if (PtInRect(*pPosition, &(pGameWindow->LevelSelectScene.NextButtonRect))) { + // Clicked on next button, go to next page if possible if ((pGameWindow->LevelSelectScene.PageNumber + 1) * LevelsPerPage < LevelCount) { pGameWindow->LevelSelectScene.PageNumber++; diff --git a/src/Levels.c b/src/Levels.c index 1659579..aeec6b4 100644 --- a/src/Levels.c +++ b/src/Levels.c @@ -7,7 +7,6 @@ * This file provides implementations for Levels.h. */ -#include "Common.h" #include "Levels.h" /** The levels from Set A, stored in 32-bit integers. */ diff --git a/src/MacLO.c b/src/MacLO.c index e5dc074..33d3f81 100644 --- a/src/MacLO.c +++ b/src/MacLO.c @@ -7,32 +7,35 @@ * This file provides implementations for MacLO.h. */ -#include "GameWindow.h" #include "MacLO.h" +#include "GameWindow.h" /** Resource ID for the apple menu. */ -#define AppleMenuResID BaseResID +#define AppleMenuResID BaseResID -/** Resource ID for the about menu item. */ -#define AboutMenuItemID 1 +/** ID for the about menu item. */ +#define AboutMenuItemID 1 /** Resource ID for the game menu. */ -#define GameMenuResID BaseResID+1 +#define GameMenuResID BaseResID+1 -/** Resource ID for the title menu id. */ -#define TitleMenuItemID 1 +/** ID for the title menu item. */ +#define GoToTitleMenuItemID 1 -/** Resource ID for the clear menu id. */ -#define ClearMenuItemID 2 +/** ID for the sound item. */ +#define SoundMenuItemID 2 -/** Resource ID for the quit menu id. */ -#define QuitMenuItemID 4 +/** ID for the clear menu item. */ +#define ClearMenuItemID 4 + +/** ID for the quit menu item. */ +#define QuitMenuItemID 6 /** Resource ID for the about dialog. */ -#define AboutDialogResID BaseResID +#define AboutDialogResID BaseResID /** Resource ID for the about dialog's ok button. */ -#define AboutDialogOKID 1 +#define AboutDialogOKID 1 /** GameWindow global instance. */ GameWindow gGameWindow; @@ -109,21 +112,39 @@ void MacLO_ToolBoxInit() void MacLO_AppInit() { Handle menuBar; - MenuHandle appleMenu; + MenuHandle appleMenu, gameMenu; // Add the menu bar menuBar = GetNewMBar(BaseResID); + if (menuBar == nil) + { + ShowError("\pMacLO MBAR resource missing!", true); + } + SetMenuBar(menuBar); // Populate the apple menu appleMenu = GetMHandle(AppleMenuResID); + if (appleMenu == nil) + { + ShowError("\pApple MENU resource missing!", true); + } + AddResMenu(appleMenu, 'DRVR'); - DrawMenuBar(); + gameMenu = GetMHandle(GameMenuResID); + if (gameMenu == nil) + { + ShowError("\pGame MENU resource missing!", true); + } // Setup the game window GameWindow_Init(&gGameWindow); + MacLO_UpdateMenus(); GameWindow_Show(&gGameWindow); + + // Update menus now that the game window is ready + MacLO_UpdateMenus(); } void MacLO_MainLoop() @@ -152,7 +173,17 @@ void MacLO_MainLoop() cmdChar = event.message & charCodeMask; if ((event.modifiers & cmdKey) != 0) { - MacLO_HandleMenuChoice(MenuKey(cmdChar)); + if (cmdChar == 'Q' || cmdChar == 'q') + { + // Always handle quit properly, don't rely + // on the quit menu existing or working properly + MacLO_Quit(); + } + else + { + // Try to invoke menu + MacLO_HandleMenuChoice(MenuKey(cmdChar)); + } } break; } @@ -160,6 +191,15 @@ void MacLO_MainLoop() } } +void MacLO_UpdateMenus() +{ + MenuHandle gameMenu = GetMHandle(GameMenuResID); + + CheckItem(gameMenu, SoundMenuItemID, gGameWindow.Sounds.Enabled); + + DrawMenuBar(); +} + void MacLO_HandleUpdate(const EventRecord *pEvent) { WindowPtr window; @@ -244,10 +284,6 @@ void MacLO_HandleMenuChoice(const int32_t menuChoice) void MacLO_HandleAppleMenuChoice(const int16_t item) { - MenuHandle appleMenu; - Str255 accName; - int16_t accNumber; - switch (item) { case AboutMenuItemID: @@ -296,9 +332,12 @@ void MacLO_HandleGameMenuChoice(const int16_t item) { switch (item) { - case TitleMenuItemID: + case GoToTitleMenuItemID: GameWindow_SetScene(&gGameWindow, Title); break; + case SoundMenuItemID: + GameWindow_ToggleSound(&gGameWindow); + break; case ClearMenuItemID: GameWindow_ClearScores(&gGameWindow); break; diff --git a/src/MacLO.h b/src/MacLO.h index c006515..4ad9144 100644 --- a/src/MacLO.h +++ b/src/MacLO.h @@ -25,4 +25,9 @@ void MacLO_AppInit(); */ void MacLO_MainLoop(); +/** + * Update menus of the application. + */ +void MacLO_UpdateMenus(); + #endif diff --git a/src/MacLO.pi.bin b/src/MacLO.pi.bin index 4463d0ee863ba84357476a45833a6a3ac7341682..3618aa828e65b13b552258a9b0c6846533c3453b 100644 GIT binary patch delta 3171 zcmeHJaZDRk7=PDSpew_+u9TK*g;7gkxPpL0rxFG;VF?Hs{ITeQ5<&G+mrj#<6pFQEztlg4Zl2{H> z<(q|ff9}e*)U+gAZs^Y$5EkL{oO+A(6Y$vTEqS(tYa1N2MTMJaU%F{?(%8gTRGu87 z^3*hyr!P_YL^G97U8QoemdbOBRG#-z`3;H6XP2pbVIP$*)?wdI<@e69v?ShQ*rb@m zKCH1XoO6zos#zmdjiysIIOvV(n5+852UW>eP<70PjfKyw!RGu@S*~DVm_m!jChEn8 z_?T*q$HwA3TE?gY6fp~PQHKqH(Q$5zkMT%c%CyXlUq&~yFtcXV6#7)-nY%dvCd&LW zo;tYAsCF$b7iuw>G_!)H(us__7Ct78F<-qLn&a&N3}K65xztGNB;%{f4PqwOrD{c( z6)7G@1q_B&nL1?DJSv~+@}-BjJ|WOPLO{y%&p1V@cv5hm^YNMvBBT}9+j=J+f)9+} z+q%1{h2*q$_q4P{&W`v*kuigzD2=0)K2nXu=nQbqJO#i{Mmc*T${SRNdh=y{o4Xgw^UP!!b{L@X_+M zz)DTq<{d1VssC@1|HMtQTolOL^oIBgKc4=Elf$EXE(Rv1$>GVlJqw-5C8g=dEwNcI zA?xde*bmTD@;8pHewvys=9vD3*w1m+0%H7=%k*0oQGbhARNs4P>P(bS6&E7DMTGTr zH)(tpHD7YQy@aMtf3M+EO){{!v>(il{YdDmEI; z$L+^8A7`v>u5Z<}2_d0cYQhh){^iaT5F^NI@z^iU{$YnZ1zPAXFsv zkIT*MGtc`m&(6&4zWS7;Pf26V>xu2!`&4r1yVhjli?3qdf(*mhKw|1Xhx>Ny+f6ia zWBilf+gy(7FJoRGbYyl)V=$jt=Wtzt{H!|10}C;49=w=!SSm#O>@Qg!TK7f^HAjD< z=5Yr#$Nr$^>366(?xE&Hgql--QgixwYR-H^&2uHxJU>m%3xn9sQ}fgJn6BB$bvq?Z z(=|iavDa9S7eZY%7|+K1C$NSrBRS6&8_#Fu6~ThCOw3nIX(iT}j^(NN zP%zBEO{t`4V`|t>sA6|3fZ0;sRuB)jI?Kz_%JK*%m4|5+EWh!gWmBy?&uT@9nRtvP zN!JbLs2donvNaY7@n(c0nu-P_(7^PlxZvoh>S3hOlTDx*$nsp+sW{+jG-gJgUzi{F zNo9%o9E@ZmMq)2^i}~Y#Wx%ORF*Ymn#({NlfL;dbXS$G%^s8Y# z95M8Pp>SAN`}7EkR#AFH*9LGJLmkxAzR_NNu-_PnzG6gshPsD)MtY)z^lQEPX#ZQi z!!I2_7VRIwxW2(Gee5|k`ohWRDUVDOSC2r6r#6QWDVg{P|0kkBK#_Ao#F0$Ae=*gd zYI8AMt#}(cyxX!9Gp?l7;7EBXT=$-}am6r{`=C25Twd!)-u!w~s=-2Tz0Co3=9LGf z&b0UrmQ=})yPi?JVf;{Z%6GJLT4 znS0Z)D(g@WC#q#|Ry0Zk9qUULbtk2rX2E@GWfj@KhzAkyNZk2JQ^ z_!-OJy^+S>#ZrU&l%vmGjy2-mO5@{L^m0Rp#wQ7JF`PjVZ$acD#Q8b~)DWHV&S~To zf!&RW1D1$toZx#)#172qvG~W(r_kc-Fi)kJ%Q;NrXKz(GyE+dZIxOwL1ri0^-xh?d I@>2D`0N^pZEdT%j diff --git a/src/MacLO.pi.rsrc.bin b/src/MacLO.pi.rsrc.bin index 9e8883e1580d6cf9f78b9a4d57311c7edf5ceec0..994214d87418a9b02d16ac87a3446859da7a9944 100644 GIT binary patch delta 571 zcmY+=ze`(D6bJC{%TuvxA&O9us5h?%N0Cd zddu0|W!G8eZ!%i^s>JUgpy6@ zhd-MDhG87%bPP>+3Ol@F$}4)urp7(!1#)}5)04wM36usv4ul+~|K9-AX*Di?TbiKB4SwziN6BUKC}N+9$1>TTtw4>( zPBF{5?SP!d4|c_OHPP0H0K2l4T#q@^|Huw#?5YiNHG*t0LKX=%&4Pyp)(@ljHItSJH)$}I$3P0H&=uX$m3;g2Z<02Iqsp$5mgzHWKp8)3|^-hI?PN306P74dV Xfp!P^Pj;%BL6f?WeR_}F{p@}O;?T&} delta 555 zcmZ9|OK1~e5C`!8?iTTpLQDgK#JI6l*PeVJiUbia#s@`64?Pv6Sy8AWl0uPUcWat` z8k2sp4W)<&4?W}%n+getgc3aU(1QnQ=uL`eFCN#KjUf2J2fz8xFo!W#Wn)z?-#(82 zp0DjK?%&z#b+eVD$6}`Gba+6bZ#My}S@ADOy~>x%M|xjt+yQ(|NYX;nkXpsz49tEA z1VQk7;MRjDdSv`@ep*+vQ_pq%DaJ*@(Zm&dBmQqEpv)-VP&c|SCY+BXh=}VRuq4H6 zXT+MD9JPjsX&6BO9C|?$@xLyRqcAxyej-Q24>vXM#lH2k#9_sY?O=iXi7t5?uh=JE z(!LG~?BrGQXDo*PMQ)+UK3OMk!eXlr$qm@-luE9{3B5~Rhs!=yC4Yby1oOb~7!~i~ zb7SNnc@3{aZ;@*#u}{yDt9ZjcbCFy|IrLAmk0timcjN*DTf0v-P-UN!$#ZxcxEngine), c, r); GameWindow_Draw(pGameWindow, false); Sounds_PlayClickSnd(&(pGameWindow->Sounds)); @@ -229,14 +230,15 @@ void PlayScene_Click(GameWindow *pGameWindow, const Point *pPosition) if (PtInRect(*pPosition, &(pGameWindow->PlayScene.RetryButtonRect))) { + // Click on retry button, reset level GameEngine_ResetLevel(&(pGameWindow->Engine)); GameWindow_Draw(pGameWindow, false); Sounds_PlayRetrySnd(&(pGameWindow->Sounds)); } else if (PtInRect(*pPosition, &(pGameWindow->PlayScene.SoundButtonRect))) { - pGameWindow->Sounds.Enabled = !pGameWindow->Sounds.Enabled; - GameWindow_Draw(pGameWindow, false); + // Click on sound button + GameWindow_ToggleSound(pGameWindow); } } } diff --git a/src/Sounds.c b/src/Sounds.c index de6fa40..9a1209f 100644 --- a/src/Sounds.c +++ b/src/Sounds.c @@ -13,13 +13,13 @@ #define SndBaseResID 8192 /** The click snd resource ID. */ -#define ClickSndResID SndBaseResID +#define ClickSndResID SndBaseResID /** The retry snd resource ID. */ -#define RetrySndResID (ClickSndResID + 1) +#define RetrySndResID (ClickSndResID + 1) /** The done snd resource ID. */ -#define DoneSndResID (RetrySndResID + 1) +#define DoneSndResID (RetrySndResID + 1) /** Whether or not sound is enabled by default. */ #define DefaultEnabled true diff --git a/src/TitleScene.c b/src/TitleScene.c index d0c7b1a..d9faa73 100644 --- a/src/TitleScene.c +++ b/src/TitleScene.c @@ -44,15 +44,24 @@ void TitleScene_Init(GameWindow *pGameWindow) void TitleScene_Draw(const GameWindow *pGameWindow, bool fullRefresh) { // Draw Title - DrawPicture(pGameWindow->Bitmaps.TitlePict, &(pGameWindow->TitleScene.TitleRect)); + if (fullRefresh) + { + DrawPicture(pGameWindow->Bitmaps.TitlePict, &(pGameWindow->TitleScene.TitleRect)); + } // Draw Set A - MoveTo(pGameWindow->TitleScene.SetARect.left, pGameWindow->TitleScene.SetARect.top); - Bitmaps_DrawAChar(&(pGameWindow->Bitmaps), TitleTextScale); + if (fullRefresh) + { + MoveTo(pGameWindow->TitleScene.SetARect.left, pGameWindow->TitleScene.SetARect.top); + Bitmaps_DrawAChar(&(pGameWindow->Bitmaps), TitleTextScale); + } // Draw Set B - MoveTo(pGameWindow->TitleScene.SetBRect.left, pGameWindow->TitleScene.SetBRect.top); - Bitmaps_DrawBChar(&(pGameWindow->Bitmaps), TitleTextScale); + if (fullRefresh) + { + MoveTo(pGameWindow->TitleScene.SetBRect.left, pGameWindow->TitleScene.SetBRect.top); + Bitmaps_DrawBChar(&(pGameWindow->Bitmaps), TitleTextScale); + } // Draw sound button MoveTo(pGameWindow->TitleScene.SoundButtonRect.left, pGameWindow->TitleScene.SoundButtonRect.top); @@ -63,17 +72,39 @@ void TitleScene_Click(GameWindow *pGameWindow, const Point *pPosition) { if (PtInRect(*pPosition, &(pGameWindow->TitleScene.SetARect))) { + // Click on Set A button GameEngine_NewGame(&(pGameWindow->Engine), false); - GameWindow_SetScene(pGameWindow, LevelSelect); + if (GameEngine_HasPlayedLevel(&(pGameWindow->Engine), 0)) + { + // Not first time, go to level select + GameWindow_SetScene(pGameWindow, LevelSelect); + } + else + { + // First time, go straight to play scene + GameWindow_SetScene(pGameWindow, Play); + Sounds_PlayRetrySnd(&(pGameWindow->Sounds)); + } } else if (PtInRect(*pPosition, &(pGameWindow->TitleScene.SetBRect))) { + // Click on Set B button GameEngine_NewGame(&(pGameWindow->Engine), true); - GameWindow_SetScene(pGameWindow, LevelSelect); + if (GameEngine_HasPlayedLevel(&(pGameWindow->Engine), 0)) + { + // Not first time, go to level select + GameWindow_SetScene(pGameWindow, LevelSelect); + } + else + { + // First time, go straight to play scene + GameWindow_SetScene(pGameWindow, Play); + Sounds_PlayRetrySnd(&(pGameWindow->Sounds)); + } } else if (PtInRect(*pPosition, &(pGameWindow->TitleScene.SoundButtonRect))) { - pGameWindow->Sounds.Enabled = !pGameWindow->Sounds.Enabled; - GameWindow_Draw(pGameWindow, false); + // Click on sound button + GameWindow_ToggleSound(pGameWindow); } }