From eab519a40dee47b39430b49493570ca758a99d1c Mon Sep 17 00:00:00 2001 From: Jon Thysell Date: Thu, 4 Nov 2021 19:54:28 -0700 Subject: [PATCH] Importing image assets from ArduLO I've imported some of the "character" images from ArduLO, converted to GIFs because they're easier to work with. They've been imported into a new Bitmaps structure so they only need to be loaded once at app start. I've also cleaned up some of the drawing code, and created a series of helpers for dividing Rects into a 3x3 grid, to make it easier to define the layout. I've also stubbed out "theme-support". :) --- img/0.gif | Bin 0 -> 83 bytes img/1.gif | Bin 0 -> 74 bytes img/2.gif | Bin 0 -> 80 bytes img/3.gif | Bin 0 -> 81 bytes img/4.gif | Bin 0 -> 83 bytes img/5.gif | Bin 0 -> 81 bytes img/6.gif | Bin 0 -> 83 bytes img/7.gif | Bin 0 -> 78 bytes img/8.gif | Bin 0 -> 83 bytes img/9.gif | Bin 0 -> 82 bytes img/a.gif | Bin 0 -> 84 bytes img/b.gif | Bin 0 -> 85 bytes img/slash.gif | Bin 0 -> 73 bytes img/title.gif | Bin 0 -> 1878 bytes img/title.png | Bin 2300 -> 0 bytes src/Bitmaps.c | 55 +++++++++++++++++++++++++++++++ src/Bitmaps.h | 20 ++++++++++++ src/GameEndScene.c | 4 +-- src/GameWindow.c | 3 ++ src/GameWindow.h | 20 +++++++----- src/LevelEndScene.c | 4 +-- src/MacCommon.c | 73 +++++++++++++++++++++++++++++++++++++++++- src/MacCommon.h | 23 +++++++++++-- src/MacLO.c | 28 ++++++++-------- src/MacLO.pi.bin | Bin 11776 -> 15872 bytes src/MacLO.pi.rsrc.bin | Bin 8064 -> 10752 bytes src/PlayScene.c | 10 +++--- src/Scenes.h | 17 +++++++--- src/TitleScene.c | 17 ++-------- 29 files changed, 219 insertions(+), 55 deletions(-) create mode 100644 img/0.gif create mode 100644 img/1.gif create mode 100644 img/2.gif create mode 100644 img/3.gif create mode 100644 img/4.gif create mode 100644 img/5.gif create mode 100644 img/6.gif create mode 100644 img/7.gif create mode 100644 img/8.gif create mode 100644 img/9.gif create mode 100644 img/a.gif create mode 100644 img/b.gif create mode 100644 img/slash.gif create mode 100644 img/title.gif delete mode 100644 img/title.png create mode 100644 src/Bitmaps.c create mode 100644 src/Bitmaps.h diff --git a/img/0.gif b/img/0.gif new file mode 100644 index 0000000000000000000000000000000000000000..fef56070f76c1fa1bd2b623db6797abbc55c0126 GIT binary patch literal 83 zcmZ?wbhEHb literal 0 HcmV?d00001 diff --git a/img/1.gif b/img/1.gif new file mode 100644 index 0000000000000000000000000000000000000000..9380c6095c1229b7034570885d7b633d5ae52e91 GIT binary patch literal 74 zcmZ?wbhEHba7N ZEr~G;jLvLInN%8@QCHA)%8il18USiz9F+h7 literal 0 HcmV?d00001 diff --git a/img/4.gif b/img/4.gif new file mode 100644 index 0000000000000000000000000000000000000000..dbf58ef0c3c285bc4ef01d8f114a0dec4237a7cd GIT binary patch literal 83 zcmZ?wbhEHbuv2TFWF&vcL5jvocr%0I$g&4gdfE literal 0 HcmV?d00001 diff --git a/img/7.gif b/img/7.gif new file mode 100644 index 0000000000000000000000000000000000000000..e06ee5441e3c9006638bdc217230f1891fd4d031 GIT binary patch literal 78 zcmZ?wbhEHbu~- bd}ElhW;2)F>zEtHJ$+%8*0h etDGek7MIC3eOK8U?%g?FZ5qwbe+4lxSOWkF?;qy? literal 0 HcmV?d00001 diff --git a/img/slash.gif b/img/slash.gif new file mode 100644 index 0000000000000000000000000000000000000000..cde8c7c3a606952f2b47b5ef1daf569c7f766528 GIT binary patch literal 73 zcmZ?wbhEHbQD-~g|1^{%W7!3db literal 0 HcmV?d00001 diff --git a/img/title.gif b/img/title.gif new file mode 100644 index 0000000000000000000000000000000000000000..25de3cb5bd60a5e83119823831b63528c8f0e06c GIT binary patch literal 1878 zcmV-c2dVf+Nk%w1VR8YA0HFZ@00030|NsC0|NsC0A^8LW3IGBCEC2ui0CE9}00091 zgpaAq?GI6yGg?OT-Msq`TG<$cW=D?a%7$sx9xoNw_Pxz7e(Ez1T=`-?TJVT;6?aL< za@dSEmaHdCip^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KBakGR7YdsV~@S z_bltzddHo#$G6tKF572i+_dg!OhPP*&mQVx0Qa7)a3>~rS~yXa-_OMC6MtByP8m@D6R z%EA}lcIU>&Y}VVzOW!s2%=3PF$bwsal!z~qeLTwDzYcrv&qI&?ZsI4*^6zju5B}%V z2cP}-_51Sv`1i{{zw-rdS@a_x{@MqN{*7;QiPIkNf>*%V4KH&!QDB!CcsmCYZcgem zAp0Iz4hwPwgBe`j2FDgb;(ZW-01@G2NVv4*tq+0%oM8j6<-)>rFn9Wk-m_{bwH1QU zBOv;pk6;)>4erl&DKz2)cQ+qdwB%SG6ypA@EVo1^0#Slbgd%mou@@%A?||cKqV>XM z#rBo)T&;tcTW~SME)GkEV+5cP&4=tCuPagPz);b{6{ND7wEkM@&b z2~Bv&Kp^pkkW`@^>zKq!Mv@Mbq@?cJ*vKlbjgFgy$rimhwgE;iWoIlUU;wGeMOIOk zm_+5uTv?Y><_~l5^W7eO`Ab{^1D3J8&ELnZo2`B6le;HU<)Vt!!pjo@vWW z5r}WAtfn=gnM0=hCY#1|A~V0K%5W~^KjgfW|Ik@Xb(*I(*V_y{>nYD|qLCY;wC6qB zna`=T=8 z(;9jcu5^{8^U_+^yjF*mc-5<4*O*6hD)X;|b*cd8TG+%E%y5WRtYde^HmyE(vXI4^ zWGRbTJPM|lne8k=mBv}miWZ+IljdkoyHY$M6}7A-twdW3+f4d1wzNGcMQe-O?Qt}> zyyYoKdkfsD;xxF#^&Ux!E{oi;{x-SHRj6s33*C@jHoC|?E_JV)OkHBPwLjgicT-x< Q?{0Ux;w`TrV_N_KJ5(dd-v9sr literal 0 HcmV?d00001 diff --git a/img/title.png b/img/title.png deleted file mode 100644 index ab096a1b86185de4111fc30141fd61db5606ce99..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2300 zcmVz1^@s6x01oh00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliruWFU8GbZ8()Nlj2>E@cM*00>}7L_t(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-0,0 +1,55 @@ +// Copyright (c) Jon Thysell +// Licensed under the MIT License. + +#include "Bitmaps.h" + +#define NumChars 10 + +#define TitlePictResID BaseResID +#define NumCharPictBaseResID (TitlePictResID + 1) +#define ACharPictResID (NumCharPictBaseResID + NumChars) +#define BCharPictResID (ACharPictResID + 1) +#define SlashCharPictResID (BCharPictResID + 1) + +void Bitmaps_Init(Bitmaps *pBitmaps) +{ + int16_t i; + + // Load title + pBitmaps->TitlePict = GetPicture(TitlePictResID); + if (pBitmaps->TitlePict == nil) + { + ShowError("\pTitle PICT resource missing!", true); + } + + // Load number chars + for (i = 0; i < NumChars; i++) + { + pBitmaps->NumCharPicts[i] = GetPicture(NumCharPictBaseResID + i); + if (pBitmaps->NumCharPicts[i] == nil) + { + ShowError("\pNumber char PICT resource missing!", true); + } + } + + // Load "A" char + pBitmaps->ACharPict = GetPicture(ACharPictResID); + if (pBitmaps->ACharPict == nil) + { + ShowError("\pA char PICT resource missing!", true); + } + + // Load "B" char + pBitmaps->BCharPict = GetPicture(BCharPictResID); + if (pBitmaps->BCharPict == nil) + { + ShowError("\pB char PICT resource missing!", true); + } + + // Load "/" char + pBitmaps->SlashCharPict = GetPicture(SlashCharPictResID); + if (pBitmaps->SlashCharPict == nil) + { + ShowError("\pSlash char PICT resource missing!", true); + } +} \ No newline at end of file diff --git a/src/Bitmaps.h b/src/Bitmaps.h new file mode 100644 index 0000000..1d8b2e6 --- /dev/null +++ b/src/Bitmaps.h @@ -0,0 +1,20 @@ +// Copyright (c) Jon Thysell +// Licensed under the MIT License. + +#ifndef BITMAPS_H +#define BITMAPS_H + +#include "MacCommon.h" + +typedef struct sBitmaps +{ + PicHandle TitlePict; + PicHandle NumCharPicts[10]; + PicHandle ACharPict; + PicHandle BCharPict; + PicHandle SlashCharPict; +} Bitmaps; + +void Bitmaps_Init(Bitmaps *pBitmaps); + +#endif diff --git a/src/GameEndScene.c b/src/GameEndScene.c index 29a5900..d596cab 100644 --- a/src/GameEndScene.c +++ b/src/GameEndScene.c @@ -11,8 +11,6 @@ void GameEndScene_Draw(const GameWindow *pGameWindow, bool fullRefresh) { Str255 scoreStr; - SetPort(pGameWindow->Window); - // TODO: Proper level end if (fullRefresh) { @@ -23,7 +21,7 @@ void GameEndScene_Draw(const GameWindow *pGameWindow, bool fullRefresh) MoveTo(100, 125); DrawString("\pScore: "); - NumToString((long)(pGameWindow->Engine.Score), &scoreStr); + NumToString((int32_t)(pGameWindow->Engine.Score), &scoreStr); DrawString(scoreStr); DrawString("\p/300"); } diff --git a/src/GameWindow.c b/src/GameWindow.c index b929d52..98d7380 100644 --- a/src/GameWindow.c +++ b/src/GameWindow.c @@ -21,6 +21,9 @@ void GameWindow_Init(GameWindow *pGameWindow) ShowError("\pGameWindow WIND resource missing!", true); } + // Load PICT resources + Bitmaps_Init(&(pGameWindow->Bitmaps)); + GameWindow_SetScene(pGameWindow, Title); } diff --git a/src/GameWindow.h b/src/GameWindow.h index e8af4f2..7e9ef54 100644 --- a/src/GameWindow.h +++ b/src/GameWindow.h @@ -6,18 +6,22 @@ #include "MacCommon.h" #include "GameEngine.h" +#include "Bitmaps.h" #include "Scenes.h" -#define WindowPattern black +#define WindowPattern black -typedef struct GameWindow +typedef struct sGameWindow { - WindowPtr Window; - GameEngine Engine; - SceneId CurrentSceneId; - bool SceneIsInitialized[NumScenes]; - TitleScene TitleScene; - PlayScene PlayScene; + WindowPtr Window; + GameEngine Engine; + Bitmaps Bitmaps; + SceneId CurrentSceneId; + bool SceneIsInitialized[NumScenes]; + TitleScene TitleScene; + PlayScene PlayScene; + LevelEndScene LevelEndScene; + GameEndScene GameEndScene; } GameWindow; void GameWindow_Init(GameWindow *pGameWindow); diff --git a/src/LevelEndScene.c b/src/LevelEndScene.c index adfdaf5..16f90c7 100644 --- a/src/LevelEndScene.c +++ b/src/LevelEndScene.c @@ -11,8 +11,6 @@ void LevelEndScene_Draw(const GameWindow *pGameWindow, bool fullRefresh) { Str255 halfStarsStr; - SetPort(pGameWindow->Window); - // TODO: Proper level end if (fullRefresh) { @@ -23,7 +21,7 @@ void LevelEndScene_Draw(const GameWindow *pGameWindow, bool fullRefresh) MoveTo(100, 125); DrawString("\pReceived "); - NumToString((long)GameEngine_GetHalfStars(&(pGameWindow->Engine)), &halfStarsStr); + NumToString((int32_t)GameEngine_GetHalfStars(&(pGameWindow->Engine)), &halfStarsStr); DrawString(halfStarsStr); DrawString("\p/6 half-stars."); diff --git a/src/MacCommon.c b/src/MacCommon.c index 5d35cdf..892da58 100644 --- a/src/MacCommon.c +++ b/src/MacCommon.c @@ -3,7 +3,12 @@ #include "MacCommon.h" -void ShowError(Str255 message, Boolean isFatal) +int32_t GetThemeID() +{ + return 0; +} + +void ShowError(Str255 message, bool isFatal) { ParamText(message, EmptyString, EmptyString, EmptyString); StopAlert(ErrorAlertResID, NilFilterProc); @@ -30,4 +35,70 @@ void CenterRectV(const Rect *pOuterRect, Rect *pInnerRect) { OffsetRect(pInnerRect, 0, pOuterRect->top - pInnerRect->top); OffsetRect(pInnerRect, 0, (pOuterRect->bottom - pInnerRect->bottom) / 2); +} + +void GetBoxRect(const Rect *pOuterRect, const BoxAlignment boxAlignment, Rect *pBoxRect) +{ + int32_t boxWidth, boxHeight; + + boxWidth = (pOuterRect->right - pOuterRect->left) / 3; + boxHeight = (pOuterRect->bottom - pOuterRect->top) / 3; + + switch (boxAlignment) + { + case Top: + pBoxRect->top = pOuterRect->top; + pBoxRect->left = pOuterRect->left + boxWidth; + pBoxRect->bottom = pOuterRect->top + boxHeight; + pBoxRect->right = pOuterRect->right - boxWidth; + break; + case TopLeft: + pBoxRect->top = pOuterRect->top; + pBoxRect->left = pOuterRect->left; + pBoxRect->bottom = pOuterRect->top + boxHeight; + pBoxRect->right = pOuterRect->left + boxWidth; + break; + case Left: + pBoxRect->top = pOuterRect->top + boxHeight; + pBoxRect->left = pOuterRect->left; + pBoxRect->bottom = pOuterRect->bottom - boxHeight; + pBoxRect->right = pOuterRect->left + boxWidth; + break; + case BottomLeft: + pBoxRect->top = pOuterRect->bottom - boxHeight; + pBoxRect->left = pOuterRect->left; + pBoxRect->bottom = pOuterRect->bottom; + pBoxRect->right = pOuterRect->left + boxWidth; + break; + case Bottom: + pBoxRect->top = pOuterRect->bottom - boxHeight; + pBoxRect->left = pOuterRect->left + boxWidth; + pBoxRect->bottom = pOuterRect->bottom; + pBoxRect->right = pOuterRect->right - boxWidth; + break; + case BottomRight: + pBoxRect->top = pOuterRect->bottom - boxHeight; + pBoxRect->left = pOuterRect->right - boxWidth; + pBoxRect->bottom = pOuterRect->bottom; + pBoxRect->right = pOuterRect->right; + break; + case Right: + pBoxRect->top = pOuterRect->top + boxHeight; + pBoxRect->left = pOuterRect->right - boxWidth; + pBoxRect->bottom = pOuterRect->bottom - boxHeight; + pBoxRect->right = pOuterRect->right; + break; + case TopRight: + pBoxRect->top = pOuterRect->top; + pBoxRect->left = pOuterRect->right - boxWidth; + pBoxRect->bottom = pOuterRect->top + boxHeight; + pBoxRect->right = pOuterRect->right; + break; + case Center: + pBoxRect->top = pOuterRect->top + boxHeight; + pBoxRect->left = pOuterRect->left + boxWidth; + pBoxRect->bottom = pOuterRect->bottom - boxHeight; + pBoxRect->right = pOuterRect->right - boxWidth; + break; + } } \ No newline at end of file diff --git a/src/MacCommon.h b/src/MacCommon.h index 40b6f4b..861d7b9 100644 --- a/src/MacCommon.h +++ b/src/MacCommon.h @@ -4,6 +4,8 @@ #ifndef MACCOMMON_H #define MACCOMMON_H +#include "Common.h" + #define BaseResID 128 #define MoveToFront (WindowPtr)-1L @@ -12,12 +14,29 @@ #define ErrorAlertResID BaseResID -pascal OSErr SetDialogDefaultItem(DialogPtr theDialog, short newItem) = { 0x303C, 0x0304, 0xAA68 }; +typedef enum eBoxAlignment +{ + Top, + TopLeft, + Left, + BottomLeft, + Bottom, + BottomRight, + Right, + TopRight, + Center +} BoxAlignment; -void ShowError(Str255 message, Boolean isFatal); +pascal OSErr SetDialogDefaultItem(DialogPtr theDialog, int16_t newItem) = { 0x303C, 0x0304, 0xAA68 }; + +int32_t GetThemeID(); + +void ShowError(Str255 message, bool isFatal); void CenterRect(const Rect *pOuterRect, Rect *pInnerRect); void CenterRectH(const Rect *pOuterRect, Rect *pInnerRect); void CenterRectV(const Rect *pOuterRect, Rect *pInnerRect); +void GetBoxRect(const Rect *pOuterRect, const BoxAlignment boxAlignment, Rect *pBoxRect); + #endif diff --git a/src/MacLO.c b/src/MacLO.c index 31fb129..4863ef9 100644 --- a/src/MacLO.c +++ b/src/MacLO.c @@ -21,13 +21,13 @@ void MacLO_HandleUpdate(const EventRecord *pEvent); void MacLO_HandleMouseDown(const EventRecord *pEvent); void MacLO_HandleMouseUp(const EventRecord *pEvent); -void MacLO_HandleMenuChoice(const long menuChoice); -void MacLO_HandleAppleMenuChoice(const short item); +void MacLO_HandleMenuChoice(const int32_t menuChoice); +void MacLO_HandleAppleMenuChoice(const int16_t item); void MacLO_ShowAboutDialog(); -void MacLO_LaunchAppleMenuItem(const short item); +void MacLO_LaunchAppleMenuItem(const int16_t item); -void MacLO_HandleGameMenuChoice(const short item); +void MacLO_HandleGameMenuChoice(const int16_t item); void MacLO_ToolBoxInit() { @@ -116,8 +116,8 @@ void MacLO_HandleUpdate(const EventRecord *pEvent) void MacLO_HandleMouseDown(const EventRecord *pEvent) { WindowPtr window; - long windowPart; - long menuChoice; + int32_t windowPart; + int32_t menuChoice; Point mousePosition; windowPart = FindWindow(pEvent->where, &window); @@ -140,7 +140,7 @@ void MacLO_HandleMouseDown(const EventRecord *pEvent) void MacLO_HandleMouseUp(const EventRecord *pEvent) { WindowPtr window; - long windowPart; + int32_t windowPart; Point mousePosition; windowPart = FindWindow(pEvent->where, &window); @@ -155,10 +155,10 @@ void MacLO_HandleMouseUp(const EventRecord *pEvent) } } -void MacLO_HandleMenuChoice(const long menuChoice) +void MacLO_HandleMenuChoice(const int32_t menuChoice) { - short menu; - short item; + int16_t menu; + int16_t item; if (menuChoice != 0) { @@ -179,11 +179,11 @@ void MacLO_HandleMenuChoice(const long menuChoice) } } -void MacLO_HandleAppleMenuChoice(const short item) +void MacLO_HandleAppleMenuChoice(const int16_t item) { MenuHandle appleMenu; Str255 accName; - short accNumber; + int16_t accNumber; switch (item) { @@ -214,7 +214,7 @@ void MacLO_ShowAboutDialog() DisposDialog(dialog); } -void MacLO_LaunchAppleMenuItem(const short item) +void MacLO_LaunchAppleMenuItem(const int16_t item) { MenuHandle appleMenu; Str255 accName; @@ -225,7 +225,7 @@ void MacLO_LaunchAppleMenuItem(const short item) } -void MacLO_HandleGameMenuChoice(const short item) +void MacLO_HandleGameMenuChoice(const int16_t item) { switch (item) { diff --git a/src/MacLO.pi.bin b/src/MacLO.pi.bin index d2cafb78209544d922566c858722795d3c2ad17d..bdb822f2d03eca0181ad3f06a6ddf1778a3d04b4 100644 GIT binary patch delta 3815 zcmeH~U2Icj7{{N}w_VqDYu#4bvTn9??1K>+cfp4fIKWWEI9v#RK#8z;mdM3`2!;;{ z=MX{JaALR_8@*8Ug3Toug~4WN!5~*tiA-pF{J;GeY(v=v2{*KP z&iTLZ`MuA1-jDO1=VzXKMD5SVWNh^q4q}U z^Uy%0HT-)}Tp?Ptx-0drQL>%dZYnkKQ|1|JEivWCcBWhqc9JPSSHsrBt}x}|a;97w zWXj+jrVJlv%GEVYi4Qa7w~b7>ag!-G1F&YM+-^@hucjK>MY~m3 z%>vu=4>6YIqA4oaOHzttjZ{6FB$FH^V)|W@qy#v-3a}OqHGqo+s1m?PlJevTmXod} zNV2Cu$^h#Ox}Hi>!9rXRQL4I@BuPeFN%%HMx_*a@OwXc;Bv}^XX78uaC(#!f_lE~G z#2q7d$*7O0YJ_IP?FiTfV8vBE1$OTko74>&d6PPecrz@b18Wwnq$j}c0js9{jWJV%M!EYC_Bf6-DQ74T1;Wi0&V zo4ncP;I)ObY@10M3dicQ#=8njd9%w}WEcu}IdaC2OsnAE+x$|1FDa_wf0WE*L?-@> zvyvYzspEZxtN7BQ+WK((z);pOmw1fJ-OE<4X(G$AP21a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#t98j29+O&}Gb-xX+Y( zNs9SNAmajtCPoG>5TEG+lfw)K1E^F5ObLSC zY{y&7wfUC#Wmc9249)*1xA2%qp<2wm)n7m;4yZ$hao%Jv^?pW%$+y(^2{3OBU|?wc z{~zeSPN0&M$tyJESy?~^PtMRZD$UQ)%K%z`x1)9f3^Pc8yd)zL9OB~1z)@V1l9^Wm zQpCW#M5lH>3Window); - if (fullRefresh) { // Fill backgrounds @@ -89,13 +87,13 @@ void PlayScene_Draw(const GameWindow *pGameWindow, bool fullRefresh) // Draw Par MoveTo(pGameWindow->PlayScene.HUDRect.left + 10, pGameWindow->PlayScene.HUDRect.top + 40); DrawString("\pPar: "); - NumToString((long)(pGameWindow->Engine.Par), &parStr); + NumToString((int32_t)(pGameWindow->Engine.Par), &parStr); DrawString(parStr); // Draw Moves MoveTo(pGameWindow->PlayScene.HUDRect.left + 10, pGameWindow->PlayScene.HUDRect.top + 60); DrawString("\pMoves: "); - NumToString((long)(pGameWindow->Engine.Moves), &movesStr); + NumToString((int32_t)(pGameWindow->Engine.Moves), &movesStr); DrawString(movesStr); DrawString("\p/"); DrawString(parStr); @@ -103,14 +101,14 @@ void PlayScene_Draw(const GameWindow *pGameWindow, bool fullRefresh) // Draw Stars MoveTo(pGameWindow->PlayScene.HUDRect.left + 10, pGameWindow->PlayScene.HUDRect.top + 80); DrawString("\pStars: "); - NumToString((long)GameEngine_GetHalfStars(&(pGameWindow->Engine)), &halfStarsStr); + NumToString((int32_t)GameEngine_GetHalfStars(&(pGameWindow->Engine)), &halfStarsStr); DrawString(halfStarsStr); DrawString("\p/6"); // Draw Score MoveTo(pGameWindow->PlayScene.HUDRect.left + 10, pGameWindow->PlayScene.HUDRect.top + 100); DrawString("\pScore: "); - NumToString((long)(pGameWindow->Engine.Score), &scoreStr); + NumToString((int32_t)(pGameWindow->Engine.Score), &scoreStr); DrawString(scoreStr); DrawString("\p/300"); } diff --git a/src/Scenes.h b/src/Scenes.h index ef46def..2293bff 100644 --- a/src/Scenes.h +++ b/src/Scenes.h @@ -6,7 +6,7 @@ #define NumScenes 4 -typedef enum SceneId +typedef enum eSceneId { Title, Play, @@ -14,16 +14,25 @@ typedef enum SceneId GameEnd } SceneId; -typedef struct TitleScene +typedef struct sTitleScene { - PicHandle TitlePict; Rect TitleRect; } TitleScene; -typedef struct PlayScene +typedef struct sPlayScene { Rect PlayfieldRect; Rect HUDRect; } PlayScene; +typedef struct sLevelEndScene +{ + Rect temp; +} LevelEndScene; + +typedef struct sGameEndScene +{ + Rect temp; +} GameEndScene; + #endif diff --git a/src/TitleScene.c b/src/TitleScene.c index cc2ef80..e0a50aa 100644 --- a/src/TitleScene.c +++ b/src/TitleScene.c @@ -2,38 +2,27 @@ // Licensed under the MIT License. #include "TitleScene.h" - -#define TitlePictResID BaseResID +#include "Bitmaps.h" void TitleScene_Init(GameWindow *pGameWindow) { const Rect *pContentRect = &(pGameWindow->Window->portRect); - pGameWindow->TitleScene.TitlePict = GetPicture(TitlePictResID); - - if (pGameWindow->TitleScene.TitlePict == nil) - { - ShowError("\pTitle PICT resource missing!", true); - } - // Setup rects - pGameWindow->TitleScene.TitleRect = (**(pGameWindow->TitleScene.TitlePict)).picFrame; + pGameWindow->TitleScene.TitleRect = (**(pGameWindow->Bitmaps.TitlePict)).picFrame; CenterRect(pContentRect, &(pGameWindow->TitleScene.TitleRect)); } void TitleScene_Draw(const GameWindow *pGameWindow, bool fullRefresh) { - SetPort(pGameWindow->Window); - // TODO: Proper title if (fullRefresh) { } // Draw Title PICT - DrawPicture(pGameWindow->TitleScene.TitlePict, &(pGameWindow->TitleScene.TitleRect)); + DrawPicture(pGameWindow->Bitmaps.TitlePict, &(pGameWindow->TitleScene.TitleRect)); - ForeColor(blackColor); TextFace(bold + outline); MoveTo(100, pGameWindow->TitleScene.TitleRect.bottom + 30);