Skip to content

Commit

Permalink
Merge pull request #15 from RobbieNesmith/more-how-to
Browse files Browse the repository at this point in the history
More information on how to play
  • Loading branch information
RobbieNesmith authored Oct 31, 2024
2 parents 71fc180 + 526b536 commit 52cbced
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 17 deletions.
52 changes: 38 additions & 14 deletions PalmWordle.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static void DrawKeyboardUsedChars(int x, int y)
WinPopDrawState();
}

static Boolean CheckAndRenderWord(const Char c[5], int x, int y)
static Boolean CheckAndRenderWord(const Char correct[5], const Char guess[5], int x, int y)
{
Boolean won = true;
int i, j, k;
Expand All @@ -131,23 +131,23 @@ static Boolean CheckAndRenderWord(const Char c[5], int x, int y)

for (i = 0; i < 5; i++)
{
if (word[i] != c[i])
if (correct[i] != guess[i])
{
colors[i] = WRONG_COLOR;
won = false;
for (j = 0; j < 5; j++)
{
if (word[j] == c[i])
if (correct[j] == guess[i])
{
wordInstances = 0;
guessInstances = 0;
for (k = 0; k < 5; k++)
{
if (word[k] == c[i])
if (correct[k] == guess[i])
{
wordInstances++;
}
if (c[k] == c[i])
if (guess[k] == guess[i])
{
guessInstances++;
}
Expand All @@ -160,14 +160,14 @@ static Boolean CheckAndRenderWord(const Char c[5], int x, int y)
{
if (k < i)
{
if (c[k] == c[i] && colors[k] < WRONG_COLOR)
if (guess[k] == guess[i] && colors[k] < WRONG_COLOR)
{
timesBeaten++;
}
}
else if (k > i)
{
if (c[k] == c[i] && c[k] == word[k])
if (guess[k] == guess[i] && guess[k] == correct[k])
{
timesBeaten++;
}
Expand Down Expand Up @@ -204,7 +204,7 @@ static Boolean CheckAndRenderWord(const Char c[5], int x, int y)
WinDrawRectangleFrame(roundFrame, &rect);
}
}
WinDrawChar(c[i] - 0x20, x + i * 24 + 7, y + 2);
WinDrawChar(guess[i] - 0x20, x + i * 24 + 7, y + 2);
}

WinPopDrawState();
Expand All @@ -227,7 +227,7 @@ static void RenderBoard()
{
if (row < guessRow)
{
CheckAndRenderWord(guess[row], xOffset, row * 24 + 18);
CheckAndRenderWord(word, guess[row], xOffset, row * 24 + 18);
}
else
{
Expand Down Expand Up @@ -268,7 +268,7 @@ static void RenderNextAndLastGuess(int x, int y)

if (guessRow > 0)
{
CheckAndRenderWord(guess[guessRow - 1], screenWidth / 2 - 60, y);
CheckAndRenderWord(word, guess[guessRow - 1], screenWidth / 2 - 60, y);
}
}

Expand All @@ -292,12 +292,12 @@ static void ClearWord(int x, int y)

static void RenderCorrectWord()
{
CheckAndRenderWord(word, screenWidth / 2 - 60, 70);
CheckAndRenderWord(word, word, screenWidth / 2 - 60, 70);
}

static void RenderFinalWord()
{
CheckAndRenderWord(guess[guessRow], screenWidth / 2 - 60, 110);
CheckAndRenderWord(word, guess[guessRow], screenWidth / 2 - 60, 110);
}

static Boolean WinFormHandleEvent(EventPtr e)
Expand Down Expand Up @@ -354,13 +354,13 @@ static Boolean HandleKeyDown(EventPtr e)
{
if (activeFormId == MainForm)
{
won = CheckAndRenderWord(guess[guessRow], xOffset, guessRow * 24 + 18);
won = CheckAndRenderWord(word, guess[guessRow], xOffset, guessRow * 24 + 18);
}
else
{
ClearWord(xOffset, 20);
ClearWord(xOffset, 44);
won = CheckAndRenderWord(guess[guessRow], xOffset, 20);
won = CheckAndRenderWord(word, guess[guessRow], xOffset, 20);
}

if (won)
Expand Down Expand Up @@ -474,6 +474,14 @@ static Boolean KeyboardFormHandleEvent(EventPtr e)
return handled;
}

static Boolean HowToForm2HandleEvent(EventPtr e) {
if (e->eType == frmOpenEvent)
{
CheckAndRenderWord("liven", "pilot", screenWidth / 2 - 60, 64);
}
return false;
}

static Boolean ApplicationHandleEvent(EventPtr e)
{
short formId;
Expand Down Expand Up @@ -501,6 +509,9 @@ static Boolean ApplicationHandleEvent(EventPtr e)
case KeyboardForm:
FrmSetEventHandler(frm, KeyboardFormHandleEvent);
break;
case HowToForm2:
FrmSetEventHandler(frm, HowToForm2HandleEvent);
break;
}
return true;
}
Expand Down Expand Up @@ -573,6 +584,19 @@ UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
case OkButton:
FrmGotoForm(MainForm);
break;
case NextButton:
FrmGotoForm(HowToForm2);
break;
case BackButton:
if (screenWidth == 560)
{
FrmGotoForm(HowToFormDana);
}
else
{
FrmGotoForm(HowToForm);
}
break;
case QuitButton:
goto _quit;
break;
Expand Down
3 changes: 3 additions & 0 deletions PalmWordle.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
#define LoseFormDana 1007
#define AboutFormDana 1008
#define HowToFormDana 1009
#define HowToForm2 1010

#define OkButton 9000
#define QuitButton 9001
#define NextButton 9002
#define BackButton 9003

#define WordleMenu 2000
#define Quit 2011
Expand Down
22 changes: 19 additions & 3 deletions PalmWordle.rcp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,22 @@ BEGIN
LABEL "Use Graffiti or a keyboard to enter" AUTOID AT (CENTER PREVBOTTOM + 2) FONT 0
LABEL "letters and enter, 5-way center" AUTOID AT (CENTER PREVBOTTOM + 2) FONT 0
LABEL "button or press the rocker to guess." AUTOID AT (CENTER PREVBOTTOM + 2) FONT 0
BUTTON "OK" ID OkButton AT (CENTER 140 AUTO AUTO)
BUTTON "OK" ID OkButton AT (RIGHT@78 140 AUTO AUTO)
BUTTON "Next" ID NextButton AT (82 140 AUTO AUTO)
END

FORM ID HowToForm2 AT (0 0 160 160)
USABLE
MENUID WordleMenu
BEGIN
TITLE "Wordle"
LABEL "How to play Wordle" AUTOID AT (CENTER 24) FONT 2
LABEL "Example" AUTOID AT (CENTER PREVBOTTOM + 4) FONT 0
LABEL "I is in the word and in the correct spot" AUTOID AT (CENTER PREVBOTTOM + 36)
LABEL "L is in the word but in the wrong spot" AUTOID AT (CENTER PREVBOTTOM + 4)
LABEL "O is not in the word in any spot" AUTOID AT (CENTER PREVBOTTOM + 4)
BUTTON "Back" ID BackButton AT (RIGHT@78 140 AUTO AUTO)
BUTTON "OK" ID OkButton AT (82 140 AUTO AUTO)
END

FORM ID HowToFormDana AT (0 0 560 160)
Expand All @@ -68,7 +83,8 @@ BEGIN
LABEL "to show how close your guess was to the word." AUTOID AT (CENTER PREVBOTTOM + 2) FONT 0
LABEL "Use Graffiti or a keyboard to enter letters" AUTOID AT (CENTER PREVBOTTOM + 2) FONT 0
LABEL "and enter, 5-way center button or press the rocker to guess." AUTOID AT (CENTER PREVBOTTOM + 2) FONT 0
BUTTON "OK" ID OkButton AT (CENTER 140 AUTO AUTO)
BUTTON "OK" ID OkButton AT (RIGHT@78 140 AUTO AUTO)
BUTTON "Next" ID NextButton AT (82 140 AUTO AUTO)
END

FORM ID WinForm AT (0 0 160 160)
Expand Down Expand Up @@ -145,6 +161,6 @@ END

SMALLICON "PalmWordleSmall.bmp"

VERSION 1 "3.0.0"
VERSION 1 "3.1.0"

LAUNCHERCATEGORY ID 1000 "Games"

0 comments on commit 52cbced

Please sign in to comment.