Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sokobokobanaban Instructions #332

Merged
merged 127 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
68cbcf4
copy over previous sokoban
hunterdyar May 4, 2024
fa378f9
pango initial sprites
hunterdyar May 4, 2024
a763f86
soko Tools from previous year
hunterdyar May 4, 2024
de301a8
spelling fix
hunterdyar May 5, 2024
6488709
start soko readme
hunterdyar May 5, 2024
cde475f
tinting crates when on goal
hunterdyar May 5, 2024
5866a61
remove old sprites, pango for player
hunterdyar May 5, 2024
0bda925
placeholders for saving solving a level
hunterdyar May 5, 2024
57646ed
Pre-process tmx files into .bin files during make.
hunterdyar May 5, 2024
5189b3b
Remembering overworld position for player
hunterdyar May 5, 2024
6c9b072
python binary packing
hunterdyar May 6, 2024
83f3703
Soko documentation on how levels and compression works
hunterdyar May 7, 2024
57f44a9
Cleanup
hunterdyar May 7, 2024
428a5ab
Saving + Loading Level Progress
hunterdyar May 7, 2024
1df9642
Saving code + gross refactor
hunterdyar May 7, 2024
7dc5366
tmx converter chases tsx files down, uses type names for tiles
hunterdyar May 7, 2024
d343bd1
Conversion output cleanup and skip unchanged files.
hunterdyar May 7, 2024
168243a
portal drawing, saving ish
hunterdyar May 7, 2024
4e1f09b
portal draw bug fix
hunterdyar May 8, 2024
fffc52e
Euler levels, loaded levels now set by index correctly
hunterdyar May 11, 2024
41bb7c3
Crate level encoded/decode bug fix
hunterdyar May 11, 2024
4bd54b3
Sticky trails as entity type
hunterdyar May 11, 2024
f885a4e
black background for euler
hunterdyar May 11, 2024
40c66a1
Undo Support
hunterdyar May 12, 2024
68c7ba1
missing semicolon oops
hunterdyar May 12, 2024
0cce550
Saving and loading
hunterdyar May 12, 2024
c590a18
flag for when to load new level data
hunterdyar May 13, 2024
79d7c0a
Soko Level Compression
hunterdyar May 14, 2024
1af316a
Art!
hunterdyar May 25, 2024
409c5ff
render bg under bg tile
hunterdyar May 25, 2024
1bd5b25
Merge branch 'main' into sokobokobanaban
hunterdyar Jul 20, 2024
1a75e9a
menu fix and bug fix
hunterdyar Jul 20, 2024
74d2ed3
removing normal soko, maybe?
hunterdyar Jul 20, 2024
0146a90
soko levels
hunterdyar Jul 20, 2024
1568690
remove test level and clean up a single entire error
hunterdyar Jul 20, 2024
2d409a1
floor color to theme struct.
hunterdyar Jul 21, 2024
c0fabd6
copy over previous sokoban
hunterdyar May 4, 2024
8f94571
pango initial sprites
hunterdyar May 4, 2024
ec553d1
soko Tools from previous year
hunterdyar May 4, 2024
bffc8c5
spelling fix
hunterdyar May 5, 2024
909ca82
start soko readme
hunterdyar May 5, 2024
24c155e
tinting crates when on goal
hunterdyar May 5, 2024
3d5dc20
remove old sprites, pango for player
hunterdyar May 5, 2024
4930586
placeholders for saving solving a level
hunterdyar May 5, 2024
1df5cbe
Pre-process tmx files into .bin files during make.
hunterdyar May 5, 2024
cfa7a9f
Remembering overworld position for player
hunterdyar May 5, 2024
3c1a29e
python binary packing
hunterdyar May 6, 2024
a05ed53
Soko documentation on how levels and compression works
hunterdyar May 7, 2024
03963d0
Cleanup
hunterdyar May 7, 2024
cfdcacb
Saving + Loading Level Progress
hunterdyar May 7, 2024
9a5b730
Saving code + gross refactor
hunterdyar May 7, 2024
5ae6b8b
tmx converter chases tsx files down, uses type names for tiles
hunterdyar May 7, 2024
a44b734
Conversion output cleanup and skip unchanged files.
hunterdyar May 7, 2024
f10291e
portal drawing, saving ish
hunterdyar May 7, 2024
ecbaec6
portal draw bug fix
hunterdyar May 8, 2024
1c5a9e8
Euler levels, loaded levels now set by index correctly
hunterdyar May 11, 2024
9e2a648
Crate level encoded/decode bug fix
hunterdyar May 11, 2024
c36a41f
Sticky trails as entity type
hunterdyar May 11, 2024
e640af5
black background for euler
hunterdyar May 11, 2024
1ca4267
Undo Support
hunterdyar May 12, 2024
b32ce25
missing semicolon oops
hunterdyar May 12, 2024
8d95c7c
Saving and loading
hunterdyar May 12, 2024
1425f81
flag for when to load new level data
hunterdyar May 13, 2024
b1b59ac
Soko Level Compression
hunterdyar May 14, 2024
3531252
Art!
hunterdyar May 25, 2024
3bdd76b
render bg under bg tile
hunterdyar May 25, 2024
39cf290
menu fix and bug fix
hunterdyar Jul 20, 2024
b88d8b3
removing normal soko, maybe?
hunterdyar Jul 20, 2024
fc45cc8
soko levels
hunterdyar Jul 20, 2024
479b848
remove test level and clean up a single entire error
hunterdyar Jul 20, 2024
1bda28c
floor color to theme struct.
hunterdyar Jul 21, 2024
48dd593
background experiments
hunterdyar Jul 21, 2024
85e84bf
preprocessor fix, warnings fix
hunterdyar Jul 21, 2024
fc4ecc6
Merge branch 'sokobokobanaban' of https://github.com/AEFeinstein/Supe…
hunterdyar Jul 21, 2024
0189d15
remove unused dependency
hunterdyar Sep 9, 2024
5bde606
Merge branch 'main' into sokobokobanaban
hunterdyar Sep 9, 2024
3c8b93e
Fix CMake for firmware build
AEFeinstein Sep 13, 2024
42e33e9
Formatting!
AEFeinstein Sep 22, 2024
6509c6f
Fix firmware warnings
AEFeinstein Sep 22, 2024
a291317
Fix cppcheck warning
AEFeinstein Sep 22, 2024
d607589
Add soko to modes list
AEFeinstein Sep 22, 2024
e3a8718
Fix out of bounds memory accesses, leaks
AEFeinstein Sep 22, 2024
7f40816
Squash merge origin/main into soko
AEFeinstein Sep 22, 2024
58bd8f3
Squashed commit of the following:
AEFeinstein Sep 22, 2024
ae6da4f
Add curly braces for switch cases
AEFeinstein Sep 22, 2024
1436da2
remove compression
hunterdyar Oct 12, 2024
247ccb8
Merge branch 'sokobokobanaban' of https://github.com/AEFeinstein/Supe…
hunterdyar Oct 12, 2024
3b4a74f
Level fix, patch out broken resume for now
hunterdyar Oct 12, 2024
165a82f
New eulerian (soko) Level
hunterdyar Oct 15, 2024
2500974
Rename game and return to previous spot on overworld
hunterdyar Oct 29, 2024
fbf46ed
Level Fix
hunterdyar Oct 30, 2024
5c547dd
allSolved and simplify BG
hunterdyar Oct 30, 2024
7754f92
fix overworld initial load bug
hunterdyar Nov 2, 2024
ea5425d
removed some laser code I felt safe removing
hunterdyar Nov 24, 2024
61dfa09
Level Titles and random victory messages
hunterdyar Nov 24, 2024
6450002
Merge branch 'main' into sokobokobanaban
hunterdyar Nov 24, 2024
1237ebf
New player sprite design
hunterdyar Nov 24, 2024
90834f3
sticky trail to match player color
hunterdyar Nov 24, 2024
5fc9146
Fix fw compilation, warning, debugging
AEFeinstein Nov 30, 2024
84889d6
Formatting
AEFeinstein Nov 30, 2024
bb36b31
Fix crash on load
AEFeinstein Nov 30, 2024
2d32cdf
Shorten name, use consistent font
AEFeinstein Nov 30, 2024
dce7dbc
use SPIRAM
AEFeinstein Nov 30, 2024
4ee2477
Remove double newline from debugging
AEFeinstein Nov 30, 2024
39b1127
Add centered player wsg
AEFeinstein Nov 30, 2024
85346f8
Add soko help page infrastructure
AEFeinstein Dec 1, 2024
b32d398
Write instructions
AEFeinstein Dec 1, 2024
d6c1005
Fix leak
AEFeinstein Dec 1, 2024
14dd5c1
Press start to return to menu
AEFeinstein Dec 1, 2024
9f6c6b4
Merge remote-tracking branch 'origin/main' into sokobokobanaban
AEFeinstein Dec 1, 2024
ff1f830
Add ability to not draw menu rings
AEFeinstein Dec 3, 2024
fce1112
Turn off rings for other instructions
AEFeinstein Dec 3, 2024
f76086f
Uttt pass and play (#334)
AEFeinstein Dec 2, 2024
78559bc
Added newmajoe's 2048 theme
johnnywycliffe Nov 3, 2024
4c97de4
Updated to include sound mapping for BGM
johnnywycliffe Nov 8, 2024
2686f96
#329 Add tilt controls
AEFeinstein Dec 2, 2024
e7e3873
Clean up pyFlashGui instructions
AEFeinstein Dec 3, 2024
5af1767
Always start pass & play on p1
AEFeinstein Dec 3, 2024
60d7742
Fix memory leak
AEFeinstein Dec 3, 2024
69ce902
Recolor UTTT menu
AEFeinstein Dec 3, 2024
4f0a7b4
UTTT Fixes
AEFeinstein Dec 4, 2024
4af0fa6
#331 Play drum funcs to match sampling rate
AEFeinstein Dec 4, 2024
5ad2bf5
#331 Fix drumkit sampling rates
AEFeinstein Dec 4, 2024
83e7fee
#224 Add note about speaker fuzz
AEFeinstein Dec 5, 2024
5f693a2
Make and use build config for production hotdog
AEFeinstein Dec 5, 2024
203b8ca
Merge remote-tracking branch 'origin/main' into sokobokobanaban
AEFeinstein Dec 5, 2024
5cf38b5
mild text updates
hunterdyar Dec 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ idf_component_register(SRCS "asset_loaders/common/heatshrink_encoder.c"
"modes/games/bigbug/soundManager_bigbug.c"
"modes/games/bigbug/tilemap_bigbug.c"
"modes/games/bigbug/worldGen_bigbug.c"
"modes/games/cGrove/cg_Chowa.c"
"modes/games/cGrove/cg_Items.c"
"modes/games/cGrove/Garden/cg_GroveAI.c"
"modes/games/cGrove/Garden/cg_Grove.c"
"modes/games/cGrove/Garden/cg_GroveDraw.c"
"modes/games/cGrove/Garden/cg_GroveItems.c"
"modes/games/cGrove/mode_cGrove.c"
"modes/games/cGrove/Sparring/cg_Match.c"
"modes/games/cGrove/Sparring/cg_Spar.c"
"modes/games/cGrove/Sparring/cg_SparDraw.c"
"modes/games/pango/paEntity.c"
"modes/games/pango/paEntityManager.c"
"modes/games/pango/paGameData.c"
Expand All @@ -47,6 +57,7 @@ idf_component_register(SRCS "asset_loaders/common/heatshrink_encoder.c"
"modes/games/soko/soko.c"
"modes/games/soko/soko_game.c"
"modes/games/soko/soko_gamerules.c"
"modes/games/soko/sokoHelp.c"
"modes/games/soko/soko_input.c"
"modes/games/soko/soko_save.c"
"modes/games/soko/soko_undo.c"
Expand All @@ -61,21 +72,11 @@ idf_component_register(SRCS "asset_loaders/common/heatshrink_encoder.c"
"modes/games/ultimateTTT/ultimateTTTmarkerSelect.c"
"modes/games/ultimateTTT/ultimateTTTp2p.c"
"modes/games/ultimateTTT/ultimateTTTresult.c"
"modes/games/cGrove/mode_cGrove.c"
"modes/games/cGrove/cg_Chowa.c"
"modes/games/cGrove/cg_Items.c"
"modes/games/cGrove/Garden/cg_Grove.c"
"modes/games/cGrove/Garden/cg_GroveAI.c"
"modes/games/cGrove/Garden/cg_GroveDraw.c"
"modes/games/cGrove/Garden/cg_GroveItems.c"
"modes/games/cGrove/Sparring/cg_Match.c"
"modes/games/cGrove/Sparring/cg_Spar.c"
"modes/games/cGrove/Sparring/cg_SparDraw.c"
"modes/music/colorchord/colorchord.c"
"modes/music/jukebox/jukebox.c"
"modes/music/sequencer/sequencerGrid.c"
"modes/music/sequencer/sequencerHelp.c"
"modes/music/sequencer/sequencerMode.c"
"modes/music/sequencer/sequencerGrid.c"
"modes/music/tunernome/tunernome.c"
"modes/music/usbsynth/mode_synth.c"
"modes/system/credits/credits_utils.c"
Expand Down
47 changes: 43 additions & 4 deletions main/modes/games/soko/soko.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "soko_game.h"
#include "soko_gamerules.h"
#include "soko_save.h"
#include "sokoHelp.h"
#include "mainMenu.h"

static void sokoMainLoop(int64_t elapsedUs);
static void sokoEnterMode(void);
Expand All @@ -15,7 +17,10 @@ static void sokoExtractLevelNamesAndIndices(soko_abs_t* self);
// strings
const char sokoModeName[] = "Hunter's Puzzles";
static const char sokoPlayGameLabel[] = "Play";
const char SOKO_TAG[] = "SB";
static const char sokoHelpLabel[] = "Instructions";
static const char sokoExitLabel[] = "Exit";

const char SOKO_TAG[] = "SB";

extern const char key_sk_overworldPos[];

Expand Down Expand Up @@ -44,7 +49,13 @@ static void sokoEnterMode(void)
{
soko = heap_caps_calloc(1, sizeof(soko_abs_t), MALLOC_CAP_SPIRAM);
// Load a font
loadFont("ibm_vga8.font", &soko->ibm, false);
loadFont("ibm_vga8.font", &soko->ibm, true);
loadFont("rodin_eb.font", &soko->font_rodin, true);
makeOutlineFont(&soko->font_rodin, &soko->font_rodin_outline, true);
loadFont("righteous_150.font", &soko->font_righteous, true);
makeOutlineFont(&soko->font_righteous, &soko->font_righteous_outline, true);

soko->allSolved = false;

soko->allSolved = false;

Expand Down Expand Up @@ -106,11 +117,15 @@ static void sokoEnterMode(void)
soko->eulerTheme.altFloorColor = c433; // painted tiles color.

// Initialize the menu
soko->menu = initMenu(sokoModeName, sokoMenuCb);
soko->menuManiaRenderer = initMenuManiaRenderer(NULL, NULL, NULL);
soko->menu = initMenu(sokoModeName, sokoMenuCb);
soko->bgMenu = initMenu(sokoModeName, NULL);
soko->menuManiaRenderer
= initMenuManiaRenderer(&soko->font_righteous, &soko->font_righteous_outline, &soko->font_rodin);

// addSingleItemToMenu(soko->menu, sokoResumeGameLabel);
addSingleItemToMenu(soko->menu, sokoPlayGameLabel);
addSingleItemToMenu(soko->menu, sokoHelpLabel);
addSingleItemToMenu(soko->menu, sokoExitLabel);

// Set the mode to menu mode
soko->screen = SOKO_MENU;
Expand All @@ -135,10 +150,15 @@ static void sokoExitMode(void)
}
// Deinitialize the menu
deinitMenu(soko->menu);
deinitMenu(soko->bgMenu);
deinitMenuManiaRenderer(soko->menuManiaRenderer);

// Free the font
freeFont(&soko->ibm);
freeFont(&soko->font_rodin);
freeFont(&soko->font_rodin_outline);
freeFont(&soko->font_righteous);
freeFont(&soko->font_righteous_outline);

// free the level name file
freeTxt(soko->levelFileText);
Expand Down Expand Up @@ -193,6 +213,15 @@ static void sokoMenuCb(const char* label, bool selected, uint32_t settingVal)
sokoInitGameBin(soko);
soko->screen = SOKO_LEVELPLAY;
}
else if (sokoHelpLabel == label)
{
soko->helpIdx = 0;
soko->screen = SOKO_HELP;
}
else if (sokoExitLabel == label)
{
switchToSwadgeMode(&mainMenuMode);
}
}
}

Expand Down Expand Up @@ -241,6 +270,16 @@ static void sokoMainLoop(int64_t elapsedUs)
ESP_LOGD(SOKO_TAG, "Go to gameplay");
soko->loadNewLevelFlag = false; // reset flag.
soko->screen = SOKO_LEVELPLAY;
break;
}
case SOKO_HELP:
{
buttonEvt_t evt = {0};
while (checkButtonQueueWrapper(&evt))
{
buttonSokoHelp(soko, &evt);
}
drawSokoHelp(soko, elapsedUs);
}
}
}
Expand Down
14 changes: 12 additions & 2 deletions main/modes/games/soko/soko.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ typedef enum
{
SOKO_MENU,
SOKO_LEVELPLAY,
SOKO_LOADNEWLEVEL
SOKO_LOADNEWLEVEL,
SOKO_HELP,
} sokoScreen_t;

typedef enum
Expand Down Expand Up @@ -181,9 +182,14 @@ typedef struct soko_abs_s
{
// meta
menu_t* menu; ///< The menu structure
menu_t* bgMenu; ///< The menu structure
menuManiaRenderer_t* menuManiaRenderer; ///< Renderer for the menu
font_t ibm; ///< The font used in the menu and game
sokoScreen_t screen; ///< The screen being displayed
font_t font_rodin;
font_t font_rodin_outline;
font_t font_righteous;
font_t font_righteous_outline;
sokoScreen_t screen; ///< The screen being displayed

char* levelFileText;
char* levelNames[SOKO_LEVEL_COUNT];
Expand Down Expand Up @@ -261,6 +267,10 @@ typedef struct soko_abs_s
soko_var_t loadNewLevelVariant;

int chosen_victory_message;

// Help page
uint32_t helpIdx;
uint32_t arrowBlinkTimer;
} soko_abs_t;

extern const char SOKO_TAG[];
Expand Down
183 changes: 183 additions & 0 deletions main/modes/games/soko/sokoHelp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
//==============================================================================
// Includes
//==============================================================================

#include "hdw-tft.h"
#include "sokoHelp.h"

//==============================================================================
// Defines
//==============================================================================

#define TEXT_MARGIN_L 18
#define TEXT_MARGIN_R 13

#define ARROW_BLINK_PERIOD 1000000

//==============================================================================
// Structs
//==============================================================================

typedef struct
{
const char* title;
const char* text;
} sokoHelpPage_t;

//==============================================================================
// Const data
//==============================================================================

static const char controlTitle[] = "Controls";
static const char boxTitle[] = "Boxes";

static const sokoHelpPage_t helpPages[] = {
hunterdyar marked this conversation as resolved.
Show resolved Hide resolved
{
.title = sokoModeName,
.text = "You are an Eye and your job is to paint the floors in twenty two rooms. Don't ask questions.",
},
{
.title = controlTitle,
.text = "Use the D-Pad to walk around the main hallway, enter rooms, and paint the floors.",
},
{
.title = controlTitle,
.text = "When painting a floor, you absolutely MUST NOT step on wet paint. If you do, you won't get paid.",
},
{
.title = controlTitle,
.text = "If you make a small mistake, you can press A to undo one step before anyone notices.",
},
{
.title = controlTitle,
.text
= "If you make a big mistake, you can press B to reset the entire room. Your boss will probably notice though.",
},
{
.title = controlTitle,
.text = "If you're frustrated and need a break from a room, you can press Start to return to the main hallway.",
},
{
.title = boxTitle,
.text = "Some jerk left orange boxes are on some floors. You can push them around to make sure all the floor "
"is painted.",
},
{
.title = boxTitle,
.text = "Purple boxes are like orange boxes, but sticky and gross. In the unlikely event that one is stuck to "
"you, try scraping it off.",
},
{
.title = boxTitle,
.text = "Red & purple boxes are highly toxic to touch. You can't push them directly, but maybe you can with "
"something else. Safety first.",
},
{
.title = sokoModeName,
.text = "Good luck and get painting!",
},
};

//==============================================================================
// Functions
//==============================================================================

/**
* @brief Draw the help menu
*
* @param soko The entire soko state
* @param elapsedUs The time elapsed since the last function call
*/
void drawSokoHelp(soko_abs_t* soko, int32_t elapsedUs)
{
// Set the title
soko->bgMenu->title = helpPages[soko->helpIdx].title;

// Draw background, without animation
drawMenuMania(soko->bgMenu, soko->menuManiaRenderer, 0);

// Draw text
paletteColor_t textColor = c000;
int16_t xOff = TEXT_MARGIN_L;
int16_t yOff = MANIA_TITLE_HEIGHT + 8;
drawTextWordWrap(&soko->font_rodin, textColor, helpPages[soko->helpIdx].text, &xOff, &yOff,
TFT_WIDTH - TEXT_MARGIN_R, TFT_HEIGHT);
xOff = TEXT_MARGIN_L;
yOff = MANIA_TITLE_HEIGHT + 8;

// Draw page numbers
char pageText[32];
snprintf(pageText, sizeof(pageText) - 1, "%" PRId32 "/%" PRId32 "", 1 + soko->helpIdx,
(int32_t)ARRAY_SIZE(helpPages));

int16_t tWidth = textWidth(&soko->font_rodin, pageText);
drawText(&soko->font_rodin, textColor, pageText, TFT_WIDTH - 30 - tWidth, TFT_HEIGHT - soko->font_rodin.height + 2);

// Blink the arrows
soko->arrowBlinkTimer += elapsedUs;
while (soko->arrowBlinkTimer >= ARROW_BLINK_PERIOD)
{
soko->arrowBlinkTimer -= ARROW_BLINK_PERIOD;
}

if (soko->arrowBlinkTimer < (ARROW_BLINK_PERIOD / 2))
{
// Draw arrows to indicate this can be scrolled
if (0 != soko->helpIdx)
{
// Draw left arrow if not on the first page
drawText(&soko->font_rodin, textColor, "<", 0, (TFT_HEIGHT - soko->font_rodin.height) / 2);
}

if ((ARRAY_SIZE(helpPages) - 1) != soko->helpIdx)
{
// Draw right arrow if not on the last page
drawText(&soko->font_rodin, textColor, ">", TFT_WIDTH - textWidth(&soko->font_rodin, ">"),
(TFT_HEIGHT - soko->font_rodin.height) / 2);
}
}
}

/**
* @brief Handle a button event on the help screen
*
* @param soko The entire soko state
* @param evt The button event to handle
*/
void buttonSokoHelp(soko_abs_t* soko, buttonEvt_t* evt)
{
if (evt->down)
{
switch (evt->button)
{
case PB_LEFT:
{
if (soko->helpIdx > 0)
{
soko->helpIdx--;
}
else
{
soko->screen = SOKO_MENU;
}
break;
}
case PB_RIGHT:
{
if (soko->helpIdx < ARRAY_SIZE(helpPages) - 1)
{
soko->helpIdx++;
}
else
{
soko->screen = SOKO_MENU;
}
break;
}
default:
{
break;
}
}
}
}
6 changes: 6 additions & 0 deletions main/modes/games/soko/sokoHelp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include "soko.h"

void buttonSokoHelp(soko_abs_t* sv, buttonEvt_t* evt);
void drawSokoHelp(soko_abs_t* sv, int32_t elapsedUs);
Loading
Loading