From 0e2fb6159171688a198f09ee19c4de36313719c7 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Fri, 15 Sep 2023 20:12:28 -0700 Subject: [PATCH 01/54] Title screen update Added title screen to act as an inbetween for non-networked games. Added sprites for the title screen Renamed ghost from enemy_d1 to lumbers_enemy_d1 --- .../{enemy_d1.png => lumbers_enemy_d1.png} | Bin .../{enemy_d2.png => lumbers_enemy_d2.png} | Bin assets/lumbers/lumbers_title.png | Bin 0 -> 601 bytes assets/lumbers/lumbers_title_attack_green.png | Bin 0 -> 289 bytes assets/lumbers/lumbers_title_attack_red.png | Bin 0 -> 286 bytes assets/lumbers/lumbers_title_attack_white.png | Bin 0 -> 284 bytes assets/lumbers/lumbers_title_panic_green.png | Bin 0 -> 311 bytes assets/lumbers/lumbers_title_panic_red.png | Bin 0 -> 303 bytes assets/lumbers/lumbers_title_panic_white.png | Bin 0 -> 300 bytes main/modes/lumberjack/lumberjack.c | 15 +- main/modes/lumberjack/lumberjack.h | 8 +- main/modes/lumberjack/lumberjackGame.c | 214 ++++++++++++------ main/modes/lumberjack/lumberjackGame.h | 1 + main/swadge2024.c | 6 +- 14 files changed, 166 insertions(+), 78 deletions(-) rename assets/lumbers/{enemy_d1.png => lumbers_enemy_d1.png} (100%) rename assets/lumbers/{enemy_d2.png => lumbers_enemy_d2.png} (100%) create mode 100644 assets/lumbers/lumbers_title.png create mode 100644 assets/lumbers/lumbers_title_attack_green.png create mode 100644 assets/lumbers/lumbers_title_attack_red.png create mode 100644 assets/lumbers/lumbers_title_attack_white.png create mode 100644 assets/lumbers/lumbers_title_panic_green.png create mode 100644 assets/lumbers/lumbers_title_panic_red.png create mode 100644 assets/lumbers/lumbers_title_panic_white.png diff --git a/assets/lumbers/enemy_d1.png b/assets/lumbers/lumbers_enemy_d1.png similarity index 100% rename from assets/lumbers/enemy_d1.png rename to assets/lumbers/lumbers_enemy_d1.png diff --git a/assets/lumbers/enemy_d2.png b/assets/lumbers/lumbers_enemy_d2.png similarity index 100% rename from assets/lumbers/enemy_d2.png rename to assets/lumbers/lumbers_enemy_d2.png diff --git a/assets/lumbers/lumbers_title.png b/assets/lumbers/lumbers_title.png new file mode 100644 index 0000000000000000000000000000000000000000..5c218f6e0329e2278a05d8a6e835a3de101fcda0 GIT binary patch literal 601 zcmV-f0;c_mP)Px%6G=otRCt{2np=TU@sTQZhRIDJxyHf3Rwh-x zKLKVt5FV%Y)6=hk^||e>`)?jdf2pm%1C-iU+a15(xW}pe^z>^W{qA{pbhQ27_z{g{ zE~)bW2>lfl`~RIi3J&KA+yPSlSqfg+SfAS73e^8i{0WZvN?beUMC+8A4%Y#V_OKa; z#Bhur+xT`c#W7YZUQ6R1!)iYRjbl>w_stABf01JfvGx&@qjhd$AI8e+DC3BGj8j}^ zWq5^2ci3LwWQE}vrd6rV0Dv_`bekD2eV2kUajaAEBj zNo=6B0im{4|I^_Xyr??V_Pus*DU?x<*S{dbt#C?CxHUE_J?;XcURd?`Boo7}aEdB} zjq0A29$AN2fi*qf$jY3;-N$g3f;Q91voTA(QJCqEd?X`&xnbMxVS`#)#v8T#_ef7X zt_IW)PXbTO>RdiJ$S1~h#^1!K(smBMwyvKpYZ6ZjUa>KuVFagTAztp>hq6afZu$9TWFcpslB nmTzKWJ!=PA+z-7+h--Wwf8zF8R}u;f00000NkvXXu0mjfUo9ZN literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_title_attack_green.png b/assets/lumbers/lumbers_title_attack_green.png new file mode 100644 index 0000000000000000000000000000000000000000..33955164f77e7cb508883684b36c084b625614f3 GIT binary patch literal 289 zcmV++0p9+JP)Px#+et)0R9J=Wmr)LcFbG7U*|XX+*~@l6+}$)SP^hJDjPFwiW@LQ5vDp+duf z1A1#7PN&IJ_9DHSKzrUARm4;_BQ+cm6Ik^SWggK>y&a#4 z|M(}pux%vuCiUtAC|7mQo9VGR!^%9G9znV(orVGGB|F5VJXRkRhcw}&tOFADS8eiZ ziR%S$1J!Qhw?1OZD;~FLc;wOa6o>S1@C-@8Er#U%TCo0Cjr0eDhj*SKZm~(;1dzW? nsC(F{p=vF9uRL6jUM;=>a^YYhAFpoj00000NkvXXu0mjf5`lU= literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_title_attack_red.png b/assets/lumbers/lumbers_title_attack_red.png new file mode 100644 index 0000000000000000000000000000000000000000..74e584350b0dca29b8e1c1f4720504a3b2a00a35 GIT binary patch literal 286 zcmV+(0pb3MP)Px#*hxe|R9J=WSJ4i`AP5ArZ}p@2S@*CtGYSY+>C*Hb^|-qrniio)Vb;*Vk$@9? zZyt$f$x~~wUR|J)bI&5G#aND*hzPv=kypcUWoq+OTB28~jZ7|ah|HsUnWy91@t^7+ z@s(*~(N5B+K7nymOU|xqa|V%lEE-AM)K0?z?vb4nT9e1?gKCo&oRqggD*viUeucPR z0I8wYX*}wYs6<@1W!RC&qNz6N!3R&147f#;c0UW=|Ed{%aCq#_Glg4B(rzTszfHJ3 k9Mo{N9{#R8lE$bO-yoS^h=Px#)=5M`R9J=WSHTU$APkGqjl}*Fbf@%DorE9>2?z94)z9L@ZZK5=wP4{H92^Z8 z;79#vJddBUm#EbkI=JQKiw29MAp;cU_p~Zb$W!g7=%s3wD$88!``0?~KhxFpYJ0u4lF{IU>h3LI%q(22TR{I&kBa*ZliR^z9X$_qk isW!r2Px#@kvBMR9J=Gm)i})APhw>RkvWNY>}C=1xsZP`qNYe`GLWtsOO8|Yaqs05FnEk zI{*ZOZ>^OywT>rQjnxcD4UmF>Tmh+z_cxX1uxHRQqIBV?}`8b002ov JPDHLkV1oU#j|Bh# literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_title_panic_red.png b/assets/lumbers/lumbers_title_panic_red.png new file mode 100644 index 0000000000000000000000000000000000000000..7796898a0d92e8992a9f19d6fb77fafb32f04b6c GIT binary patch literal 303 zcmV+~0nq-5P)Px#=}AOER9J=Gms=9UAP7Y-ovzhIv03}mbgCmS#nkEfGIBwK$Rq@vYS;mQ0=~Ug z)ATlJer64ipKSn8YbkbQ=24uXZ>QBX=xx&c%o+~AhKDPHO%=v}!87VW%*|UZ9?qN;Uq~7HR7{^vvH?# zOC_Czl;n4>99Gj*lA@=TdEI_NR^!&bw_<_z^_*!kl9ZO9Q&~w8;qU}yRi*k{67)Uk zOPesapRKT9ULyMz$=yHt%_H62=j~h8If;Qphfal^6g3002ovPDHLkV1l=D BgdhL_ literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_title_panic_white.png b/assets/lumbers/lumbers_title_panic_white.png new file mode 100644 index 0000000000000000000000000000000000000000..492a0e4bf0af077e233fd6a37cfab2bd96754417 GIT binary patch literal 300 zcmV+{0n`48P)Px#=1D|BR9J=GmrD-AAPhvuRgc8|Pmnvgo2DuVe{oXOw<36Kz%iB}=&)f201Ehy zT1_+Br1{Jm9zWXvfDg9gH=d9TP_gexh-SbeLpE-Gz(8h2TZU)XcfR3vG?Qx&t4B*Nwis;Wx$SrYW!sp$}M y`?>U4vLj_xt|duZWM-?b-Vy|uvEsp52BO+0000menu, lumberjackMenuMultiPlayerClient); lumberjack->menu = endSubMenu(lumberjack->menu); - addSingleItemToMenu(lumberjack->menu, lumberjackAttack); + lumberjack->menu = startSubMenu(lumberjack->menu, lumberjackAttack); + addSingleItemToMenu(lumberjack->menu, lumberjackMenuSinglePlayer); + addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerHost); + addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerClient); + lumberjack->menu = endSubMenu(lumberjack->menu); if (true) // Ignore this line { @@ -136,7 +140,7 @@ static void lumberjackExitMode(void) lumberjackExitGameMode(); p2pDeinit(&lumberjack->p2p); - freeFont(&lumberjack->ibm); + freeFont(&lumberjack->ibm); freeFont(&lumberjack->logbook); deinitMenu(lumberjack->menu); free(lumberjack); @@ -244,8 +248,11 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) void lumberjackSendAttack(int number) { - const uint8_t testMsg[] = {0x13}; - p2pSendMsg(&lumberjack->p2p, testMsg, ARRAY_SIZE(testMsg), lumberjackMsgTxCbFn); + if (lumberjack->networked) + { + const uint8_t testMsg[] = {0x13}; + p2pSendMsg(&lumberjack->p2p, testMsg, ARRAY_SIZE(testMsg), lumberjackMsgTxCbFn); + } } void lumberjackUpdateLocation(int ghostX, int ghostY, int frame) diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index e3b2655bf..b541ac519 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -58,6 +58,7 @@ typedef struct typedef struct { bool loaded; + bool onTitle; font_t ibm; lumberjack_t* lumberjackMain; menu_t* menu; @@ -77,11 +78,16 @@ typedef struct wsg_t floorTiles[20]; wsg_t animationTiles[20]; + wsg_t title; + wsg_t subtitle_red; + wsg_t subtitle_green; + wsg_t subtitle_white; + lumberjackTile_t tile[400]; uint8_t anim[400]; wsg_t enemySprites[21]; - wsg_t playerSprites[54]; + wsg_t playerSprites[16]; wsg_t alertSprite; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 48965a529..af98afc99 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -29,6 +29,7 @@ static lumberjackTile_t* lumberjackGetTile(int x, int y); static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs); static bool lumberjackIsCollisionTile(int index); +void DrawTitle(void); void DrawGame(void); lumberjackVars_t* lumv; @@ -47,6 +48,26 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->liquidAnimationFrame = 0; lumv->loaded = false; lumv->gameType = main->gameMode; + lumv->onTitle = true; + + ESP_LOGI(LUM_TAG, "Load Title"); + loadWsg("lumbers_title.wsg", &lumv->title, true); + + if (main->screen == LUMBERJACK_A) + { + loadWsg("lumbers_title_panic_red.wsg", &lumv->subtitle_red, true); + loadWsg("lumbers_title_panic_green.wsg", &lumv->subtitle_green, true); + loadWsg("lumbers_title_panic_white.wsg", &lumv->subtitle_white, true); + } + + if (main->screen == LUMBERJACK_B) + { + + loadWsg("lumbers_title_attack_red.wsg", &lumv->subtitle_red, true); + loadWsg("lumbers_title_attack_green.wsg", &lumv->subtitle_green, true); + loadWsg("lumbers_title_attack_white.wsg", &lumv->subtitle_white, true); + } + ESP_LOGI(LUM_TAG, "Loading floor Tiles"); loadWsg("bottom_floor1.wsg", &lumv->floorTiles[0], true); @@ -75,64 +96,68 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("water_floor_b4.wsg", &lumv->animationTiles[11], true); ESP_LOGI(LUM_TAG, "Loading Characters"); - loadWsg("lumbers_red_1.wsg", &lumv->playerSprites[0], true); - loadWsg("lumbers_red_2.wsg", &lumv->playerSprites[1], true); - loadWsg("lumbers_red_3.wsg", &lumv->playerSprites[2], true); - loadWsg("lumbers_red_4.wsg", &lumv->playerSprites[3], - true); // These two things break 3 seconds after the game loads - loadWsg("lumbers_red_5.wsg", &lumv->playerSprites[4], true); // I think the memory is being replaces - loadWsg("lumbers_red_6.wsg", &lumv->playerSprites[5], true); - loadWsg("lumbers_red_7.wsg", &lumv->playerSprites[6], true); - loadWsg("lumbers_red_8.wsg", &lumv->playerSprites[7], true); - loadWsg("lumbers_red_9.wsg", &lumv->playerSprites[8], true); - loadWsg("lumbers_red_10.wsg", &lumv->playerSprites[9], true); - loadWsg("lumbers_red_11.wsg", &lumv->playerSprites[10], true); - loadWsg("lumbers_red_12.wsg", &lumv->playerSprites[11], true); - loadWsg("lumbers_red_13.wsg", &lumv->playerSprites[12], true); - loadWsg("lumbers_red_14.wsg", &lumv->playerSprites[13], true); - loadWsg("lumbers_red_15.wsg", &lumv->playerSprites[14], true); - loadWsg("lumbers_red_16.wsg", &lumv->playerSprites[15], true); - loadWsg("lumbers_red_17.wsg", &lumv->playerSprites[16], true); - - loadWsg("lumbers_green_1.wsg", &lumv->playerSprites[17], true); - loadWsg("lumbers_green_2.wsg", &lumv->playerSprites[18], true); - loadWsg("lumbers_green_3.wsg", &lumv->playerSprites[19], true); - loadWsg("lumbers_green_4.wsg", &lumv->playerSprites[20], true); - loadWsg("lumbers_green_5.wsg", &lumv->playerSprites[21], true); - loadWsg("lumbers_green_6.wsg", &lumv->playerSprites[22], true); - loadWsg("lumbers_green_7.wsg", &lumv->playerSprites[23], true); - loadWsg("lumbers_green_8.wsg", &lumv->playerSprites[24], true); - loadWsg("lumbers_green_9.wsg", &lumv->playerSprites[25], true); - loadWsg("lumbers_green_10.wsg", &lumv->playerSprites[26], true); - loadWsg("lumbers_green_11.wsg", &lumv->playerSprites[27], true); - loadWsg("lumbers_green_12.wsg", &lumv->playerSprites[28], true); - loadWsg("lumbers_green_13.wsg", &lumv->playerSprites[29], true); - loadWsg("lumbers_green_14.wsg", &lumv->playerSprites[30], true); - loadWsg("lumbers_green_15.wsg", &lumv->playerSprites[31], true); - loadWsg("lumbers_green_16.wsg", &lumv->playerSprites[32], true); - loadWsg("lumbers_green_17.wsg", &lumv->playerSprites[33], true); - - loadWsg("secret_swadgeland_1.wsg", &lumv->playerSprites[34], true); - loadWsg("secret_swadgeland_2.wsg", &lumv->playerSprites[35], true); - loadWsg("secret_swadgeland_3.wsg", &lumv->playerSprites[36], true); - loadWsg("secret_swadgeland_4.wsg", &lumv->playerSprites[37], true); - loadWsg("secret_swadgeland_5.wsg", &lumv->playerSprites[38], true); - loadWsg("secret_swadgeland_6.wsg", &lumv->playerSprites[39], true); - loadWsg("secret_swadgeland_7.wsg", &lumv->playerSprites[40], true); - loadWsg("secret_swadgeland_8.wsg", &lumv->playerSprites[41], true); - loadWsg("secret_swadgeland_9.wsg", &lumv->playerSprites[42], true); - loadWsg("secret_swadgeland_10.wsg", &lumv->playerSprites[43], true); - loadWsg("secret_swadgeland_11.wsg", &lumv->playerSprites[44], true); - loadWsg("secret_swadgeland_12.wsg", &lumv->playerSprites[45], true); - loadWsg("secret_swadgeland_13.wsg", &lumv->playerSprites[46], true); - loadWsg("secret_swadgeland_14.wsg", &lumv->playerSprites[47], true); - loadWsg("secret_swadgeland_15.wsg", &lumv->playerSprites[48], true); - loadWsg("secret_swadgeland_16.wsg", &lumv->playerSprites[49], true); - loadWsg("secret_swadgeland_17.wsg", &lumv->playerSprites[50], true); - loadWsg("secret_swadgeland_18.wsg", &lumv->playerSprites[51], true); - loadWsg("secret_swadgeland_19.wsg", &lumv->playerSprites[52], true); - loadWsg("secret_swadgeland_20.wsg", &lumv->playerSprites[53], true); - loadWsg("secret_swadgeland_21.wsg", &lumv->playerSprites[54], true); + + if (characterIndex == 0) + { + loadWsg("lumbers_red_1.wsg", &lumv->playerSprites[0], true); + loadWsg("lumbers_red_2.wsg", &lumv->playerSprites[1], true); + loadWsg("lumbers_red_3.wsg", &lumv->playerSprites[2], true); + loadWsg("lumbers_red_4.wsg", &lumv->playerSprites[3], true); + loadWsg("lumbers_red_5.wsg", &lumv->playerSprites[4], true); + loadWsg("lumbers_red_6.wsg", &lumv->playerSprites[5], true); + loadWsg("lumbers_red_7.wsg", &lumv->playerSprites[6], true); + loadWsg("lumbers_red_8.wsg", &lumv->playerSprites[7], true); + loadWsg("lumbers_red_9.wsg", &lumv->playerSprites[8], true); + loadWsg("lumbers_red_10.wsg", &lumv->playerSprites[9], true); + loadWsg("lumbers_red_11.wsg", &lumv->playerSprites[10], true); + loadWsg("lumbers_red_12.wsg", &lumv->playerSprites[11], true); + loadWsg("lumbers_red_13.wsg", &lumv->playerSprites[12], true); + loadWsg("lumbers_red_14.wsg", &lumv->playerSprites[13], true); + loadWsg("lumbers_red_15.wsg", &lumv->playerSprites[14], true); + loadWsg("lumbers_red_16.wsg", &lumv->playerSprites[15], true); + loadWsg("lumbers_red_17.wsg", &lumv->playerSprites[16], true); + } + else if (characterIndex == 1) + { + loadWsg("lumbers_green_1.wsg", &lumv->playerSprites[0], true); + loadWsg("lumbers_green_2.wsg", &lumv->playerSprites[1], true); + loadWsg("lumbers_green_3.wsg", &lumv->playerSprites[2], true); + loadWsg("lumbers_green_4.wsg", &lumv->playerSprites[3], true); + loadWsg("lumbers_green_5.wsg", &lumv->playerSprites[4], true); + loadWsg("lumbers_green_6.wsg", &lumv->playerSprites[5], true); + loadWsg("lumbers_green_7.wsg", &lumv->playerSprites[6], true); + loadWsg("lumbers_green_8.wsg", &lumv->playerSprites[7], true); + loadWsg("lumbers_green_9.wsg", &lumv->playerSprites[8], true); + loadWsg("lumbers_green_10.wsg", &lumv->playerSprites[9], true); + loadWsg("lumbers_green_11.wsg", &lumv->playerSprites[10], true); + loadWsg("lumbers_green_12.wsg", &lumv->playerSprites[11], true); + loadWsg("lumbers_green_13.wsg", &lumv->playerSprites[12], true); + loadWsg("lumbers_green_14.wsg", &lumv->playerSprites[13], true); + loadWsg("lumbers_green_15.wsg", &lumv->playerSprites[14], true); + loadWsg("lumbers_green_16.wsg", &lumv->playerSprites[15], true); + loadWsg("lumbers_green_17.wsg", &lumv->playerSprites[16], true); + } + else if (characterIndex == 2) + { + + loadWsg("secret_swadgeland_1.wsg", &lumv->playerSprites[0], true); + loadWsg("secret_swadgeland_2.wsg", &lumv->playerSprites[1], true); + loadWsg("secret_swadgeland_3.wsg", &lumv->playerSprites[2], true); + loadWsg("secret_swadgeland_4.wsg", &lumv->playerSprites[3], true); + loadWsg("secret_swadgeland_5.wsg", &lumv->playerSprites[4], true); + loadWsg("secret_swadgeland_6.wsg", &lumv->playerSprites[5], true); + loadWsg("secret_swadgeland_7.wsg", &lumv->playerSprites[6], true); + loadWsg("secret_swadgeland_8.wsg", &lumv->playerSprites[7], true); + loadWsg("secret_swadgeland_9.wsg", &lumv->playerSprites[8], true); + loadWsg("secret_swadgeland_10.wsg", &lumv->playerSprites[9], true); + loadWsg("secret_swadgeland_11.wsg", &lumv->playerSprites[10], true); + loadWsg("secret_swadgeland_12.wsg", &lumv->playerSprites[11], true); + loadWsg("secret_swadgeland_13.wsg", &lumv->playerSprites[12], true); + loadWsg("secret_swadgeland_14.wsg", &lumv->playerSprites[13], true); + loadWsg("secret_swadgeland_15.wsg", &lumv->playerSprites[14], true); + loadWsg("secret_swadgeland_16.wsg", &lumv->playerSprites[15], true); + loadWsg("secret_swadgeland_17.wsg", &lumv->playerSprites[16], true); + } ESP_LOGI(LUM_TAG, "Loading Enemies"); loadWsg("enemy_a1.wsg", &lumv->enemySprites[0], true); @@ -168,7 +193,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumberjackSetupLevel(characterIndex); } - ESP_LOGI(LUM_TAG, "height %d", TFT_HEIGHT); + ESP_LOGI(LUM_TAG, "width %d height %d",TFT_WIDTH, TFT_HEIGHT); } void lumberjackSetupLevel(int characterIndex) @@ -198,17 +223,27 @@ void lumberjackSetupLevel(int characterIndex) } const uint8_t level[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 3, 3, 4, 4, 0, - 0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 5, 0, 0, 0, 0, 0, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 10, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4, 4, 3, 3, 4, 4, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 0, 0, 0, + 0, 0, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 10, 0, 0, 0, }; const uint8_t ani[] = { @@ -245,8 +280,33 @@ void restartLevel(void) lumberjackRespawn(lumv->localPlayer); } +void lumberjackTitleLoop(int64_t elapsedUs) +{ + + // Update State + buttonEvt_t evt = {0}; + while (checkButtonQueueWrapper(&evt)) + { + lumv->btnState = evt.state; + } + + if (lumv->btnState & PB_A) + { + lumv->onTitle = false; + } + + DrawTitle(); +} + void lumberjackGameLoop(int64_t elapsedUs) { + + if (lumv->onTitle == true) + { + lumberjackTitleLoop(elapsedUs); + return; + } + baseMode(elapsedUs); // If networked @@ -478,6 +538,18 @@ void baseMode(int64_t elapsedUs) lumv->yOffset = LUMBERJACK_SCREEN_Y_MAX; } +void DrawTitle(void) +{ + drawWsgSimple(&lumv->title, (TFT_WIDTH / 2) - 51, (TFT_HEIGHT / 2) - 48); + drawWsgSimple(&lumv->subtitle_red, (TFT_WIDTH/2)- 36, (TFT_HEIGHT/2) -9); + for (int i = 0; i < 18; i++) + { + drawWsgSimple(&lumv->floorTiles[1], i * 16, 208); + drawWsgSimple(&lumv->floorTiles[7], i * 16, 224); + } + +} + void DrawGame(void) { // Draw section @@ -517,7 +589,7 @@ void DrawGame(void) // ESP_LOGI(LUM_TAG, "DEAD %d", currentFrame); } - lumv->localPlayer->drawFrame = lumv->localPlayer->spriteOffset + currentFrame; + lumv->localPlayer->drawFrame = currentFrame; // This is where it breaks. When it tries to play frame 3 or 4 it crashes. drawWsg(&lumv->playerSprites[lumv->localPlayer->drawFrame], lumv->localPlayer->x - 4, diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index f5646a930..14421611a 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -10,6 +10,7 @@ void lumberjackDoControls(void); void lumberjackTileMap(void); void lumberjackUpdate(int64_t elapseUs); +void lumberjackTitleLoop(int64_t elapsedUs); void lumberjackGameLoop(int64_t elapsedUs); void lumberjackUpdateLocation(int ghostX, int ghostY, int frame); void lumberjackUpdateRemote(int remoteX, int remoteY, int remoteFrame); diff --git a/main/swadge2024.c b/main/swadge2024.c index b9c04b542..3330b074d 100644 --- a/main/swadge2024.c +++ b/main/swadge2024.c @@ -378,7 +378,6 @@ void app_main(void) { // Call the overlay mode's main loop if there is one quickSettingsMode.fnMainLoop(tNowUs - tLastMainLoopCall); - } else { @@ -388,7 +387,6 @@ void app_main(void) tLastMainLoopCall = tNowUs; } - // If the menu button is being held if (0 != timeExitPressed && !showQuickSettings) { @@ -435,6 +433,10 @@ void app_main(void) { int16_t r = QUICK_SETTINGS_PANEL_R; int16_t numPx = (tHeldUs * (QUICK_SETTINGS_PANEL_W - r * 2)) / PAUSE_TIME_US; + + if (numPx < 0) + numPx = abs(numPx); + drawCircleFilled(QUICK_SETTINGS_PANEL_X + r, 0, r, c333); fillDisplayArea(QUICK_SETTINGS_PANEL_X + r, 0, QUICK_SETTINGS_PANEL_X + r + numPx, r + 1, c333); drawCircleFilled(QUICK_SETTINGS_PANEL_X + numPx + r, 0, r, c333); From f126adc863eefcb4e0d9774daa4c87fa6b3476eb Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 16 Sep 2023 00:17:03 -0700 Subject: [PATCH 02/54] External Map loader Renamed enemies a b c to be more aligned with game Made map loadable via file Made map width a hard number of 18 No H scrolling pls Made map height dynamic as it's loaded via file now Fixed entity going off of screen bug that was almost introduced --- assets/lumbers/lumberjacks_panic_1.bin | Bin 0 -> 390 bytes assets/lumbers/lumberjacks_panic_2.bin | Bin 0 -> 390 bytes .../lumbers/{alert.png => lumbers_alert.png} | Bin .../{enemy_a1.png => lumbers_enemy_a1.png} | Bin .../{enemy_a2.png => lumbers_enemy_a2.png} | Bin .../{enemy_a3.png => lumbers_enemy_a3.png} | Bin .../{enemy_a4.png => lumbers_enemy_a4.png} | Bin .../{enemy_a5.png => lumbers_enemy_a5.png} | Bin .../{enemy_a6.png => lumbers_enemy_a6.png} | Bin .../{enemy_a7.png => lumbers_enemy_a7.png} | Bin .../{enemy_b1.png => lumbers_enemy_b1.png} | Bin .../{enemy_b2.png => lumbers_enemy_b2.png} | Bin .../{enemy_b3.png => lumbers_enemy_b3.png} | Bin .../{enemy_b4.png => lumbers_enemy_b4.png} | Bin .../{enemy_b5.png => lumbers_enemy_b5.png} | Bin .../{enemy_b6.png => lumbers_enemy_b6.png} | Bin .../{enemy_b7.png => lumbers_enemy_b7.png} | Bin .../{enemy_c1.png => lumbers_enemy_c1.png} | Bin .../{enemy_c2.png => lumbers_enemy_c2.png} | Bin .../{enemy_c3.png => lumbers_enemy_c3.png} | Bin .../{enemy_c4.png => lumbers_enemy_c4.png} | Bin .../{enemy_c5.png => lumbers_enemy_c5.png} | Bin .../{enemy_c6.png => lumbers_enemy_c6.png} | Bin .../{enemy_c7.png => lumbers_enemy_c7.png} | Bin main/modes/lumberjack/lumberjack.h | 3 +- main/modes/lumberjack/lumberjackGame.c | 202 ++++++++++-------- 26 files changed, 116 insertions(+), 89 deletions(-) create mode 100644 assets/lumbers/lumberjacks_panic_1.bin create mode 100644 assets/lumbers/lumberjacks_panic_2.bin rename assets/lumbers/{alert.png => lumbers_alert.png} (100%) rename assets/lumbers/{enemy_a1.png => lumbers_enemy_a1.png} (100%) rename assets/lumbers/{enemy_a2.png => lumbers_enemy_a2.png} (100%) rename assets/lumbers/{enemy_a3.png => lumbers_enemy_a3.png} (100%) rename assets/lumbers/{enemy_a4.png => lumbers_enemy_a4.png} (100%) rename assets/lumbers/{enemy_a5.png => lumbers_enemy_a5.png} (100%) rename assets/lumbers/{enemy_a6.png => lumbers_enemy_a6.png} (100%) rename assets/lumbers/{enemy_a7.png => lumbers_enemy_a7.png} (100%) rename assets/lumbers/{enemy_b1.png => lumbers_enemy_b1.png} (100%) rename assets/lumbers/{enemy_b2.png => lumbers_enemy_b2.png} (100%) rename assets/lumbers/{enemy_b3.png => lumbers_enemy_b3.png} (100%) rename assets/lumbers/{enemy_b4.png => lumbers_enemy_b4.png} (100%) rename assets/lumbers/{enemy_b5.png => lumbers_enemy_b5.png} (100%) rename assets/lumbers/{enemy_b6.png => lumbers_enemy_b6.png} (100%) rename assets/lumbers/{enemy_b7.png => lumbers_enemy_b7.png} (100%) rename assets/lumbers/{enemy_c1.png => lumbers_enemy_c1.png} (100%) rename assets/lumbers/{enemy_c2.png => lumbers_enemy_c2.png} (100%) rename assets/lumbers/{enemy_c3.png => lumbers_enemy_c3.png} (100%) rename assets/lumbers/{enemy_c4.png => lumbers_enemy_c4.png} (100%) rename assets/lumbers/{enemy_c5.png => lumbers_enemy_c5.png} (100%) rename assets/lumbers/{enemy_c6.png => lumbers_enemy_c6.png} (100%) rename assets/lumbers/{enemy_c7.png => lumbers_enemy_c7.png} (100%) diff --git a/assets/lumbers/lumberjacks_panic_1.bin b/assets/lumbers/lumberjacks_panic_1.bin new file mode 100644 index 0000000000000000000000000000000000000000..e389be87b2ecf6ba753536a3444d7606388f9d7c GIT binary patch literal 390 zcmWe-W`F=@W_~D(Vu}R +#include +#include +#include + //============================================================================== // Defines //============================================================================== @@ -25,10 +34,14 @@ #define LUMBERJACK_SCREEN_Y_MIN -16 #define LUMBERJACK_SCREEN_Y_MAX 96 +#define LUMBERJACK_MAP_WIDTH 18 + static lumberjackTile_t* lumberjackGetTile(int x, int y); static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs); static bool lumberjackIsCollisionTile(int index); +bool lumberjackLoadLevel(int index); + void DrawTitle(void); void DrawGame(void); @@ -48,7 +61,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->liquidAnimationFrame = 0; lumv->loaded = false; lumv->gameType = main->gameMode; - lumv->onTitle = true; + lumv->onTitle = true; ESP_LOGI(LUM_TAG, "Load Title"); loadWsg("lumbers_title.wsg", &lumv->title, true); @@ -160,29 +173,29 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) } ESP_LOGI(LUM_TAG, "Loading Enemies"); - loadWsg("enemy_a1.wsg", &lumv->enemySprites[0], true); - loadWsg("enemy_a2.wsg", &lumv->enemySprites[1], true); - loadWsg("enemy_a3.wsg", &lumv->enemySprites[2], true); - loadWsg("enemy_a4.wsg", &lumv->enemySprites[3], true); - loadWsg("enemy_a5.wsg", &lumv->enemySprites[4], true); - loadWsg("enemy_a6.wsg", &lumv->enemySprites[5], true); - loadWsg("enemy_a7.wsg", &lumv->enemySprites[6], true); - loadWsg("enemy_b1.wsg", &lumv->enemySprites[7], true); - loadWsg("enemy_b2.wsg", &lumv->enemySprites[8], true); - loadWsg("enemy_b3.wsg", &lumv->enemySprites[9], true); - loadWsg("enemy_b4.wsg", &lumv->enemySprites[10], true); - loadWsg("enemy_b5.wsg", &lumv->enemySprites[11], true); - loadWsg("enemy_b6.wsg", &lumv->enemySprites[12], true); - loadWsg("enemy_b7.wsg", &lumv->enemySprites[13], true); - loadWsg("enemy_c1.wsg", &lumv->enemySprites[14], true); - loadWsg("enemy_c2.wsg", &lumv->enemySprites[15], true); - loadWsg("enemy_c3.wsg", &lumv->enemySprites[16], true); - loadWsg("enemy_c4.wsg", &lumv->enemySprites[17], true); - loadWsg("enemy_c5.wsg", &lumv->enemySprites[18], true); - loadWsg("enemy_c6.wsg", &lumv->enemySprites[19], true); - loadWsg("enemy_c7.wsg", &lumv->enemySprites[20], true); - - loadWsg("alert.wsg", &lumv->alertSprite, true); + loadWsg("lumbers_enemy_a1.wsg", &lumv->enemySprites[0], true); + loadWsg("lumbers_enemy_a2.wsg", &lumv->enemySprites[1], true); + loadWsg("lumbers_enemy_a3.wsg", &lumv->enemySprites[2], true); + loadWsg("lumbers_enemy_a4.wsg", &lumv->enemySprites[3], true); + loadWsg("lumbers_enemy_a5.wsg", &lumv->enemySprites[4], true); + loadWsg("lumbers_enemy_a6.wsg", &lumv->enemySprites[5], true); + loadWsg("lumbers_enemy_a7.wsg", &lumv->enemySprites[6], true); + loadWsg("lumbers_enemy_b1.wsg", &lumv->enemySprites[7], true); + loadWsg("lumbers_enemy_b2.wsg", &lumv->enemySprites[8], true); + loadWsg("lumbers_enemy_b3.wsg", &lumv->enemySprites[9], true); + loadWsg("lumbers_enemy_b4.wsg", &lumv->enemySprites[10], true); + loadWsg("lumbers_enemy_b5.wsg", &lumv->enemySprites[11], true); + loadWsg("lumbers_enemy_b6.wsg", &lumv->enemySprites[12], true); + loadWsg("lumbers_enemy_b7.wsg", &lumv->enemySprites[13], true); + loadWsg("lumbers_enemy_c1.wsg", &lumv->enemySprites[14], true); + loadWsg("lumbers_enemy_c2.wsg", &lumv->enemySprites[15], true); + loadWsg("lumbers_enemy_c3.wsg", &lumv->enemySprites[16], true); + loadWsg("lumbers_enemy_c4.wsg", &lumv->enemySprites[17], true); + loadWsg("lumbers_enemy_c5.wsg", &lumv->enemySprites[18], true); + loadWsg("lumbers_enemy_c6.wsg", &lumv->enemySprites[19], true); + loadWsg("lumbers_enemy_c7.wsg", &lumv->enemySprites[20], true); + + loadWsg("lumbers_alert.wsg", &lumv->alertSprite, true); if (lumv->gameType == LUMBERJACK_MODE_ATTACK) { @@ -196,11 +209,68 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) ESP_LOGI(LUM_TAG, "width %d height %d",TFT_WIDTH, TFT_HEIGHT); } +bool lumberjackLoadLevel(int index) +{ + char* fname = "lumberjacks_panic_1.bin"; + bool fileExists = false; + DIR* d; + d = opendir("./spiffs_image/"); + if (d) + { + struct dirent* dir; + while ((dir = readdir(d)) != NULL) + { + if (0 == strcmp(dir->d_name, fname)) + { + fileExists = true; + break; + } + } + closedir(d); + } + + if (false == fileExists) + { + ESP_LOGE(LUM_TAG, "No file \"%s\" found!", fname); + return false; + } + + size_t ms; + uint8_t *buffer = spiffsReadFile(fname, &ms, false); + + ESP_LOGI(LUM_TAG, "HEIGHT = %d", (int)buffer[0]); + // Buffer 0 = map height + lumv->tile = (lumberjackTile_t*)malloc((int)buffer[0] * LUMBERJACK_MAP_WIDTH * sizeof(lumberjackTile_t)); + lumv->currentMapHeight = (int)buffer[0]; + for (int i = 0; i < lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH; i++) + { + lumv->tile[i].index = -1; + lumv->tile[i].x = i % LUMBERJACK_MAP_WIDTH; + lumv->tile[i].y = i / LUMBERJACK_MAP_WIDTH; + lumv->tile[i].type = (int)buffer[i+12]; + lumv->tile[i].offset = 0; + lumv->tile[i].offset_time = 0; + + if (i < 10) + { + ESP_LOGI(LUM_TAG, "Tile = %d", lumv->tile[i].x); + } + + } + + //lumv->tile = &level; + + return true; +} + void lumberjackSetupLevel(int characterIndex) { + + + bool levelLoaded = lumberjackLoadLevel(0); + // This all to be loaded externally lumv->yOffset = 0; - lumv->currentMapHeight = 21; lumv->lives = 3; lumv->spawnIndex = 0; lumv->spawnTimer = 2750; @@ -222,44 +292,7 @@ void lumberjackSetupLevel(int characterIndex) sprintf(lumv->enemy[eSpawnIndex]->name, "Enemy %d", eSpawnIndex); } - const uint8_t level[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 4, 3, 3, 4, 4, 0, 0, 0, 0, 0, 0, - 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 0, 0, 0, - 0, 0, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 10, 0, 0, 0, - }; - - const uint8_t ani[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 3, 1, 3, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, - }; - +/* for (int tileIndex = 0; tileIndex < ARRAY_SIZE(ani); tileIndex++) { lumv->anim[tileIndex] = ani[tileIndex]; @@ -267,8 +300,7 @@ void lumberjackSetupLevel(int characterIndex) lumv->tile[tileIndex].x = tileIndex % 18; lumv->tile[tileIndex].y = tileIndex / 18; lumv->tile[tileIndex].type = level[tileIndex]; - } - + }*/ ESP_LOGI(LUM_TAG, "LOADED"); } @@ -380,7 +412,6 @@ void baseMode(int64_t elapsedUs) lumberjackCollisionCheckTiles[colTileIndex].type = -1; lumberjackCollisionCheckTiles[colTileIndex].x = -1; lumberjackCollisionCheckTiles[colTileIndex].y = -1; - lumberjackCollisionCheckTiles[colTileIndex].collision = -1; lumberjackCollisionCheckTiles[colTileIndex].index = -1; lumberjackCollisionCheckTiles[colTileIndex].offset = 0; lumberjackCollisionCheckTiles[colTileIndex].offset_time = 0; @@ -542,7 +573,7 @@ void DrawTitle(void) { drawWsgSimple(&lumv->title, (TFT_WIDTH / 2) - 51, (TFT_HEIGHT / 2) - 48); drawWsgSimple(&lumv->subtitle_red, (TFT_WIDTH/2)- 36, (TFT_HEIGHT/2) -9); - for (int i = 0; i < 18; i++) + for (int i = 0; i < LUMBERJACK_MAP_WIDTH; i++) { drawWsgSimple(&lumv->floorTiles[1], i * 16, 208); drawWsgSimple(&lumv->floorTiles[7], i * 16, 224); @@ -887,12 +918,10 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs void lumberjackUpdate(int64_t elapseUs) { - for (int tileIndex = 0; tileIndex < ARRAY_SIZE(lumv->tile); tileIndex++) + for (int tileIndex = 0; tileIndex < lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH; tileIndex++) { if (lumv->tile[tileIndex].offset > 0) { - // ESP_LOGI(LUM_TAG, "Update %d",lumv->tile[tileIndex].offset); - lumv->tile[tileIndex].offset_time -= elapseUs; if (lumv->tile[tileIndex].offset_time < 0) { @@ -905,24 +934,17 @@ void lumberjackUpdate(int64_t elapseUs) void lumberjackTileMap(void) { - // TODO: Stop drawing any area of the map that is off screen - for (int y = 0; y < 21; y++) + for (int y = 0; y < lumv->currentMapHeight; y++) { - for (int x = 0; x < 18; x++) + for (int x = 0; x < LUMBERJACK_MAP_WIDTH; x++) { - int index = (y * 18) + x; + int index = (y * LUMBERJACK_MAP_WIDTH) + x; + int tileIndex = lumv->tile[index].type; - int animIndex = lumv->anim[index]; int offset = lumv->tile[index].offset; if ((y * 16) - lumv->yOffset >= -16) { - if (animIndex > 0 && animIndex < 4) - { - drawWsgSimple(&lumv->animationTiles[((animIndex - 1) * 4) + (lumv->liquidAnimationFrame % 4)], - x * 16, (y * 16) - lumv->yOffset + 8 - offset); - } - if (tileIndex > 0 && tileIndex < 13) { if (tileIndex < 11) @@ -1026,15 +1048,21 @@ static lumberjackTile_t* lumberjackGetTile(int x, int y) // int test = -1; for (int colTileIndex = 0; colTileIndex < 32; colTileIndex++) { + if ((ty * LUMBERJACK_MAP_WIDTH) + tx >= lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH) + { + //Don't calculate if entity is going off screen + continue; + } + if (lumberjackCollisionCheckTiles[colTileIndex].type == -1) { - if (lumberjackCollisionCheckTiles[colTileIndex].index == (ty * 18) + tx) + if (lumberjackCollisionCheckTiles[colTileIndex].index == (ty * LUMBERJACK_MAP_WIDTH) + tx) return &lumberjackCollisionCheckTiles[colTileIndex]; - lumberjackCollisionCheckTiles[colTileIndex].index = (ty * 18) + tx; + lumberjackCollisionCheckTiles[colTileIndex].index = (ty * LUMBERJACK_MAP_WIDTH) + tx; lumberjackCollisionCheckTiles[colTileIndex].x = tx; lumberjackCollisionCheckTiles[colTileIndex].y = ty; - lumberjackCollisionCheckTiles[colTileIndex].type = lumv->tile[(ty * 18) + tx].type; + lumberjackCollisionCheckTiles[colTileIndex].type = lumv->tile[(ty * LUMBERJACK_MAP_WIDTH) + tx].type; return &lumberjackCollisionCheckTiles[colTileIndex]; } @@ -1085,10 +1113,10 @@ void lumberjackDetectBump(lumberjackTile_t* tile) if (ty > lumv->currentMapHeight) ty = lumv->currentMapHeight; - lumberjackTile_t* tileA = &lumv->tile[(ty * 18) + tx]; - lumberjackTile_t* tileB = &lumv->tile[(ty * 18) + tx2]; + lumberjackTile_t* tileA = &lumv->tile[(ty * LUMBERJACK_MAP_WIDTH) + tx]; + lumberjackTile_t* tileB = &lumv->tile[(ty * LUMBERJACK_MAP_WIDTH) + tx2]; - if ((tileA != NULL && (ty * 18) + tx == tile->index) || (tileB != NULL && (ty * 18) + tx2 == tile->index)) + if ((tileA != NULL && (ty * LUMBERJACK_MAP_WIDTH) + tx == tile->index) || (tileB != NULL && (ty * LUMBERJACK_MAP_WIDTH) + tx2 == tile->index)) { enemy->vy = -20; enemy->onGround = false; From ca52dca70a49fdd175a6de17830d191771043753 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 16 Sep 2023 18:15:39 -0700 Subject: [PATCH 03/54] File format updated Added axe or ax block, doesn't do anything yet. Updated level bin file Fixed title, because Lumber Jack is two words. Made enemies file loadable (up to 64) Made player spawn location file loadable Made axe block location file loadable (up to 8) Fixed enemy spawn time --- assets/lumbers/lumberjacks_panic_1.bin | Bin 390 -> 398 bytes assets/lumbers/lumbers_green_ax_block.png | Bin 0 -> 1091 bytes assets/lumbers/lumbers_green_ax_block1.png | Bin 0 -> 1028 bytes assets/lumbers/lumbers_green_ax_block2.png | Bin 0 -> 1031 bytes assets/lumbers/lumbers_green_ax_block3.png | Bin 0 -> 1031 bytes assets/lumbers/lumbers_green_ax_block4.png | Bin 0 -> 1026 bytes assets/lumbers/lumbers_green_ax_block5.png | Bin 0 -> 1021 bytes assets/lumbers/lumbers_green_ax_block6.png | Bin 0 -> 1025 bytes assets/lumbers/lumbers_green_ax_block7.png | Bin 0 -> 1026 bytes assets/lumbers/lumbers_normal_ax_block1.png | Bin 0 -> 1026 bytes assets/lumbers/lumbers_normal_ax_block2.png | Bin 0 -> 1030 bytes assets/lumbers/lumbers_normal_ax_block3.png | Bin 0 -> 1030 bytes assets/lumbers/lumbers_normal_ax_block4.png | Bin 0 -> 1028 bytes assets/lumbers/lumbers_normal_ax_block5.png | Bin 0 -> 1022 bytes assets/lumbers/lumbers_normal_ax_block6.png | Bin 0 -> 1026 bytes assets/lumbers/lumbers_normal_ax_block7.png | Bin 0 -> 1026 bytes assets/lumbers/lumbers_red_ax_block1.png | Bin 0 -> 1026 bytes assets/lumbers/lumbers_red_ax_block2.png | Bin 0 -> 1031 bytes assets/lumbers/lumbers_red_ax_block3.png | Bin 0 -> 1030 bytes assets/lumbers/lumbers_red_ax_block4.png | Bin 0 -> 1029 bytes assets/lumbers/lumbers_red_ax_block5.png | Bin 0 -> 1022 bytes assets/lumbers/lumbers_red_ax_block6.png | Bin 0 -> 1027 bytes assets/lumbers/lumbers_red_ax_block7.png | Bin 0 -> 1026 bytes main/modes/lumberjack/lumberjack.c | 2 +- main/modes/lumberjack/lumberjack.h | 34 ++- main/modes/lumberjack/lumberjackGame.c | 249 ++++++++++++++++---- main/modes/lumberjack/lumberjackGame.h | 2 +- 27 files changed, 237 insertions(+), 50 deletions(-) create mode 100644 assets/lumbers/lumbers_green_ax_block.png create mode 100644 assets/lumbers/lumbers_green_ax_block1.png create mode 100644 assets/lumbers/lumbers_green_ax_block2.png create mode 100644 assets/lumbers/lumbers_green_ax_block3.png create mode 100644 assets/lumbers/lumbers_green_ax_block4.png create mode 100644 assets/lumbers/lumbers_green_ax_block5.png create mode 100644 assets/lumbers/lumbers_green_ax_block6.png create mode 100644 assets/lumbers/lumbers_green_ax_block7.png create mode 100644 assets/lumbers/lumbers_normal_ax_block1.png create mode 100644 assets/lumbers/lumbers_normal_ax_block2.png create mode 100644 assets/lumbers/lumbers_normal_ax_block3.png create mode 100644 assets/lumbers/lumbers_normal_ax_block4.png create mode 100644 assets/lumbers/lumbers_normal_ax_block5.png create mode 100644 assets/lumbers/lumbers_normal_ax_block6.png create mode 100644 assets/lumbers/lumbers_normal_ax_block7.png create mode 100644 assets/lumbers/lumbers_red_ax_block1.png create mode 100644 assets/lumbers/lumbers_red_ax_block2.png create mode 100644 assets/lumbers/lumbers_red_ax_block3.png create mode 100644 assets/lumbers/lumbers_red_ax_block4.png create mode 100644 assets/lumbers/lumbers_red_ax_block5.png create mode 100644 assets/lumbers/lumbers_red_ax_block6.png create mode 100644 assets/lumbers/lumbers_red_ax_block7.png diff --git a/assets/lumbers/lumberjacks_panic_1.bin b/assets/lumbers/lumberjacks_panic_1.bin index e389be87b2ecf6ba753536a3444d7606388f9d7c..eaccecae68fab1c5473aede5223be3690ea1be53 100644 GIT binary patch delta 36 ncmZo;?qlW=WoCc?W@fpGg3c2aST}|kF>=K5F*0#*a6p@ z$dy*q?&Qbf$}vPsTJ9!lMJadsczwQqhEF}ur_<;2d7sz&eZE)w`+Ccz){=;nYt^1Q zdl$c!mL~ouHpO|ihEw(4Zke2E`ytYJrGNiGCFK<SD zEnLGTQ*dY=W?>p88H&5=p%$v40wYgDJj6mYgsxB{1~imlaYkdbkw%Nhk`3jWW$x-O z*&l7G%-qyXvRx=RRC85V!97sibukxp!5(>l$!p@kKM**C8Zn@uEvk_hBI>EArHU6 z$_|Q7NTbD+2oF!RT6S&q7q-u*>wO35`(Lhov%ePbc(K;AXJFmy()|0xNP52Y()W{x l%SX4=j~_eq^v2oSFTakzFRlGFG&l#4)GB>Flifq3{{RtCY}^0< literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_green_ax_block1.png b/assets/lumbers/lumbers_green_ax_block1.png new file mode 100644 index 0000000000000000000000000000000000000000..c764aaddb6178a3fc10abcaec1f02524990457e8 GIT binary patch literal 1028 zcmds#ziZTC493%TsMa1Hf?_=f>Et3R`3r2XS5M?9*BeC?B(9>aE`s<23I!3#?%-6M z1nK0c1l{D&O+^qL4#YWr^8OhH?p{KYC(rZb`*>@#*;zWVBqE*R#r~MLTfYMf{GUE^ zc$;VL&UkZ8_CB2aDKh_P>+)nHDqFMxz!h@dKJnV+WiNj6zrg25Bat1rHX34YbsWs+%%7AzTb2(Z^ac z<#TCYL&@-u7v-j*j^AjNg0=~0u(%TDp@~(8o*eni zGrc<=ZL{~kj7y(pztK1t_AgA1KYQ?TzayuX*WWIGyFNX;^Kf=-W%XD0W%ui!_fM}( zBOe494TNVreOrPE{N_mV$%i3tY<`^+buHjNFD4K^^n1)G_ zqE|iCLN!$2$Y_X%ScrzO71n@38kW$a#$vF628&@SL6sBcuI^I$SW9N+rfyPlVL?&N zRb2)3kfPVcT+{`5_yJ9(u><{(Kq0IFgETB@g$Ikl1{y3W=c-IjsF{?J=wmIJs;S^B za$!NyL{0D!r!fFtv|}`Cu@XO^$uxGr3Bf3YHDHit5?b(JG1x#$ov6AglM}+lFcN*N zB~w0^_BE8;c3>`A_iRThQqA`|Z?m#EHh1dUO>j|e8tV9sRw-zkfCh^zVIG=THS=Qr zE6>Tp(Qt#k|7F}dK0ia_V9;CHTzI`R9v{A(TBOe490WqAzCeW2!$ekfLl6faMyB2J<+4Rc62yVvWvPGai|X6N}Dcz0HqXM zx>;}yjzvUJN5MhF$tC{sehdS5FCod3=XvsfxjtE2T)46zB8%hO!zpjSe&^@;AFT8? zc{)#~YpZhf@#+text;a9TcfOqOwY7T&6LU_GCadFG()QBk?!f1uIW;}7HOVlX__WA zs*&ocma3@&Qc9$Filt}@3D`h`#W3Acdn!D_A~Zs3Etz|`g=@GJ3yS7p7N%iRr07)- zwNMQeI5HaIAr_(`Y=t#okcK6+sIeGqpuu8TN>Js5xvRUBKGu?%xv86!Tv$+4b5&PC zJ*4P$F&A|~9)3WRY3x8hBv1%zz#t7vTH(QBuz?0k%DF0&6KW=9B>GrOrfMqqidTRSPVAMQYWfz%H)J_F^ohXYsr+) zrF{)0w;h;^);-&iid6Hx&fBakj?JCAb`xBbn}#}mqg4vpCZNIMN|=WxR$Y8``7_U_ zr_;$Md;iP0bN1^e8pq?|t*zy~hqKwqZg=^n-23+TS+BP=IJh=Hcrlv&espm9{liK3 z?Cr)z=fRgbwe3sy-<^AXdU!*(WnXqW*ZbY$3;jPUvcJ3c_|543S3qSvnhcLtXV3ou D<=0Dx literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_green_ax_block4.png b/assets/lumbers/lumbers_green_ax_block4.png new file mode 100644 index 0000000000000000000000000000000000000000..2c37c144c225cd2e9c9a638927b26d305a98e064 GIT binary patch literal 1026 zcmds#ziL!r5XDDbNr)^FMUbdqVUZ>v3^sOVZ;UH)iM!h=sLdd@+G!#FLj^$uh3V`A zc>x8nFx8-)h>ciSL@j&*$KQO9;lS?4Ff(V)Idh+E^y|Zgr3Dcgj?Z-y-u?BP-^2g% z%Hot~*UicLs%(8cx+Ajt@y3POT2@4+XIiFaN@Wolo?#i9AyxE9_jF6wbg5p8G*7cM zO_LhcNcB`p)l>l~B~m=aQZ$7GY@oqnm~N>(6&_&`8X>io%st$~HC&1XMe{HV(=aJg z^s0wisD=t084d9e3(*j^!WuA0!xCE5SPVAMU@gLLHZg%ZQ-`}_!Z%2dIx9`6>+s!Tg+cjUd&rX3S2ig1uT5K`7#`iy#EW&01U9ie5^4LEJ6~SzHwL3lzi`ikn~@-300E z zZ?X5kjO$H8P63yZq>*x-M+Rq t{kU`S?*823BOe494SCp$XLI%X`chUzre|8FW=drd8J=Monjuy6NcVJ0*L0~~i!@KO zG)z?gMMXLE;=WSLN$L3C5y9qAJO+y{O(JBRP6VPCBCCoz;t0uNi zed9TNG#ak4_rHv5UyuHvadFU}U!Q*Y^z(jC&Wta9nf!Qgd;0CIE60Ct&YZq`HQznn z?HrwZK6n4s%DuDmCl0qe55|1s!rq$?-S~0oU~c2@_sO3(U%#JvapN*@GFTe+cNXqE F`3HekOZ5N% literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_green_ax_block7.png b/assets/lumbers/lumbers_green_ax_block7.png new file mode 100644 index 0000000000000000000000000000000000000000..91996d3cd6e46a0854785117abedd42c3b400feb GIT binary patch literal 1026 zcmds$F>91@48~*Y(4HJ8HxwxfjxI_eOIO>g?Wr8SYqu^HC0{@%Hx=b{FOoqJT?&=r z=%|}R&`qR{PNJaTq6o%c{vX4@-AhRF3{GU7D z+v0KT=45?E4&R;rA~G}Gyt=)X6_M$gmZ_OiSwx0sScYau6+O~D-O@E(s@EdT(=1KX zq((JTJ=Ib*RX|FK6i=}fO(6jrXs{TjTWU{*M_7bLNUbGv54Ug)mtsNDJj}v0Oo|k} z>Y)~@p#n!nLp;PnG=#0N1`N`$gcdaxgAFuT3`+^BoG^EFm(s^tGBY=IladPyifXRv zDyWAPy)NdWF37_VXfll*=!XOfVGS6hVM!}ISPVAMU`aVwWpYBzq>Mx#Yspki1z(X1 z3yLOcf{!?j0q~+7qfv{M_yJ9(u>(#BMj@;LgEW)Sf(MJi23qPw)lHe45H5z1=wmIJ z^18IQq2#s$bJ4nIJ5rHqzSnu1mBq2SQ`c^Si*nOY$8WSsLE8j0SX>G7(8Q_}kNQVE zKHi#)w%Ge$#^nz`zM*k299-N!wRivho35OlTOB{RcKyPcXFJQszfLdpSC{^NzH)ni z`fKk+=heZ{==sxymw#q|&-CApdp3Wg_j>us@Xq&7^9w&8kGo6v>I;|Q+GudNvU~R* D(uzy6 literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_normal_ax_block1.png b/assets/lumbers/lumbers_normal_ax_block1.png new file mode 100644 index 0000000000000000000000000000000000000000..e7a8de929baac9b105f427c78bccfc6d38ca565d GIT binary patch literal 1026 zcmds#KWo%+490UFLTNb^aS(NIvj~C`Tm)%p5l0shgdV;C<0s#jVc_mdNb=-)p8Q^|jaCM;XJk?N_Is;L4}N~Cy-rDzHX*g%8DFx^snDm=m>G(u`EnR~c}Yq%5(isoS!reRW~ z=v5E3Pz@D0G8*C`7NQ|+g*9N1h9$J9u^4Qi!D3iSQ00WVtGkpw){>dIshgBsSWr}R zRaZehr08`q7j;1%en69H>_9&xPzY9rRP(*g+pH{(&7Hb-6I_&=hB|(uRSMcBpuyrwn1?1-&AmSL zo#)%5@o1gB|7G0zI{l5tZrCkO&g{MT@?juXW^OFrzw~l?`tHWj;X-eJ{?pIBi|^lU zf83p%>*USb)rGD7jm-(SQL(e&x{-rSFSk9VHSU+`qOJn9aX?mYVk D!t+Zb literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_normal_ax_block2.png b/assets/lumbers/lumbers_normal_ax_block2.png new file mode 100644 index 0000000000000000000000000000000000000000..a7a498a8c298db6b3dae939e6abf25c05fc3e9fa GIT binary patch literal 1030 zcmds#y=s(U5QWFs#At{pf<(oLjR-c5wYtkLn-y8&CXI>^5vH&b{AsjO1b>27V&)QT zA|i<1fyH1_iNt^+HiCuV1&q(Um*K$f%P=!%&N=fvUKkCgr)H-_WO_K?8}sh2-{f}w zkDZuVMGZp&3#|k91GBbWNA)wMg?c zOVc!|QH@kjwNy(1q53vvpVJoZwgETCmMUBN^0}U3#Qi3Wc%w653^s$!A%uU^-LEq1i@B%^^6&$iOk)T7A%Q|z0|seW(h3h2gAFuTQqEPGoKQ0&Qzj>bi(w@C zSWBjSF70b5x$VGQwC>rCRHT~kb>3!Wacu6?wVU9g+%(kj8?92%HUSM5SHe6rv1;d& zJ)1mVZjDEa?ENp}+~+^P(KtWsb(Z$Oc)0#%hjb=;7p@(Bx_aC$zdQW(!-4n97q|XC zn48&k>h0#q+h_NEfA;$2?2YHENA_-Pbp}7qd|a8kyV0HadFjx~x6`k#Uhl8pxpxIj M8TLoLweIr$eY)~@p#n!nLp;PnG=#0N1`N`$gcdaxgAFuT3`+^BoG^EFm(s^tGBY=IladPyifXRv zDyWAPy)NdWF37_VXfll*=!XOfVGS6hVM!}ISPVAMU`aVwWpYBzq>Mx#Yspki1z(X1 z3yLOcf{!?j0q~+7qfv{M_yJ9(u>(#BMj@;LgEW)Sf(MJi23qPw)lHe45H5z1=wmIJ z^0~CHq2#s$bJ4nIJ5rHqzSnu1mBq2SQ`c^Si*nOY$8WSsLE8j0SX>G7(8Q{_R}0^G zzCIg|HrV@L#?3Fkf1z=8*uTEH`1ZkM^5M<##U)ug`t$tUwO&uU_s<^v*gds%_xr-u z;f=wGy{B`X&h+%X!;|knzPmcRG`%ICazru$E3{!Sm=xw5m5k0QgtsDH3L G+5HC({z(o1 literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_normal_ax_block4.png b/assets/lumbers/lumbers_normal_ax_block4.png new file mode 100644 index 0000000000000000000000000000000000000000..34a2b9731a1326f7572b475b9b27adc5a7634f35 GIT binary patch literal 1028 zcmds#v1`3Kto^I)yF4b$1=4qCu zX;Pyash(=7nkpcrM2e?ail&f&4K!E`(=D~9!Xqp~Bc#@nxrbZ0hD))aXdY%^8YV@G zUiDB5)lh*Wqahw*AsWI~SOW%WSVD^$i@^pOEQX~7RZf_@x=ZO}Et#2{x=G1}1w}Pi zbrsY@ie49UQ5WRl2Q-<+4)j9;g|G$;(y*iz9xMhMXt1Q5t1>yEW>Q9?kF{i~rh>1? zg#|?uHNi)m#sGNHj?t*aO8kH()7Swg1fvkvfI*r`Xu*TUU;{06qUxqhP6!vnNc6Fm zO!-{e*HCiXfw^eivmL2OHQ(#J&C24~+^K6f!9}@gsN*+UrJ!vB8Z54ad1zwQ$;~r+ zJUbzeW*{nU}m6W15+UzpyX-}!R*`P#tUv$tvA6g4LGR7^^~WH}U}@OjUcC48 EAF*Ffj{pDw literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_normal_ax_block5.png b/assets/lumbers/lumbers_normal_ax_block5.png new file mode 100644 index 0000000000000000000000000000000000000000..90e7996f132af3f366fb712cdfb4504d8aaed422 GIT binary patch literal 1022 zcmds#F>6(E48_lVcF;<-2!a#`9RwFa2!dlb0{w zJj0{yjaBV`z4%L-yx6)kTd$6+iYl+NDs`4w8I@jXmFi+-MO1i&Rj7MC%cI=Otz127 zSr%npW@Q4Yl%*(n$x0+(0}U3#bgTDtM5bq2rg|+|M22TrhMEOMk91GBbTuh@Ez&&A z(ga6FQ<3tNrPvB(ghyC}S|4l4+`}zgEf*FP&BH8AsD~82 zArDyydH4ZMrm+M4kU$}<0fRIwX@v)i!3G*EwR2r2C(K=KB>GrOX67b*MJ_BTy3B=- zIE?}Dq8+1Aif6f4n{2 zVefw#x4#|#M&t74+RE(0oBO-FA79U1Sk~R6zfaCzKblO2VQ+Cd43`c*e71&$p6L5 zCsuh5Jf18s$>zIrKSX9;uH2dqvm!D*(=s(vDvQYQ49n0AsiH@^r(3$FOZ8f$d77nZ zn$)O9s;642rV2V+qqA4U`0}U3#bW822@Cb|02&uJX?%@`$;ZiIpnul4KhDnj4 zS3T51HB{ipXo!bch=#Bg)__48me8WcVz7Y*i(x52l@sQ!?o#?#OJ?S#Zc=h#K~c?B zT?O@!qSwV-)CGC?0Zpc{1O1RdA*=y|G%RU_2aCZ58Z0U2s!UF(nUs;}V=bAgso*Pe zVL{PEP4E$?F#uk)V>D{95iCUTDQKI328%0U9-3HnbmP<) zp3hGv<5l+lmvQssub*h_NB#Bbnb*(v-wb47w!i)G(u=k3?%zN6=7;O|kA2@-+`4-H z_l1qcN1smaPmi2l*zTSVt{soJGuvJNb#DE`ox|UD=dbKN81C&HdJmqAhU0#7Y3BOe490Wk6{N>uDHMu0+~{DBLU7k|rJma3ycXv_2tjaB)X_mFb#QY?CqICe zcI(z?gMMXLE;=WSLN$L3C5y9qAJO+y{O(JBRP6VPCBCCoz;tA_8_zw>;1 zv78^U_rHw07k_@EaXOpcKHU8HsO!!?3^s4c{*S*eH#R2Qi(dcJ+QVLNdwk=>Mw8b! wp9}`w(aG@Xv-82l=kv*U+^wuEwjTEfuZFUJ&mMePKm7@w%y#F~_@`a1qfdt3y4moG0Zd*NTISgT%!_P>Qoqu$?R@n9b3t z;Nl=CI0~_DQeAXCad2|!5I_0;83yjYgd|U%=gDt#WjyS4Pj^M6H@ZHU@XpomXovrc zS7ujv4m_L;`?9lpb}BOSbY*#MDJvq=Gc8jyrLu?&&#(;5kScnld%C4-x>T=4nx|Qs zrb&%zqMo^^wPa>)>Lw)@78KQ7 z)m2arDSBPZMO~1GAJAkPJJ1ga6v7%XNW+p=c(533puv)IuFB+unn@XnKGu?{nhL%m z7Zwyv)C3=K8Ux@(J4T}xEAa!GOk)R}5R5`t0|sd(p#={XgAKIQiK?42IU!sOBhklN zGUan=Uqi`l2j-%6&vv9D)qJn>HYTXbAMfKcJF=r)p`96JQ*#G2Rr>c GPyPXhTuWU5 literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_red_ax_block2.png b/assets/lumbers/lumbers_red_ax_block2.png new file mode 100644 index 0000000000000000000000000000000000000000..8558fcccf1f5efcadc57bd27a4f6f88f701ca8b9 GIT binary patch literal 1031 zcmds#ziZTC493&yP)~|K%1IG%6FTUWy=u8yPwY{yH#lAu0^)Fkx)-OjU^ja48lP&BH8A!=y;j zs~&2h8Y*yPG{i$JL_^pLYrr54OK4GJG1x$Z#jup1$_aBViD{fF{$}fqqD!5Y~V}8kV%egT-J24VIL1RVF9YOv*^~v6f8LRPYtK zu%Kw7CisZc7yvKYF&ed4i678p8av>GU=+d{Fi0~AEqJgPY@nr1RNa)x3E^TGi9Xhn zDW6OG8cJ?EFc+#LJ9X_QxF|Obb^J!F6tqo1gT<9F4^6B(eQ^E< z&-W+8!7h9M%eeFH_%|B+{oc*d>dOb?@yElHt2bnO_V;PGyT0CClg{3`*?gsYBOe48~KnqE}06p-{yS;Nlbn$6D@e&$CBqJ2*I;2*E{)sQXbJY6ll_h>Ie) zcIo1%;20dG=yK4hAn5E8e|bNKfxDNGAkZU8>h2&C@JR z)1*c?b(4|{3yNy4 z>ME#*6umCyqAtk84`?!t9q5My3SkWxq+v-bJXj1i&|pb9S7mZS&7_P(A8W}}O$A?( z3k!-SYJ!hAjREkY9ivf;mG}Worm+J~2u2~S0fRJ?(1Hhx!3J9DMAc21oDeRCk?3PB znew@`uc73&19Q>3XFF1nYQEQbo0Y|}xl`9}f{Sv~P{(hyNMQ9-1$8juaDpFOue3a^kr}|_z0%-d&BO* H%4qi=tsP8Z literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_red_ax_block4.png b/assets/lumbers/lumbers_red_ax_block4.png new file mode 100644 index 0000000000000000000000000000000000000000..c81f6022d4e1a8072a51d1b049e7e68c43284338 GIT binary patch literal 1029 zcmds#F>BOe48~KdP)>?fIVs|-T`WSrKrL6!lX|q*et-iZ;2>1g$whS0f^Ho$I=M*c zQqI9aCzl{jMVwA=5*(ae;xF&VFmU%0l012yC;yjQ!~SCDaz{iK2e*17-lh62%=5o; z{oD@E+{00ST@Jro`6Y7d#n$HTMpi_oXIiFaN@Wolo?#i9AyxE9_jF6wbg5p8G*7cM zO_LhcNcB`p)l>l~B~m=aQZ$7GY@oqnm~N>(6&_&`8X>io%st$~HC&1XMe{HV(=aJg z^s0wisD=t084d9e3(*j^!WuA0!xCE5SPVAMU@{-AerclqG%c>MnL>E$)KGyVIxyE2_!?4IfTIKR|Ao_tqMSU?!S3^@53gLGT0dQ4%f%e F{sDJHOY{H$ literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_red_ax_block5.png b/assets/lumbers/lumbers_red_ax_block5.png new file mode 100644 index 0000000000000000000000000000000000000000..fa0168a65b867a437a070058d41460461f883da4 GIT binary patch literal 1022 zcmds#v1*lZ48_lFJ7}d?1VO|>2f;-Ug5cPemU=}mz3qK~f{>-7I=DKigW%v0T=WG> zHyw3y34)7=AQr(v=+IGgh`)S~Vc_0BA<4-(C*PB;$>!4H`9(=f% ztEYE(M)$Ti*R=of!Y^s=@z(9xMs;LWRC$$Esk6+=sPsy!R2L&FqQWbzLfz|G9_3zc z+WZCO9&hij=1;#a37Y25DGAiyDi;1{y4e)q*-FJi;Q>`dCZm9&X`kxv-#U9%f-e zJ*4OjdB{S@!w+aOjUDKR1PWmd7^GoID?C^XHqc+|su8dt{atFv=2?(XiseYS9JMRyMWJUDypaDHw&eYHFpO)nn2`EdEb wmoAN_pRVs6pIo`|dto*^dj0PG=%rS_&*{g*z2|>_ej9_O@y29*e{J{CKR6UgL;wH) literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_red_ax_block6.png b/assets/lumbers/lumbers_red_ax_block6.png new file mode 100644 index 0000000000000000000000000000000000000000..ca89e89bc1cbccb47bef76e90ef48e2fbca9c1d3 GIT binary patch literal 1027 zcmds#F>BLd5XLV_2dzYl5G=u=i{K(CH@USXp^el~(|&+}a3D^iZk?QJ2RDbq#ZOQi z#i?E8bS&axaT6lws>Aua_hWdFyc~D;-19v5f4Mu|>MswMMWjF39?f`H>UW{X|IJ%h z_INr^XIqIv zjcTNNs-U@=U$)Se2Dun3KiT1)00Zs8g(#e$-Fn1yMW6e)Vu zLoHN81&)k{c!-5)2wPzd7^GndEov+V8)&c?mJ(DsVeaZKrH{2_W^U>xB^MSH)m+t8 zP!B13UCc#YkcS`8WEwlr4+#{)8Zb!1l2&-I7;K=yl5(!fsz9JVE z6iw6wA8{H3;6*z|qZTXi1DZ@@2b>U$LRbR^X(pis4;F(BwA6{Jn=&~eTnr=8$67Mw zb7@~g$!!PbqIJ)9q$1UPuk$u5i(_-AuH6I|<))#I-)NPBwh3skxDw`}iB*@5u72hD z@@zKUWAA?%_s)JT&^VrqHuhIvKb+6szgk*dm;2{`o)6Z}d%eNn?aJlOgWD%J-dTTV z{%N@A9vnPATVGoId~)&d==(LfvvzXYc_SO&x-$Iz=BLd5XLVtf;5B{p-{vjqlhhq!&S5-v=I$4EzS|)C_1X6h)(L@*5RD|08%=3 z?I@fM4n>^YL~y99%lW(aV|b9f9C!EJ^E~%|Gn;M?mM$%c$Y8QFn)9yI@4`9$udFZc z@^qfex3}c*%jI7p-Pf}_d*iH#OwY7T&6LU_GCadFG()QBk?!f1uIW;}7HOVlX__WA zs*&ocma3@&Qc9$Filt}@3D`h`#W3Acdn!D_A~Zs3Etz|`g=@GJ3yS7p7N%iRr07)- zwNMQeI5HaIAr_(`Y=t#okcK6+sIeGqpuu8TN>Js5xvRUBKGu?%xv86!Tv$+4b5&PC zJ*4P$F&A|~9)3WRY3x8hBv1%zz#t7vTH(QBuz?0k%DF0&6KW=9B>GrOrfMqqidTRSPVAMQYWfz%H)J_F^ohXYsr+) zrF{)0w;h;^);-&iid6Hx&fBakj?JCAb`xBbn}#}mqg4vpCZNIMN|=WxR`uUr{Lb_3 z>3q7&-v2UgpPv0j<7hIvwYPTgaIrXk*ITi9aWP^>D z*B_6@58fa3&;FeBPCuS(46i;~K0jOE@AjVeW%zY}@ae_ppWw-4JRKcwEnfWt!stes literal 0 HcmV?d00001 diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index 735f8471e..a5b28d48c 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -29,7 +29,7 @@ static void lumberjackMenuCb(const char*, bool selected, uint32_t settingVal); static void lumberjackJoinGame(void); -static const char lumberjackName[] = "Lumberjack"; +static const char lumberjackName[] = "Lumber Jack"; static const char lumberjackPanic[] = "Panic"; static const char lumberjackAttack[] = "Attack"; static const char lumberjackBack[] = "Back"; diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index e7b17e638..25a0397be 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -54,6 +54,15 @@ typedef struct } lumberjackTile_t; +typedef struct +{ + int x; + int y; + int type; + bool active; + +} lumberjackAxeBlock_t; + typedef struct { bool loaded; @@ -69,11 +78,28 @@ typedef struct int64_t worldTimer; int64_t physicsTimer; int liquidAnimationFrame; + int stageAnimationFrame; int currentMapHeight; int spawnTimer; int spawnIndex; int spawnSide; + int waterLevel; + int waterTimer; + int waterSpeed; + int waterDirection; + int playerSpawnX; + int playerSpawnY; + + int enemy1Count; + int enemy2Count; + int enemy3Count; + int enemy4Count; + int enemy5Count; + int enemy6Count; + int enemy7Count; + int enemy8Count; + wsg_t floorTiles[20]; wsg_t animationTiles[20]; @@ -85,6 +111,11 @@ typedef struct lumberjackTile_t* tile; uint8_t anim[400]; + wsg_t greenBlockSprite[7]; + wsg_t redBlockSprite[7]; + wsg_t unknownBlockSprite[7]; + wsg_t unusedBlockSprite[7]; + wsg_t enemySprites[21]; wsg_t playerSprites[16]; @@ -92,8 +123,9 @@ typedef struct wsg_t slowload[400]; - lumberjackEntity_t* enemy[8]; + lumberjackEntity_t* enemy[64]; + lumberjackAxeBlock_t* axeBlocks[8]; lumberjackEntity_t* localPlayer; lumberjackEntity_t* remotePlayer; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 77d1f94c0..34147dfb1 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -13,7 +13,6 @@ //redundancy #include "hdw-spiffs.h" -#include "emu_main.h" #include #include @@ -24,17 +23,20 @@ // Defines //============================================================================== -#define LUMBERJACK_TILEANIMATION_SPEED 150500 +#define LUMBERJACK_TILEANIMATION_SPEED 150500 -#define LUMBERJACK_SCREEN_X_OFFSET 299 -#define LUMBERJACK_SCREEN_X_MIN 0 -#define LUMBERJACK_SCREEN_X_MAX 270 +#define LUMBERJACK_SCREEN_X_OFFSET 299 +#define LUMBERJACK_SCREEN_X_MIN 0 +#define LUMBERJACK_SCREEN_X_MAX 270 -#define LUMBERJACK_SCREEN_Y_OFFSET 140 -#define LUMBERJACK_SCREEN_Y_MIN -16 -#define LUMBERJACK_SCREEN_Y_MAX 96 +#define LUMBERJACK_SCREEN_Y_OFFSET 140 +#define LUMBERJACK_SCREEN_Y_MIN -16 +#define LUMBERJACK_SCREEN_Y_MAX 96 + +#define LUMBERJACK_MAP_WIDTH 18 +#define LUMBERJACK_BLOCK_ANIMATION_MAX 7 +#define LUMBERJACK_RESPAWN_TIMER 3750 -#define LUMBERJACK_MAP_WIDTH 18 static lumberjackTile_t* lumberjackGetTile(int x, int y); static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs); @@ -57,8 +59,17 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) bzrStop(); // Stop the buzzer? + for (int i = 0; i < ARRAY_SIZE(lumv->axeBlocks); i++) + { + lumv->axeBlocks[i] = calloc(1, sizeof(lumberjackAxeBlock_t)); + lumv->axeBlocks[i]->x = -90; + lumv->axeBlocks[i]->y = -1000; + lumv->axeBlocks[i]->active = false; + } + lumv->worldTimer = 0; lumv->liquidAnimationFrame = 0; + lumv->stageAnimationFrame = 0; lumv->loaded = false; lumv->gameType = main->gameMode; lumv->onTitle = true; @@ -195,6 +206,32 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_enemy_c6.wsg", &lumv->enemySprites[19], true); loadWsg("lumbers_enemy_c7.wsg", &lumv->enemySprites[20], true); + loadWsg("lumbers_green_ax_block1.wsg", &lumv->greenBlockSprite[0], true); + loadWsg("lumbers_green_ax_block2.wsg", &lumv->greenBlockSprite[1], true); + loadWsg("lumbers_green_ax_block3.wsg", &lumv->greenBlockSprite[2], true); + loadWsg("lumbers_green_ax_block4.wsg", &lumv->greenBlockSprite[3], true); + loadWsg("lumbers_green_ax_block5.wsg", &lumv->greenBlockSprite[4], true); + loadWsg("lumbers_green_ax_block6.wsg", &lumv->greenBlockSprite[5], true); + loadWsg("lumbers_green_ax_block7.wsg", &lumv->greenBlockSprite[6], true); + + loadWsg("lumbers_red_ax_block1.wsg", &lumv->redBlockSprite[0], true); + loadWsg("lumbers_red_ax_block2.wsg", &lumv->redBlockSprite[1], true); + loadWsg("lumbers_red_ax_block3.wsg", &lumv->redBlockSprite[2], true); + loadWsg("lumbers_red_ax_block4.wsg", &lumv->redBlockSprite[3], true); + loadWsg("lumbers_red_ax_block5.wsg", &lumv->redBlockSprite[4], true); + loadWsg("lumbers_red_ax_block6.wsg", &lumv->redBlockSprite[5], true); + loadWsg("lumbers_red_ax_block7.wsg", &lumv->redBlockSprite[6], true); + + loadWsg("lumbers_normal_ax_block1.wsg", &lumv->unusedBlockSprite[0], true); + loadWsg("lumbers_normal_ax_block2.wsg", &lumv->unusedBlockSprite[1], true); + loadWsg("lumbers_normal_ax_block3.wsg", &lumv->unusedBlockSprite[2], true); + loadWsg("lumbers_normal_ax_block4.wsg", &lumv->unusedBlockSprite[3], true); + loadWsg("lumbers_normal_ax_block5.wsg", &lumv->unusedBlockSprite[4], true); + loadWsg("lumbers_normal_ax_block6.wsg", &lumv->unusedBlockSprite[5], true); + loadWsg("lumbers_normal_ax_block7.wsg", &lumv->unusedBlockSprite[6], true); + + ESP_LOGI(LUM_TAG, "AXE %d", lumv->axeBlocks[0]->active); + loadWsg("lumbers_alert.wsg", &lumv->alertSprite, true); if (lumv->gameType == LUMBERJACK_MODE_ATTACK) @@ -212,28 +249,6 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) bool lumberjackLoadLevel(int index) { char* fname = "lumberjacks_panic_1.bin"; - bool fileExists = false; - DIR* d; - d = opendir("./spiffs_image/"); - if (d) - { - struct dirent* dir; - while ((dir = readdir(d)) != NULL) - { - if (0 == strcmp(dir->d_name, fname)) - { - fileExists = true; - break; - } - } - closedir(d); - } - - if (false == fileExists) - { - ESP_LOGE(LUM_TAG, "No file \"%s\" found!", fname); - return false; - } size_t ms; uint8_t *buffer = spiffsReadFile(fname, &ms, false); @@ -242,6 +257,20 @@ bool lumberjackLoadLevel(int index) // Buffer 0 = map height lumv->tile = (lumberjackTile_t*)malloc((int)buffer[0] * LUMBERJACK_MAP_WIDTH * sizeof(lumberjackTile_t)); lumv->currentMapHeight = (int)buffer[0]; + + lumv->enemy1Count = (int) buffer[1]; + lumv->enemy2Count = (int) buffer[2]; + lumv->enemy3Count = (int) buffer[3]; + lumv->enemy4Count = (int) buffer[4]; + lumv->enemy5Count = (int) buffer[5]; + lumv->enemy6Count = (int) buffer[6]; + lumv->enemy7Count = (int) buffer[7]; + lumv->enemy8Count = (int) buffer[8]; + + + lumv->waterSpeed = (int)buffer[11]; + lumv->waterTimer = (int)buffer[11]; + for (int i = 0; i < lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH; i++) { lumv->tile[i].index = -1; @@ -257,8 +286,13 @@ bool lumberjackLoadLevel(int index) } } - + int offset = (lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH) + 12; + ESP_LOGI (LUM_TAG, "%d",((int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8))); //lumv->tile = &level; + lumv->playerSpawnX = (int)buffer[offset]; + lumv->playerSpawnY = (int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8); + + return true; } @@ -266,7 +300,7 @@ bool lumberjackLoadLevel(int index) void lumberjackSetupLevel(int characterIndex) { - + ESP_LOGI(LUM_TAG, "LOADING LEVEL"); bool levelLoaded = lumberjackLoadLevel(0); // This all to be loaded externally @@ -275,32 +309,73 @@ void lumberjackSetupLevel(int characterIndex) lumv->spawnIndex = 0; lumv->spawnTimer = 2750; lumv->spawnSide = 0; + lumv->waterLevel = lumv->currentMapHeight * 16; + lumv->waterDirection = -1; // This needs to be taken in to account with the intro timer lumv->localPlayer = calloc(1, sizeof(lumberjackEntity_t)); lumv->remotePlayer = calloc(1, sizeof(lumberjackEntity_t)); lumberjackSetupPlayer(lumv->localPlayer, characterIndex); - lumberjackSpawnPlayer(lumv->localPlayer, 94, 0, 0); + lumberjackSpawnPlayer(lumv->localPlayer, lumv->playerSpawnX, lumv->playerSpawnY, 0); - // snprintf(lumv->localPlayer->name, sizeof(lumv->localPlayer->name), "Player"); strcpy(lumv->localPlayer->name, " Dennis"); // If you see this... this name means nothing - for (int eSpawnIndex = 0; eSpawnIndex < 2; eSpawnIndex++) + int offset = 0; + //Load enemies + for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy1Count; eSpawnIndex++) { lumv->enemy[eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); lumberjackSetupEnemy(lumv->enemy[eSpawnIndex], 0); + } - sprintf(lumv->enemy[eSpawnIndex]->name, "Enemy %d", eSpawnIndex); - } + offset += lumv->enemy1Count; + for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy2Count; eSpawnIndex++) + { + lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + } + + offset += lumv->enemy2Count; + for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy3Count; eSpawnIndex++) + { + lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + } + + offset += lumv->enemy3Count; + for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy4Count; eSpawnIndex++) + { + lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + } + + offset += lumv->enemy4Count; + for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy5Count; eSpawnIndex++) + { + lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + } -/* - for (int tileIndex = 0; tileIndex < ARRAY_SIZE(ani); tileIndex++) + offset += lumv->enemy5Count; + for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy6Count; eSpawnIndex++) { - lumv->anim[tileIndex] = ani[tileIndex]; + lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + } + + offset += lumv->enemy6Count; + for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy7Count; eSpawnIndex++) + { + lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + } + + offset += lumv->enemy7Count; + for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy8Count; eSpawnIndex++) + { + lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + } - lumv->tile[tileIndex].x = tileIndex % 18; - lumv->tile[tileIndex].y = tileIndex / 18; - lumv->tile[tileIndex].type = level[tileIndex]; - }*/ ESP_LOGI(LUM_TAG, "LOADED"); } @@ -327,6 +402,19 @@ void lumberjackTitleLoop(int64_t elapsedUs) lumv->onTitle = false; } + //Update Animation + lumv->worldTimer += elapsedUs; + + if (lumv->worldTimer > LUMBERJACK_TILEANIMATION_SPEED) + { + lumv->worldTimer -= LUMBERJACK_TILEANIMATION_SPEED; + lumv->liquidAnimationFrame++; + lumv->liquidAnimationFrame %= 4; + lumv->stageAnimationFrame++; + } + + + DrawTitle(); } @@ -340,6 +428,26 @@ void lumberjackGameLoop(int64_t elapsedUs) } baseMode(elapsedUs); + //if panic mode do water + lumv->waterTimer -= elapsedUs/10000; + if (lumv->waterTimer < 0) + { + lumv->waterTimer += lumv->waterSpeed; + lumv->waterLevel += lumv->waterDirection; + + if (lumv->waterLevel > lumv->currentMapHeight * 16) + { + lumv->waterLevel = lumv->currentMapHeight * 16; + lumv->waterTimer = lumv->waterSpeed * 10; + lumv->waterDirection = -1; + } + + if (lumv->waterLevel < 0) + { + lumv->waterLevel = 0; + } + + } // If networked if (lumv->lumberjackMain->networked && lumv->lumberjackMain->conStatus == CON_ESTABLISHED) @@ -537,6 +645,7 @@ void baseMode(int64_t elapsedUs) lumv->worldTimer -= LUMBERJACK_TILEANIMATION_SPEED; lumv->liquidAnimationFrame++; lumv->liquidAnimationFrame %= 4; + lumv->stageAnimationFrame++; } // Update animation @@ -572,13 +681,17 @@ void baseMode(int64_t elapsedUs) void DrawTitle(void) { drawWsgSimple(&lumv->title, (TFT_WIDTH / 2) - 51, (TFT_HEIGHT / 2) - 48); + + drawWsgSimple(&lumv->subtitle_red, (TFT_WIDTH/2)- 36, (TFT_HEIGHT/2) -9); + for (int i = 0; i < LUMBERJACK_MAP_WIDTH; i++) { drawWsgSimple(&lumv->floorTiles[1], i * 16, 208); drawWsgSimple(&lumv->floorTiles[7], i * 16, 224); } + drawWsgSimple(&lumv->unusedBlockSprite[lumv->stageAnimationFrame % LUMBERJACK_BLOCK_ANIMATION_MAX], 8.5 * 16, 208 - 64); } void DrawGame(void) @@ -618,6 +731,12 @@ void DrawGame(void) if (lumv->localPlayer->state == LUMBERJACK_DEAD) { // ESP_LOGI(LUM_TAG, "DEAD %d", currentFrame); + + // If panic mode + lumv->waterDirection = 3; + lumv->waterTimer = lumv->waterSpeed; + lumv->waterLevel += lumv->waterDirection; + } lumv->localPlayer->drawFrame = currentFrame; @@ -638,6 +757,10 @@ void DrawGame(void) lumv->remotePlayer->y - lumv->yOffset, false, false, 0); } + //If playing panic mode draw water + lumberjackDrawWaterLevel(); + + // Debug char debug[20] = {0}; @@ -689,11 +812,11 @@ void lumberjackSpawnCheck(int64_t elapseUs) lumv->spawnSide++; lumv->spawnSide %= 2; - lumv->spawnTimer = 750; + lumv->spawnTimer = LUMBERJACK_RESPAWN_TIMER; lumberjackRespawnEnemy(lumv->enemy[enemyIndex], lumv->spawnSide); spawnReady = false; - // break; + break; } } @@ -955,8 +1078,22 @@ void lumberjackTileMap(void) } } } + +} + +void lumberjackDrawWaterLevel(void) +{ + //If GameMode is Panic... draw the water + for (int i = 0; i < LUMBERJACK_MAP_WIDTH; i++) + { + drawWsgSimple(&lumv->animationTiles[lumv->liquidAnimationFrame], i * 16, lumv->waterLevel - lumv->yOffset); + } + + fillDisplayArea(0, lumv->waterLevel + 16 - lumv->yOffset, TFT_WIDTH, ((lumv->currentMapHeight+1) * 16)- lumv->yOffset , c134); + } + void lumberjackDoControls(void) { lumv->localPlayer->cW = 15; @@ -1164,6 +1301,24 @@ void lumberjackExitGameMode(void) freeWsg(&lumv->animationTiles[i]); } + //Free the axes + for (int i = 0; i < ARRAY_SIZE(lumv->greenBlockSprite); i++) + { + freeWsg(&lumv->greenBlockSprite[i]); + } + + //Free the axes + for (int i = 0; i < ARRAY_SIZE(lumv->redBlockSprite); i++) + { + freeWsg(&lumv->redBlockSprite[i]); + } + + //Free the axes + for (int i = 0; i < ARRAY_SIZE(lumv->unusedBlockSprite); i++) + { + freeWsg(&lumv->unusedBlockSprite[i]); + } + freeWsg(&lumv->alertSprite); freeFont(&lumv->ibm); diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 14421611a..76f20ce23 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -3,11 +3,11 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex); -// void lumberjackStartGameMode(lumberjackGameType_t type, uint8_t characterIndex); void lumberjackExitGameMode(void); void lumberjackSetupLevel(int index); void lumberjackDoControls(void); void lumberjackTileMap(void); +void lumberjackDrawWaterLevel(void); void lumberjackUpdate(int64_t elapseUs); void lumberjackTitleLoop(int64_t elapsedUs); From a040b2e97c40e49a124e7676d8947b4c969b37a8 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Mon, 18 Sep 2023 22:27:46 -0700 Subject: [PATCH 04/54] Add Game Over Add invincibility when you respawn Add lives counter Add lives icon Added submersion timer Fixed ducking bug Removed climbing animations from code removed spriteOffset from hero --- assets/lumbers/lumbers_game_over.png | Bin 0 -> 444 bytes assets/lumbers/lumbers_green_22.png | Bin 0 -> 1070 bytes assets/lumbers/lumbers_green_lives.png | Bin 0 -> 276 bytes assets/lumbers/lumbers_red_22.png | Bin 0 -> 1069 bytes assets/lumbers/lumbers_red_lives.png | Bin 0 -> 275 bytes assets/lumbers/secret_swadgeland_22.png | Bin 1087 -> 1056 bytes assets/lumbers/secret_swadgeland_lives.png | Bin 0 -> 1053 bytes main/modes/lumberjack/lumberjack.h | 7 +- main/modes/lumberjack/lumberjackEntity.c | 20 +- main/modes/lumberjack/lumberjackEntity.h | 2 + main/modes/lumberjack/lumberjackGame.c | 253 ++++++++++++++------- main/modes/lumberjack/lumberjackPlayer.c | 28 +-- main/modes/lumberjack/lumberjack_types.h | 3 +- 13 files changed, 207 insertions(+), 106 deletions(-) create mode 100644 assets/lumbers/lumbers_game_over.png create mode 100644 assets/lumbers/lumbers_green_22.png create mode 100644 assets/lumbers/lumbers_green_lives.png create mode 100644 assets/lumbers/lumbers_red_22.png create mode 100644 assets/lumbers/lumbers_red_lives.png create mode 100644 assets/lumbers/secret_swadgeland_lives.png diff --git a/assets/lumbers/lumbers_game_over.png b/assets/lumbers/lumbers_game_over.png new file mode 100644 index 0000000000000000000000000000000000000000..788e579185a87da024e309658e711d1122d1296d GIT binary patch literal 444 zcmV;t0YmPx$c1c7*RA_ z%8#_Yww-p|Tt8N%P+FscXwBu&_u_B&7)GupC z#TgX8+P)qC?S0Lf!5E1jXLv2{EI{#g&=;BT@O(LU5ra7 zjexI>lh>IjfxN4Iuaa2#(;6r(qvCJ<&Zt0bHqV%0q1D_?peW^Ves372eB5r(OVs?0 zTFX#=xOs2Zun@HiTTIG~udsATm6q5=9{M?CDbRUIv3|P)_}3b`h-~K@0U%_Ps(SctpLh?)PX4P meU2;#$~ZsT_ENkD)yfmW;<)l=!W;bn000086%}intnD6of=jn}|pvkk-@hdH;+C?tK_$=FB-~-p7s6p^mn$HWBHl57(N!-R0N1 zkN?`sr7fO4_nJckvhx1uPm#Tgjgj%eED@QWX_=ZSC5y=L49n0ADMgQTPq%bUm(pvI z=4qCuX;MZtQa#mDHB~@Li4;$<6ip!k8)&c?rd!IM5*}d@8X;vZnR~c}Yq%5^6wSjd zOv9v*qE|iCLN!$2$Y_X%ScrzO71n@38kW$a#$vF628&@Sf=W)9yShu!$67KoH+7RD z7Zw!NT-8-j4=H+G%tc+0hab>n8avPr2^7K_Fi69aR(P-&Y@orC;#?_{6KW>KNc6Fm zOx0BI6}hmWXrdb zi(w@CSWBjSF4fmijfqUD~|kqW8G_j2CK%EGa7r(C-dTqsu>%JC~&MM1R*Xt1~v z=AnsI2bT_i=GngA9KFKc|1vIp`m=+^yY*WC__-(VKCT~F>u%rQSigMd>c-5;6H|-7 zubuCom|VZOIoG-|*R%cf!`Ah_v2VW~j?AyVnL75W^Y8T9>gI*7&wFkkdUkr=hbNZL z+>(~F%{F^ICX;W!?@li-%(nOScJ9pocyx27Yv;j{*_oCv$4~9{)?ak=v0LhcqqUWR H8w>vclZ|3l literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_green_lives.png b/assets/lumbers/lumbers_green_lives.png new file mode 100644 index 0000000000000000000000000000000000000000..f4757454916308f1bd442902c37f7f8bbe1c8a9a GIT binary patch literal 276 zcmV+v0qg#WP)Px#&PhZ;R49>slH0AsAPhtgtL?k%+~-ul7iuVb12aD zs&9Q(3(fBR$=j=b0=5%bjH0U}P|$TM5(UAIxkwZ-TEu8EB93prpR@;nV-hy`X0n}T zKvIlW=F-&*yh&HE_VZXD**X?22(f;gNW+kIHc&zCKag&s+!wE;Xm`H)_4xAn=BDcF a9{vD(L54f^`kk==0000U7lT+J2R8A_Hpo!NYC>8>4oVm5t*K8nVKmji^%W{%g_udMUQk(w{%UH z(rc0CX_lsGQbsjWJ=Ib*RX|FK6i=}fO(6jrXs{TjTgsji9$^t0A!RL@d$@&bxD*x? z&BH8A!=#X+S3T51HB{ipXo!bch=#Bg)__48me8WcVz7Y*i(x5(N=}%&x=Yc=S~4>? zb(10&78KQ7)m2arDSBPZMO~1GAJAkPJJ1ga6v7%XNW+p=c(533puv*jTq%fjZZzJG)Th4QAG@~Q_b#)0 z^!?`Zo1Z$XQ+u~BjxQZK{AA+XP z9qp5e{)hDkyI=Kg{9YZt{<3%WL+$+5VE@k2;Px#%}GQ-R49>slG}|1Aq+zgSJRQH32K6xlA5v~Twb%Qjf5s5u@iep93d(AC)_=y zv)P(KuXk5>I#8mKbLIKf-2Ltcu(qzBU8#$0g|(wxarblpzN4Ftr8j(LpRrEaj1mZN z?tB7fk_BZlPC9q)9U(2zMT2pMGyp(HOT$rDgtc+Pu5&E&>(geF^?-mw+~>c$y7Hr)fXTwNifhJ)^!f Z{{XDFl~7N%$vFT3002ovPDHLkV1miCar*!O literal 0 HcmV?d00001 diff --git a/assets/lumbers/secret_swadgeland_22.png b/assets/lumbers/secret_swadgeland_22.png index f3243941b88bd40491b4a178d25036cf2a3a2b85..8716b67577b3daafac2152cc54c209b4f2071827 100644 GIT binary patch delta 127 zcmV-_0D%9$2%reCsRMUnNkl)X-1&Dych$i{7C5uD09;#F-=(lCd|U;p90G03_&{N$5c*&!CV)Q!3mv}4Y;)p3~c}a N002ovPDHLkV1krXK{EgV diff --git a/assets/lumbers/secret_swadgeland_lives.png b/assets/lumbers/secret_swadgeland_lives.png new file mode 100644 index 0000000000000000000000000000000000000000..f04f65342d1fa8ec74bff3af9e6af30bc50a814b GIT binary patch literal 1053 zcmds#zf0F~5XP?@GR=NdB7q4(Q8*p_7=q9gv*Me4bto6Z;54GCprIjh($+9I8f!L+ z>Mv+$ILaxcr6Lr9h#=RvUibMkI{1Fy9C!EJ^E~%inrMynboF(KNYD6%kv8w{`gL~j ze{68qB+r&R?Xh85`Eclm$kxS)%TuFS5t*K8nVKn;MPzt}WoU*}(Ief{EnU;4dM(mC z&C)bYYE&cDQ!Q0f1*DWn@f1tZ6cVt328&_3rS?>KghgnC)LJt4a0}OPDHasX!z@h0 zq)5@L9%`W)DsW^p#6v7ZL)Z#yz#t7vXi;M^*g%8Du#}+633FF>DSfOZGjmfnDY>wq zsOGA!f_g~N>tZhIf;{|yCezq~en_AY)__48mbAiy#b5&smXvccpG)&Kl-%aPT(s`l9H~e(zSnshD~n^}PF=eZT$CFPb^L}_DQGqU4Hj3zJT$SY z`_bOdJZpE`tx5L&mvQma@1JO#86O#%>RrBl<>ek3=zRA2#`d{OA9wzmeLT>=eEy4$ z4V^i>^nTxtBQLIgecJu-R>$g6@9N_0#+z-^$M>InFn?|B)xmo+-`Br&&#&A(*T2!X mcH-2+=AU=>-#$62bI8d({>zVHud!B`mp literal 0 HcmV?d00001 diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 25a0397be..7872803c4 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -67,15 +67,16 @@ typedef struct { bool loaded; bool onTitle; + bool gameOver; font_t ibm; lumberjack_t* lumberjackMain; menu_t* menu; uint16_t btnState; ///<-- The STOLEN! ;) int yOffset; - int lives; int64_t worldTimer; + int64_t transitionTimer; int64_t physicsTimer; int liquidAnimationFrame; int stageAnimationFrame; @@ -102,11 +103,13 @@ typedef struct wsg_t floorTiles[20]; wsg_t animationTiles[20]; + wsg_t minicharacters[3]; wsg_t title; wsg_t subtitle_red; wsg_t subtitle_green; wsg_t subtitle_white; + wsg_t gameoverSprite; lumberjackTile_t* tile; uint8_t anim[400]; @@ -117,7 +120,7 @@ typedef struct wsg_t unusedBlockSprite[7]; wsg_t enemySprites[21]; - wsg_t playerSprites[16]; + wsg_t playerSprites[18]; wsg_t alertSprite; diff --git a/main/modes/lumberjack/lumberjackEntity.c b/main/modes/lumberjack/lumberjackEntity.c index 5b0a1f1e1..3359c6ccd 100644 --- a/main/modes/lumberjack/lumberjackEntity.c +++ b/main/modes/lumberjack/lumberjackEntity.c @@ -5,15 +5,16 @@ void lumberjackSetupEnemy(lumberjackEntity_t* enemy, int character) { - enemy->direction = 1; - enemy->state = LUMBERJACK_RUN; - enemy->maxVX = 0; - enemy->active = false; - enemy->ready = true; - enemy->showAlert = false; - enemy->spriteOffset = 0; - enemy->cW = 15; - enemy->cH = 15; + enemy->direction = 1; + enemy->state = LUMBERJACK_RUN; + enemy->maxVX = 0; + enemy->active = false; + enemy->ready = true; + enemy->showAlert = false; + enemy->spriteOffset = 0; + enemy->cW = 15; + enemy->cH = 15; + enemy->submergedTimer = 0; lumberjackUpdateEnemy(enemy, character); } @@ -39,6 +40,7 @@ void lumberjackRespawnEnemy(lumberjackEntity_t* enemy, int side) enemy->active = true; enemy->ready = false; enemy->y = 0; + enemy->lives = 1; // I need to figure out why when moving right he appears to move faster if (side == 1) diff --git a/main/modes/lumberjack/lumberjackEntity.h b/main/modes/lumberjack/lumberjackEntity.h index ced2eabaf..c0675cc15 100644 --- a/main/modes/lumberjack/lumberjackEntity.h +++ b/main/modes/lumberjack/lumberjackEntity.h @@ -26,11 +26,13 @@ typedef struct int y; int spriteOffset; int vx; + int lives; float vy; int maxVX; int type; int maxLevel; int respawn; + int submergedTimer; int cX; int cY; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 34147dfb1..e0757fdb8 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -36,6 +36,7 @@ #define LUMBERJACK_MAP_WIDTH 18 #define LUMBERJACK_BLOCK_ANIMATION_MAX 7 #define LUMBERJACK_RESPAWN_TIMER 3750 +#define LUMBERJACK_SUBMERGE_TIMER 300 static lumberjackTile_t* lumberjackGetTile(int x, int y); @@ -43,6 +44,7 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs static bool lumberjackIsCollisionTile(int index); bool lumberjackLoadLevel(int index); +void lumberjackOnLocalPlayerDeath(void); void DrawTitle(void); void DrawGame(void); @@ -67,6 +69,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->axeBlocks[i]->active = false; } + lumv->gameOver = false; lumv->worldTimer = 0; lumv->liquidAnimationFrame = 0; lumv->stageAnimationFrame = 0; @@ -92,6 +95,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_title_attack_white.wsg", &lumv->subtitle_white, true); } + loadWsg("lumbers_game_over.wsg", &lumv->gameoverSprite, true); ESP_LOGI(LUM_TAG, "Loading floor Tiles"); loadWsg("bottom_floor1.wsg", &lumv->floorTiles[0], true); @@ -121,6 +125,12 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) ESP_LOGI(LUM_TAG, "Loading Characters"); + ESP_LOGI(LUM_TAG, "*Loading character icons"); + loadWsg("lumbers_red_lives.wsg", &lumv->minicharacters[0], true); + loadWsg("lumbers_green_lives.wsg", &lumv->minicharacters[1], true); + loadWsg("secret_swadgeland_lives.wsg", &lumv->minicharacters[2], true); + + ESP_LOGI(LUM_TAG, "*Loading character sprites"); if (characterIndex == 0) { loadWsg("lumbers_red_1.wsg", &lumv->playerSprites[0], true); @@ -140,6 +150,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_red_15.wsg", &lumv->playerSprites[14], true); loadWsg("lumbers_red_16.wsg", &lumv->playerSprites[15], true); loadWsg("lumbers_red_17.wsg", &lumv->playerSprites[16], true); + loadWsg("lumbers_red_22.wsg", &lumv->playerSprites[17], true); } else if (characterIndex == 1) { @@ -160,6 +171,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_green_15.wsg", &lumv->playerSprites[14], true); loadWsg("lumbers_green_16.wsg", &lumv->playerSprites[15], true); loadWsg("lumbers_green_17.wsg", &lumv->playerSprites[16], true); + loadWsg("lumbers_green_22.wsg", &lumv->playerSprites[17], true); } else if (characterIndex == 2) { @@ -181,7 +193,8 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("secret_swadgeland_15.wsg", &lumv->playerSprites[14], true); loadWsg("secret_swadgeland_16.wsg", &lumv->playerSprites[15], true); loadWsg("secret_swadgeland_17.wsg", &lumv->playerSprites[16], true); - } + loadWsg("secret_swadgeland_22.wsg", &lumv->playerSprites[17], true); + } ESP_LOGI(LUM_TAG, "Loading Enemies"); loadWsg("lumbers_enemy_a1.wsg", &lumv->enemySprites[0], true); @@ -286,12 +299,12 @@ bool lumberjackLoadLevel(int index) } } + int offset = (lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH) + 12; ESP_LOGI (LUM_TAG, "%d",((int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8))); //lumv->tile = &level; lumv->playerSpawnX = (int)buffer[offset]; lumv->playerSpawnY = (int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8); - return true; @@ -299,15 +312,15 @@ bool lumberjackLoadLevel(int index) void lumberjackSetupLevel(int characterIndex) { - + ESP_LOGI(LUM_TAG, "LOADING LEVEL"); bool levelLoaded = lumberjackLoadLevel(0); // This all to be loaded externally lumv->yOffset = 0; - lumv->lives = 3; lumv->spawnIndex = 0; lumv->spawnTimer = 2750; + lumv->transitionTimer = 0; lumv->spawnSide = 0; lumv->waterLevel = lumv->currentMapHeight * 16; lumv->waterDirection = -1; // This needs to be taken in to account with the intro timer @@ -384,6 +397,7 @@ void lumberjackSetupLevel(int characterIndex) */ void restartLevel(void) { + lumv->localPlayer->lives--; lumberjackRespawn(lumv->localPlayer); } @@ -428,31 +442,45 @@ void lumberjackGameLoop(int64_t elapsedUs) } baseMode(elapsedUs); - //if panic mode do water - lumv->waterTimer -= elapsedUs/10000; - if (lumv->waterTimer < 0) + + if (lumv->gameOver) { - lumv->waterTimer += lumv->waterSpeed; - lumv->waterLevel += lumv->waterDirection; + lumv->transitionTimer -= elapsedUs/10000; - if (lumv->waterLevel > lumv->currentMapHeight * 16) + if (lumv->transitionTimer <= 0) { - lumv->waterLevel = lumv->currentMapHeight * 16; - lumv->waterTimer = lumv->waterSpeed * 10; - lumv->waterDirection = -1; + lumv->transitionTimer = 0; + switchToSwadgeMode(&lumberjackMode); } + } - if (lumv->waterLevel < 0) + //if panic mode do water + if (lumv->gameOver == false) + { + lumv->waterTimer -= elapsedUs/10000; + if (lumv->waterTimer < 0) { - lumv->waterLevel = 0; - } - - } + lumv->waterTimer += lumv->waterSpeed; + lumv->waterLevel += lumv->waterDirection; - // If networked - if (lumv->lumberjackMain->networked && lumv->lumberjackMain->conStatus == CON_ESTABLISHED) - lumberjackUpdateLocation(lumv->localPlayer->x, lumv->localPlayer->y, lumv->localPlayer->drawFrame); + if (lumv->waterLevel > lumv->currentMapHeight * 16) + { + lumv->waterLevel = lumv->currentMapHeight * 16; + lumv->waterTimer = lumv->waterSpeed * 10; + lumv->waterDirection = -1; + } + + if (lumv->waterLevel < 0) + { + lumv->waterLevel = 0; + } + + } + // If networked + if (lumv->lumberjackMain->networked && lumv->lumberjackMain->conStatus == CON_ESTABLISHED) + lumberjackUpdateLocation(lumv->localPlayer->x, lumv->localPlayer->y, lumv->localPlayer->drawFrame); + } DrawGame(); } @@ -501,12 +529,15 @@ void baseMode(int64_t elapsedUs) } } - for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) + if (!lumv->gameOver) { - if (lumv->enemy[enemyIndex] == NULL) - continue; + for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) + { + if (lumv->enemy[enemyIndex] == NULL) + continue; - lumberjackDoEnemyControls(lumv->enemy[enemyIndex]); + lumberjackDoEnemyControls(lumv->enemy[enemyIndex]); + } } // Clear cruft @@ -536,46 +567,49 @@ void baseMode(int64_t elapsedUs) // Check physics lumberjackUpdatePlayerCollision(lumv->localPlayer); - // Enemy - for (int eIdx = 0; eIdx < ARRAY_SIZE(lumv->enemy); eIdx++) + if (!lumv->gameOver) { - lumberjackEntity_t* enemy = lumv->enemy[eIdx]; - if (enemy == NULL || enemy->ready == true) - continue; - - enemy->showAlert = false; - if (enemy->state == LUMBERJACK_BUMPED_IDLE) + // Enemy + for (int eIdx = 0; eIdx < ARRAY_SIZE(lumv->enemy); eIdx++) { - enemy->respawn -= elapsedUs / 10000; + lumberjackEntity_t* enemy = lumv->enemy[eIdx]; + if (enemy == NULL || enemy->ready == true) + continue; - enemy->showAlert = enemy->respawn < 200; - if (enemy->showAlert) + enemy->showAlert = false; + if (enemy->state == LUMBERJACK_BUMPED_IDLE) { - enemy->upgrading = true; - } + enemy->respawn -= elapsedUs / 10000; - if (enemy->respawn <= 0) - { - // Hopefully the enemy isn't dead off screen. - enemy->state = LUMBERJACK_RUN; + enemy->showAlert = enemy->respawn < 200; + if (enemy->showAlert) + { + enemy->upgrading = true; + } + + if (enemy->respawn <= 0) + { + // Hopefully the enemy isn't dead off screen. + enemy->state = LUMBERJACK_RUN; - enemy->direction = (enemy->flipped) ? -1 : 1; + enemy->direction = (enemy->flipped) ? -1 : 1; - enemy->showAlert = false; - enemy->vy = -10; + enemy->showAlert = false; + enemy->vy = -10; - lumberjackUpdateEnemy(enemy, enemy->type + 1); + lumberjackUpdateEnemy(enemy, enemy->type + 1); + } } - } - lumberjackUpdateEntity(enemy, elapsedUs); + lumberjackUpdateEntity(enemy, elapsedUs); - for (int oeIdx = 0; oeIdx < ARRAY_SIZE(lumv->enemy); oeIdx++) - { - if (lumv->enemy[oeIdx] == NULL) - continue; + for (int oeIdx = 0; oeIdx < ARRAY_SIZE(lumv->enemy); oeIdx++) + { + if (lumv->enemy[oeIdx] == NULL) + continue; - lumberjackUpdateEnemyCollision(lumv->enemy[oeIdx]); + lumberjackUpdateEnemyCollision(lumv->enemy[oeIdx]); + } } } @@ -584,10 +618,12 @@ void baseMode(int64_t elapsedUs) { lumv->localPlayer->respawn -= elapsedUs / 10000; - if (lumv->localPlayer->respawn <= 0 && lumv->lives > 0) + if (lumv->localPlayer->respawn <= 0 && lumv->localPlayer->lives > 0) { + ESP_LOGI(LUM_TAG, "RESPAWN PLAYER!"); // Respawn player lumv->localPlayer->respawn = 0; + lumv->localPlayer->lives--; lumberjackRespawn(lumv->localPlayer); } } @@ -600,7 +636,7 @@ void baseMode(int64_t elapsedUs) { lumberjackEntity_t* enemy = lumv->enemy[enemyIndex]; - if (enemy == NULL || lumv->localPlayer->state == LUMBERJACK_DEAD) + if (enemy == NULL || lumv->localPlayer->state == LUMBERJACK_DEAD || lumv->localPlayer->state == LUMBERJACK_INVINCIBLE) continue; if (enemy->state != LUMBERJACK_DEAD && enemy->state != LUMBERJACK_OFFSCREEN) @@ -610,7 +646,7 @@ void baseMode(int64_t elapsedUs) { if (enemy->state == LUMBERJACK_BUMPED || enemy->state == LUMBERJACK_BUMPED_IDLE) { - enemy->state = LUMBERJACK_DEAD; + enemy->state = LUMBERJACK_DEAD; // Enemy Death enemy->vy = -30; if (lumv->localPlayer->vx != 0) { @@ -627,11 +663,7 @@ void baseMode(int64_t elapsedUs) { // Kill player // ESP_LOGI(LUM_TAG, "KILL PLAYER"); - lumv->localPlayer->state = LUMBERJACK_DEAD; - lumv->localPlayer->vy = -20; - lumv->localPlayer->active = false; - lumv->localPlayer->jumping = false; - lumv->localPlayer->jumpTimer = 0; + lumberjackOnLocalPlayerDeath(); } } } @@ -648,18 +680,38 @@ void baseMode(int64_t elapsedUs) lumv->stageAnimationFrame++; } - // Update animation - // Enemy Animation - for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) + //if Panic mode... check to see if player's head is under water. + if (lumv->localPlayer->y > lumv->waterLevel && lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_OFFSCREEN) { - if (lumv->enemy[enemyIndex] == NULL) - continue; + //ESP_LOGW(LUM_TAG, "UNDER WATER! %d", lumv->localPlayer->submergedTimer); + lumv->localPlayer->submergedTimer -= elapsedUs / 10000; - lumv->enemy[enemyIndex]->timerFrameUpdate += elapsedUs; - if (lumv->enemy[enemyIndex]->timerFrameUpdate > lumv->enemy[enemyIndex]->animationSpeed) + if (lumv->localPlayer->submergedTimer <= 0) { - lumv->enemy[enemyIndex]->currentFrame++; - lumv->enemy[enemyIndex]->timerFrameUpdate = 0; //; + lumv->localPlayer->submergedTimer = 0; + lumberjackOnLocalPlayerDeath(); + } + } + else + { + lumv->localPlayer->submergedTimer = LUMBERJACK_SUBMERGE_TIMER; + } + + // Update animation + if (!lumv->gameOver) + { + // Enemy Animation + for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) + { + if (lumv->enemy[enemyIndex] == NULL) + continue; + + lumv->enemy[enemyIndex]->timerFrameUpdate += elapsedUs; + if (lumv->enemy[enemyIndex]->timerFrameUpdate > lumv->enemy[enemyIndex]->animationSpeed) + { + lumv->enemy[enemyIndex]->currentFrame++; + lumv->enemy[enemyIndex]->timerFrameUpdate = 0; //; + } } } @@ -678,12 +730,34 @@ void baseMode(int64_t elapsedUs) lumv->yOffset = LUMBERJACK_SCREEN_Y_MAX; } +void lumberjackOnLocalPlayerDeath(void) +{ + lumv->localPlayer->state = LUMBERJACK_DEAD; + lumv->localPlayer->vy = -20; + lumv->localPlayer->active = false; + lumv->localPlayer->jumping = false; + lumv->localPlayer->jumpTimer = 0; + + if (lumv->localPlayer->lives <= 0) + { + ESP_LOGI(LUM_TAG, "Game over!"); + lumv->gameOver = true; + lumv->transitionTimer = 400; + } +} + void DrawTitle(void) { drawWsgSimple(&lumv->title, (TFT_WIDTH / 2) - 51, (TFT_HEIGHT / 2) - 48); - - drawWsgSimple(&lumv->subtitle_red, (TFT_WIDTH/2)- 36, (TFT_HEIGHT/2) -9); + if (lumv->localPlayer->type == 0) + { + drawWsgSimple(&lumv->subtitle_red, (TFT_WIDTH/2)- 36, (TFT_HEIGHT/2) -9); + } + else if (lumv->localPlayer->type == 1) + { + drawWsgSimple(&lumv->subtitle_green, (TFT_WIDTH/2)- 36, (TFT_HEIGHT/2) -9); + } for (int i = 0; i < LUMBERJACK_MAP_WIDTH; i++) { @@ -739,6 +813,11 @@ void DrawGame(void) } + if (lumv->localPlayer->submergedTimer != LUMBERJACK_SUBMERGE_TIMER && ((lumv->localPlayer->submergedTimer/10) % 3) != 0) + { + drawWsg(&lumv->alertSprite, lumv->localPlayer->x + 6, lumv->localPlayer->y - 26 - lumv->yOffset, false, false, 0); + } + lumv->localPlayer->drawFrame = currentFrame; // This is where it breaks. When it tries to play frame 3 or 4 it crashes. @@ -760,10 +839,27 @@ void DrawGame(void) //If playing panic mode draw water lumberjackDrawWaterLevel(); + for (int i = 0; i < lumv->localPlayer->lives; i++) + { + int icon = lumv->localPlayer->type; + + if (icon > ARRAY_SIZE(lumv->minicharacters)) + { + icon = 0; + } + drawWsgSimple(&lumv->minicharacters[icon], (i * 17) + 10, 20); + } + if (lumv->gameOver) + { + drawWsgSimple(&lumv->gameoverSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); + } + + drawText(&lumv->ibm, c555, "00000", 16, 16); // Debug char debug[20] = {0}; + /* snprintf(debug, sizeof(debug), "Debug: %d %d %d", lumv->localPlayer->x, lumv->localPlayer->y, lumv->localPlayer->cH); @@ -789,6 +885,7 @@ void DrawGame(void) { drawText(&lumv->ibm, c000, "B", 48, 32); } + */ } void lumberjackSpawnCheck(int64_t elapseUs) @@ -1025,7 +1122,7 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs { entity->respawn = 500; entity->ready = true; - lumv->localPlayer->state = LUMBERJACK_DEAD; + lumberjackOnLocalPlayerDeath(); return; } else @@ -1102,14 +1199,14 @@ void lumberjackDoControls(void) if (lumv->btnState & PB_LEFT) { lumv->localPlayer->flipped = true; - lumv->localPlayer->state = 2; + lumv->localPlayer->state = LUMBERJACK_RUN; lumv->localPlayer->direction = -1; buttonPressed = true; } else if (lumv->btnState & PB_RIGHT) { lumv->localPlayer->flipped = false; - lumv->localPlayer->state = 2; + lumv->localPlayer->state = LUMBERJACK_RUN; lumv->localPlayer->direction = 1; buttonPressed = true; @@ -1157,7 +1254,8 @@ void lumberjackDoControls(void) if (buttonPressed == false && lumv->localPlayer->active) { - lumv->localPlayer->state = 1; // Do a ton of other checks here + if (lumv->localPlayer->state != LUMBERJACK_INVINCIBLE) + lumv->localPlayer->state = LUMBERJACK_IDLE; // Do a ton of other checks here } if (lumv->localPlayer->state != previousState) @@ -1283,6 +1381,9 @@ void lumberjackExitGameMode(void) return; //** FREE THE SPRITES **// + + freeWsg(&lumv->gameoverSprite); + // Free the enemies for (int i = 0; i < ARRAY_SIZE(lumv->enemySprites); i++) { diff --git a/main/modes/lumberjack/lumberjackPlayer.c b/main/modes/lumberjack/lumberjackPlayer.c index 08b90b529..7c09a9878 100644 --- a/main/modes/lumberjack/lumberjackPlayer.c +++ b/main/modes/lumberjack/lumberjackPlayer.c @@ -6,6 +6,7 @@ #include #define LUMBERJACK_DEFAULT_ANIMATION_SPEED 150000 +#define LUMBERJACK_INVINCIBLE_ANIMATION_SPEED 25000 #define LUMBERJACK_SPAWN_Y 270 #define LUMBERJACK_HERO_WIDTH 24 #define LUMBERJACK_HERO_HEIGHT 31 @@ -24,19 +25,8 @@ void lumberjackSetupPlayer(lumberjackEntity_t* hero, int character) hero->maxLevel = character; hero->type = character; hero->state = LUMBERJACK_UNSPAWNED; + hero->lives = 3; - if (character == 0) - { - hero->spriteOffset = 0; - } - else if (character == 1) - { - hero->spriteOffset = 17; - } - else - { - hero->spriteOffset = 34; - } } void lumberjackSpawnPlayer(lumberjackEntity_t* hero, int x, int y, int facing) @@ -47,7 +37,7 @@ void lumberjackSpawnPlayer(lumberjackEntity_t* hero, int x, int y, int facing) hero->maxVX = 15; hero->vy = 0; hero->flipped = (facing == 0); - hero->state = LUMBERJACK_IDLE; + hero->state = LUMBERJACK_INVINCIBLE; hero->timerFrameUpdate = 0; hero->active = true; hero->onGround = true; @@ -65,10 +55,12 @@ void lumberjackRespawn(lumberjackEntity_t* hero) hero->vx = 0; hero->vy = 0; hero->flipped = 0; - hero->state = LUMBERJACK_IDLE; + hero->state = LUMBERJACK_INVINCIBLE; hero->timerFrameUpdate = 0; hero->onGround = true; hero->maxLevel = 0; + hero->submergedTimer = 5000; + } int lumberjackGetPlayerAnimation(lumberjackEntity_t* hero) @@ -120,11 +112,11 @@ int lumberjackGetPlayerAnimation(lumberjackEntity_t* hero) hero->animationSpeed = LUMBERJACK_DEFAULT_ANIMATION_SPEED; return animationVictory[hero->currentFrame % ARRAY_SIZE(animationVictory)]; } - if (animation == LUMBERJACK_CLIMB) + if (animation == LUMBERJACK_INVINCIBLE) { - const int animationClimb[] = {17, 18, 19, 20}; - hero->animationSpeed = LUMBERJACK_DEFAULT_ANIMATION_SPEED; - return animationClimb[hero->currentFrame % ARRAY_SIZE(animationClimb)]; + const int animationInvincible[] = {0, 17}; + hero->animationSpeed = LUMBERJACK_INVINCIBLE_ANIMATION_SPEED; + return animationInvincible[hero->currentFrame % ARRAY_SIZE(animationInvincible)]; } return 0; diff --git a/main/modes/lumberjack/lumberjack_types.h b/main/modes/lumberjack/lumberjack_types.h index 03453915e..b231b558f 100644 --- a/main/modes/lumberjack/lumberjack_types.h +++ b/main/modes/lumberjack/lumberjack_types.h @@ -13,7 +13,8 @@ enum lumberjackPlayerState LUMBERJACK_FALLING = 6, LUMBERJACK_OFFSCREEN = 7, // reserved for enemies only LUMBERJACK_BUMPED = 8, - LUMBERJACK_BUMPED_IDLE = 9 + LUMBERJACK_BUMPED_IDLE = 9, + LUMBERJACK_INVINCIBLE = 10, }; // Animation speeds From 509e38d90db674476d93724a20a0c8b12ecd8281 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 7 Oct 2023 10:06:36 -0700 Subject: [PATCH 05/54] Back in the groove QoL updates Removed ibm font because I'm not using it. Added atari grube font. Changed lives icon to be just characters head. Disabled water in Attack game mode. Started score system feedback. UI cleanup --- assets/fonts/eightbit_atari_grube2.font.png | Bin 0 -> 2761 bytes assets/lumbers/lumbers_green_lives.png | Bin 276 -> 226 bytes assets/lumbers/lumbers_red_lives.png | Bin 275 -> 220 bytes assets/lumbers/secret_swadgeland_lives.png | Bin 1053 -> 1025 bytes main/modes/demo/demoMode.c | 49 +++++++++++++++----- main/modes/lumberjack/lumberjack.c | 2 - main/modes/lumberjack/lumberjack.h | 8 +++- main/modes/lumberjack/lumberjackGame.c | 27 +++++++---- 8 files changed, 61 insertions(+), 25 deletions(-) create mode 100644 assets/fonts/eightbit_atari_grube2.font.png diff --git a/assets/fonts/eightbit_atari_grube2.font.png b/assets/fonts/eightbit_atari_grube2.font.png new file mode 100644 index 0000000000000000000000000000000000000000..5eae75113c32d33b28ed7d95afa7ef4da3400677 GIT binary patch literal 2761 zcmaKudpHvcAIG;`=02A&w=r|AgH4H*G?&H@&Q!#bjkDq`$5yX$NiH+nF*Y(IN^EX# zC6k<~L$i&ROENl9bfSn;shsKHxV-&)-uHRle?HImkMH-7@ALeA&+}zQgaztqnQH+6 z09|ZQ01g09x%*A)Yp8#tEZeCa0MO!K1ALEOj7!)6tLmr%;Ba`DvCYSYWdxkU%-6|( zOo%KR#;y(#Zvgb&d6wxhU0i~`ieHlI^rDPzfSjL=%qP3G3c|?iea0K|c|)pp=Z0TP z*TR;qhpQZWd|{0@;jVg$l0P^du=D%q+m7Y^46LVs<{~$s&GL@^84u+jz7KmFr);mf zn(gnYjl#F}SqSIUisz4?6e8OfvAV2Y(t5ySuOjFAp!3^2({e zD7^j^DCbX2s=2s=L@BVZQyw9EiIbkQ&yZEGrxpz6%0!vW9PBPZn)T8MS` ztifb9F|eDE?Px#7f0^&16F*=7$hb$;d)gIAVC+80F?5q%1yaGT4{eIxXrEGgNg66@ zlz~ocn?lF-1Mw+hUhC*wY8SXsZ_;H|VYctV=rq%Ei6$wU$O@EiPfVfjD1&act3=gs z%C@lBgozDci1xx7pthFMV1Q4zjE$3#eC*Q=s;g5A-0GHdAivDuq~D5VWJr%~&1$LR z#=PsOy3^3N%FyCwbl4Sn63bwOg_Or-trfzs$+FdY&Xi(Q5K|m9!8!9#6UvsN|w>jl({&^O1L}O6e3jbSvb!!&{(KNM7~l&gX~6k6@SH&=a4+kUx);9vk4kmb(N9CO z1CAN3ux zCH~8tOL7BH`PtDibaXTCCc>d_M7EPUVGfnuzicz6*TOYExP0KCG{LJP_uEB(ndA3X zb_Qu$;082s$a5H>#nD&MFeUatJcu4|hQqZsMya^18E)Z5XpaF#e-IQ^$f{^ddpy(hnn`$$~IX4 zWf{%U`K#^U)+eo7s`4VH;MMFAvN8|Mi^`@kl zl$4*x+=@~9ai==`vDd|>CZb)@eruW}hm5PTCUA8O#!&rT&vqq*iEnZ% z5sk;c)~CgZxzAI%m&;$U2l3IX`elwDmMvV28O8?9{*g@azteuT?DZoasdVlP_qaw? zNb#~tqWX}VXhYS=F_Tm=HN+myUmz|(#ima3WXiFBFQoMS0KM-e%$Ciob7Gqfs>)5M zf>q$8Yo$-}dM@V#B0Wp(P^XuliFEE1nL=~3ia)2)l>|LyS!UET9`sP8*e^^6puEkP zA3hkqkD^Lw5k9@VM$U>tvef%DqPJozX}Y8i6Fqy*bKjpyrGb=!F*MB?Nl`y%ikvwV zkqu#F(FeocBE(JVv6~F2HDYsB0YiT69qOBhD%)8m6vm*ntkIb`XoBC8^4>wz0s3!# zBEE;jpf0yn1lnvH8fC94yl;=G)QR|Z0pZ zr)4BPzoo|Ge*WRntN>^iJ7gN|sFS6(6rX0{@*aiL-iy;pjS*!cqEcigW#gegj<+6d z>-!Y{#6sm7RFmu6ao*a+VyEEkN#Ym?NkBd=KAp@xQ9f@*ln`zxd_3N0plZ&T{l!X5 zDJDV!;%x?IdhtE(tQ~ow>~gU`kG^oFuv9(%oF|UuIyh$Y?ZX>KLb%z`Po}62a3Wkr*dxr*%r3a(OM~7E7^Gf zB)KH3_?Z9fENzOt`-uMXNW{t~G#4rOZ95;8g>|{mY&Ab2AvxWpDlPL0_a|Q(fE-KL(BK-FX>vZH13Z5^<&YDM7`AL3o- z&rFXtq@hrdW!;uJgL{hou*}hqy{Fw!GeN~|O}uW_Hpo91X8Vr)M22AHjp{>mbN>mT zIUNAM)(M1V66`uDEi>22G6a za0`6dp`*hmAX3c|n+rENRaI8E)&AG}&nUoTM=0MHX}*IGL;N53yQo5P^|sg}qc>Vk zV|HDm2Ft%oyr6UZUO64)yp>k~LT044z@psj(}*GAQrHq@?#fI}YfI_&B0=3L1v3V* zE6_XY#iDPE>Dv*_hYHV`1t+gY^6_>J#W~Qg6CbP}r(d+$4Exl9h&evicnhirR{#J2 literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_green_lives.png b/assets/lumbers/lumbers_green_lives.png index f4757454916308f1bd442902c37f7f8bbe1c8a9a..e21322a681fd06fd7da2fc9f7ec3504508a0c467 100644 GIT binary patch delta 211 zcmV;^04)EM0^$LX7k>)~1^@s6OK@yo00001b5ch_0Itp)=>Px#oJmAMR49>sk?RS> zAP|HqP^HK{5l7c_5UA9baW6<57BpuK}YH;+}-el`| z+IEmD*Z|xKH#r5!HP?Aon&d%EiZ$+M03S)gaK1TI=z7f;K1|C(w|k#@d(Bf|yReH< zbvgnSov$KM5#*Yyi6Tae7%fJ`{31^@s6(BUpg00001b5ch_0Itp)=>Px#&PhZ;R49>slH0As zAPhtgtL?k%+~-ul7iuVb12aDs(x>MRtwGU{mI*_egd`= zS&X8qBT&$FDiQ_3j=4w_FmL39dqIXf_4=K$00000 LNkvXXu0mjf%CLBE diff --git a/assets/lumbers/lumbers_red_lives.png b/assets/lumbers/lumbers_red_lives.png index beda1ecb9b22fa7d96cbc1298a217b9d79bb30b7..6d694c59b1cdcd661bbca1873dc495d10e9e972a 100644 GIT binary patch delta 205 zcmV;;05boR0^9+R7k>)~1^@s6OK@yo00001b5ch_0Itp)=>Px#mPtfGR49>skk0h0od7k>{31^@s6(BUpg00001b5ch_0Itp)=>Px#%}GQ-R49>slG}|1 zAq+zgSJRQH32K6xlA5v~Twb%Qjf5s5u@iep93d(AC)_=yv)P(KuXk5>I#8mKbLIKf z-2Ltcu(qzBU8#$0g|(wxarblpzN4Ftr8j(LpRrEaj1mZN?tOd$W|9SEGEO>o?j0d5 z(M5xChBN>`M@z#|SA?~3!me}vpDh~5wPWQJ?c|ruf3ueoVP$;7BCM?`&l~J6vdY&b zFc&&(x}Sy*w=Mz|ERLtq!$zAvvTRR%zFsC$W9^kFo<1c8h7yPBf(!2jewr-F*V1r3y=LYEv65r=3ZERLtqy<2jgBeI_=<)||RP10biT8AI43U_c>%UQu zL6KwemSoO!@AG``k|rz4Pj$X;?Cxlx(0M|bM`eA)gW24T*~}L@B`$O%J=@A2r6poo zpAmUulX!Xj5Xm<@1s1ZPV0^)0g~Z5Hq&<5;fKQDbP*^Pgg&e IbxsLQ054ZH>i_@% diff --git a/main/modes/demo/demoMode.c b/main/modes/demo/demoMode.c index aafb0c495..16759182a 100644 --- a/main/modes/demo/demoMode.c +++ b/main/modes/demo/demoMode.c @@ -53,6 +53,7 @@ swadgeMode_t demoMode = { typedef struct { + bool inMenu; font_t ibm; wsg_t king_donut; song_t ode_to_joy; @@ -61,6 +62,7 @@ typedef struct uint16_t recvPackets; connectionEvt_t conStatus; menu_t* menu; + menuLogbookRenderer_t* menuLogbookRenderer; } demoVars_t; demoVars_t* dv; @@ -98,6 +100,8 @@ static void demoEnterMode(void) addSingleItemToMenu(dv->menu, demoMenu5); addSingleItemToMenu(dv->menu, demoMenu6); + dv->menuLogbookRenderer = initMenuLogbookRenderer(&dv->ibm); + dv->conStatus = CON_LOST; p2pInitialize(&dv->p2p, 'p', demoConCb, demoMsgRxCb, -70); @@ -113,6 +117,8 @@ static void demoEnterMode(void) printf("High score in NVS is %" PRId32 "\n", highScoreToRead); } } + + dv->inMenu = true; } /** @@ -144,22 +150,39 @@ static void demoMainLoop(int64_t elapsedUs) static uint32_t lastBtnState = 0; while (checkButtonQueueWrapper(&evt)) { - dv->menu = menuButton(dv->menu, evt); - - // printf("state: %04X, button: %d, down: %s\n", evt.state, evt.button, evt.down ? "down" : "up"); lastBtnState = evt.state; - // drawScreen = evt.down; - if (evt.button == PB_B && evt.down && dv->conStatus == CON_ESTABLISHED) + if (dv->inMenu) { - printf("Sending packet\n"); - const uint8_t testMsg[] = {0x01, 0x02, 0x03, 0x04}; - p2pSendMsg(&dv->p2p, testMsg, ARRAY_SIZE(testMsg), demoMsgTxCbFn); + dv->menu = menuButton(dv->menu, evt); + + if (evt.button == PB_A && evt.down) + { + dv->inMenu = false; + } } + else + { + // printf("state: %04X, button: %d, down: %s\n", evt.state, evt.button, evt.down ? "down" : "up"); + // drawScreen = evt.down; + + if (evt.button == PB_B && evt.down && dv->conStatus == CON_ESTABLISHED) + { + printf("Sending packet\n"); + const uint8_t testMsg[] = {0x01, 0x02, 0x03, 0x04}; + p2pSendMsg(&dv->p2p, testMsg, ARRAY_SIZE(testMsg), demoMsgTxCbFn); + } + + static hid_gamepad_report_t report; + report.buttons = lastBtnState; + sendUsbGamepadReport(&report); + } + } - static hid_gamepad_report_t report; - report.buttons = lastBtnState; - sendUsbGamepadReport(&report); + if (dv->inMenu) + { + drawMenuLogbook(dv->menu, dv->menuLogbookRenderer, elapsedUs); + return; } // Fill the display area with a dark cyan @@ -419,4 +442,8 @@ static void demoMsgTxCbFn(p2pInfo* p2p, messageStatus_t status, const uint8_t* d static void demoMenuCb(const char* label, bool selected, uint32_t settingVal) { printf("%s %s\n", label, selected ? "selected" : "scrolled to"); + + if (selected) + { + } } diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index a5b28d48c..842290f0b 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -69,7 +69,6 @@ static void lumberjackEnterMode(void) // Allocate and clear all memory for the menu mode. lumberjack = calloc(1, sizeof(lumberjack_t)); - loadFont("ibm_vga8.font", &lumberjack->ibm, false); loadFont("logbook.font", &lumberjack->logbook, false); lumberjack->menu = initMenu(lumberjackName, lumberjackMenuCb); @@ -140,7 +139,6 @@ static void lumberjackExitMode(void) lumberjackExitGameMode(); p2pDeinit(&lumberjack->p2p); - freeFont(&lumberjack->ibm); freeFont(&lumberjack->logbook); deinitMenu(lumberjack->menu); free(lumberjack); diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 7872803c4..112b3b84d 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -27,7 +27,6 @@ typedef struct { menu_t* menu; menuLogbookRenderer_t* menuLogbookRenderer; - font_t ibm; font_t logbook; uint8_t selected; @@ -68,7 +67,7 @@ typedef struct bool loaded; bool onTitle; bool gameOver; - font_t ibm; + font_t arcade; lumberjack_t* lumberjackMain; menu_t* menu; uint16_t btnState; ///<-- The STOLEN! ;) @@ -85,6 +84,11 @@ typedef struct int spawnIndex; int spawnSide; + int score; + int highscore; + + int enemyAttackQueue; + int waterLevel; int waterTimer; int waterSpeed; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index e0757fdb8..f2019aa83 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -57,7 +57,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv = calloc(1, sizeof(lumberjackVars_t)); lumv->lumberjackMain = main; - loadFont("ibm_vga8.font", &lumv->ibm, false); + loadFont("eightbit_atari_grube2.font", &lumv->arcade, false); bzrStop(); // Stop the buzzer? @@ -455,7 +455,7 @@ void lumberjackGameLoop(int64_t elapsedUs) } //if panic mode do water - if (lumv->gameOver == false) + if (lumv->gameOver == false && lumv->gameType == LUMBERJACK_MODE_PANIC) { lumv->waterTimer -= elapsedUs/10000; if (lumv->waterTimer < 0) @@ -837,6 +837,7 @@ void DrawGame(void) } //If playing panic mode draw water + lumberjackDrawWaterLevel(); for (int i = 0; i < lumv->localPlayer->lives; i++) @@ -847,7 +848,7 @@ void DrawGame(void) { icon = 0; } - drawWsgSimple(&lumv->minicharacters[icon], (i * 17) + 10, 20); + drawWsgSimple(&lumv->minicharacters[icon], (i * 14) + 22, 32); } if (lumv->gameOver) @@ -855,7 +856,13 @@ void DrawGame(void) drawWsgSimple(&lumv->gameoverSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); } - drawText(&lumv->ibm, c555, "00000", 16, 16); + char* score_display = "000"; + + drawText(&lumv->arcade, c000, score_display, 26, 18); + drawText(&lumv->arcade, c000, score_display, 26, 15); + drawText(&lumv->arcade, c000, score_display, 25, 16); + drawText(&lumv->arcade, c000, score_display, 27, 16); + drawText(&lumv->arcade, c555, score_display, 26, 16); // Debug char debug[20] = {0}; @@ -863,27 +870,27 @@ void DrawGame(void) snprintf(debug, sizeof(debug), "Debug: %d %d %d", lumv->localPlayer->x, lumv->localPlayer->y, lumv->localPlayer->cH); - drawText(&lumv->ibm, c000, debug, 16, 16); + drawText(&lumv->arcade, c000, debug, 16, 16); // drawRect(lumv->localPlayer->cX, lumv->localPlayer->cY - lumv->yOffset, lumv->localPlayer->cX + // lumv->localPlayer->cW, lumv->localPlayer->cY - lumv->yOffset + lumv->localPlayer->cH, c050); if (lumv->localPlayer->jumpPressed) { - drawText(&lumv->ibm, c555, "A", 16, 32); + drawText(&lumv->arcade, c555, "A", 16, 32); } else { - drawText(&lumv->ibm, c000, "A", 16, 32); + drawText(&lumv->arcade, c000, "A", 16, 32); } if (lumv->localPlayer->attackPressed) { - drawText(&lumv->ibm, c555, "B", 48, 32); + drawText(&lumv->arcade, c555, "B", 48, 32); } else { - drawText(&lumv->ibm, c000, "B", 48, 32); + drawText(&lumv->arcade, c000, "B", 48, 32); } */ } @@ -1422,6 +1429,6 @@ void lumberjackExitGameMode(void) freeWsg(&lumv->alertSprite); - freeFont(&lumv->ibm); + freeFont(&lumv->arcade); free(lumv); } From 61bc49cdff0a0f273513270847aecbdafc80b4f9 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 7 Oct 2023 12:37:52 -0700 Subject: [PATCH 06/54] Continuing level flow Added UI image for multiplayer mode Started basis of game state machine Added score value for enemies Started basis of finishing winning level --- assets/lumbers/lumbers_item_ui.png | Bin 0 -> 189 bytes main/modes/lumberjack/lumberjack.h | 19 +++++- main/modes/lumberjack/lumberjackEntity.c | 3 + main/modes/lumberjack/lumberjackEntity.h | 1 + main/modes/lumberjack/lumberjackGame.c | 77 +++++++++++++++++------ main/modes/lumberjack/lumberjackGame.h | 2 + 6 files changed, 79 insertions(+), 23 deletions(-) create mode 100644 assets/lumbers/lumbers_item_ui.png diff --git a/assets/lumbers/lumbers_item_ui.png b/assets/lumbers/lumbers_item_ui.png new file mode 100644 index 0000000000000000000000000000000000000000..d3306969cd258ec8c63fe52a38ba81fdcf077338 GIT binary patch literal 189 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|$~|2iLp(a) zPTR7i<>_>b=8s~%UqdswM-+Gfv!cy31yCxIq`76yiMe^=~Xxa3Wc>Fx5H lEB`3}YWNwtsxO)IjcG@O1TaS?83{1OTQ5M(6+l literal 0 HcmV?d00001 diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 112b3b84d..ce7d6922a 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -23,6 +23,14 @@ typedef enum LUMBERJACK_MODE_ATTACK } lumberjackGameType_t; +typedef enum +{ + LUMBERJACK_GAMESTATE_TITLE, + LUMBERJACK_GAMESTATE_PLAYING, + LUMBERJACK_GAMESTATE_WINNING, + LUMBERJACK_GAMESTATE_GAMEOVER +} lumberjackGameState_t; + typedef struct { menu_t* menu; @@ -65,8 +73,8 @@ typedef struct typedef struct { bool loaded; - bool onTitle; - bool gameOver; + bool onTitle; // TODO: Make these two one state machine + bool gameOver; // TODO: Make these two one state machine font_t arcade; lumberjack_t* lumberjackMain; menu_t* menu; @@ -75,11 +83,14 @@ typedef struct int yOffset; int64_t worldTimer; + int64_t levelTime; int64_t transitionTimer; int64_t physicsTimer; int liquidAnimationFrame; int stageAnimationFrame; int currentMapHeight; + int totalEnemyCount; + int enemyKillCount; int spawnTimer; int spawnIndex; int spawnSide; @@ -123,9 +134,11 @@ typedef struct wsg_t unknownBlockSprite[7]; wsg_t unusedBlockSprite[7]; - wsg_t enemySprites[21]; + wsg_t enemySprites[23]; wsg_t playerSprites[18]; + wsg_t ui[6]; + wsg_t alertSprite; wsg_t slowload[400]; diff --git a/main/modes/lumberjack/lumberjackEntity.c b/main/modes/lumberjack/lumberjackEntity.c index 3359c6ccd..cc91fd300 100644 --- a/main/modes/lumberjack/lumberjackEntity.c +++ b/main/modes/lumberjack/lumberjackEntity.c @@ -78,6 +78,7 @@ void lumberjackUpdateEnemy(lumberjackEntity_t* enemy, int newIndex) enemy->maxVX = 4; enemy->spriteOffset = 0; enemy->maxLevel = 2; + enemy->scoreValue = 100; enemy->cW = 15; enemy->cH = 15; @@ -91,6 +92,7 @@ void lumberjackUpdateEnemy(lumberjackEntity_t* enemy, int newIndex) enemy->spriteOffset = 7; enemy->maxLevel = 2; enemy->cW = 15; + enemy->scoreValue = 250; enemy->cH = 15; } else if (newIndex == 2) @@ -102,6 +104,7 @@ void lumberjackUpdateEnemy(lumberjackEntity_t* enemy, int newIndex) enemy->spriteOffset = 14; enemy->maxLevel = 2; enemy->cW = 15; + enemy->scoreValue = 500; enemy->cH = 15; } } diff --git a/main/modes/lumberjack/lumberjackEntity.h b/main/modes/lumberjack/lumberjackEntity.h index c0675cc15..84b3f60e4 100644 --- a/main/modes/lumberjack/lumberjackEntity.h +++ b/main/modes/lumberjack/lumberjackEntity.h @@ -32,6 +32,7 @@ typedef struct int type; int maxLevel; int respawn; + int scoreValue; int submergedTimer; int cX; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index f2019aa83..a2e2b86bd 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -76,6 +76,8 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->loaded = false; lumv->gameType = main->gameMode; lumv->onTitle = true; + lumv->enemyKillCount = 0; + lumv->totalEnemyCount = 0; ESP_LOGI(LUM_TAG, "Load Title"); loadWsg("lumbers_title.wsg", &lumv->title, true); @@ -218,6 +220,8 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_enemy_c5.wsg", &lumv->enemySprites[18], true); loadWsg("lumbers_enemy_c6.wsg", &lumv->enemySprites[19], true); loadWsg("lumbers_enemy_c7.wsg", &lumv->enemySprites[20], true); + loadWsg("lumbers_enemy_d1.wsg", &lumv->enemySprites[21], true); + loadWsg("lumbers_enemy_d2.wsg", &lumv->enemySprites[22], true); loadWsg("lumbers_green_ax_block1.wsg", &lumv->greenBlockSprite[0], true); loadWsg("lumbers_green_ax_block2.wsg", &lumv->greenBlockSprite[1], true); @@ -243,6 +247,8 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_normal_ax_block6.wsg", &lumv->unusedBlockSprite[5], true); loadWsg("lumbers_normal_ax_block7.wsg", &lumv->unusedBlockSprite[6], true); + loadWsg("lumbers_item_ui.wsg", &lumv->ui[0], true); + ESP_LOGI(LUM_TAG, "AXE %d", lumv->axeBlocks[0]->active); loadWsg("lumbers_alert.wsg", &lumv->alertSprite, true); @@ -255,7 +261,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) { lumberjackSetupLevel(characterIndex); } - + ESP_LOGI(LUM_TAG, "width %d height %d",TFT_WIDTH, TFT_HEIGHT); } @@ -268,18 +274,26 @@ bool lumberjackLoadLevel(int index) ESP_LOGI(LUM_TAG, "HEIGHT = %d", (int)buffer[0]); // Buffer 0 = map height - lumv->tile = (lumberjackTile_t*)malloc((int)buffer[0] * LUMBERJACK_MAP_WIDTH * sizeof(lumberjackTile_t)); + lumv->tile = (lumberjackTile_t*)malloc((int)buffer[0] * LUMBERJACK_MAP_WIDTH * sizeof(lumberjackTile_t)); lumv->currentMapHeight = (int)buffer[0]; - - lumv->enemy1Count = (int) buffer[1]; - lumv->enemy2Count = (int) buffer[2]; - lumv->enemy3Count = (int) buffer[3]; - lumv->enemy4Count = (int) buffer[4]; - lumv->enemy5Count = (int) buffer[5]; - lumv->enemy6Count = (int) buffer[6]; - lumv->enemy7Count = (int) buffer[7]; - lumv->enemy8Count = (int) buffer[8]; - + lumv->levelTime = 0; + + lumv->enemy1Count = (int) buffer[1]; + lumv->enemy2Count = (int) buffer[2]; + lumv->enemy3Count = (int) buffer[3]; + lumv->enemy4Count = (int) buffer[4]; + lumv->enemy5Count = (int) buffer[5]; + lumv->enemy6Count = (int) buffer[6]; + lumv->enemy7Count = (int) buffer[7]; + lumv->enemy8Count = (int) buffer[8]; + lumv->totalEnemyCount = lumv->enemy1Count; + lumv->totalEnemyCount += lumv->enemy2Count; + lumv->totalEnemyCount += lumv->enemy3Count; + lumv->totalEnemyCount += lumv->enemy4Count; + lumv->totalEnemyCount += lumv->enemy5Count; + lumv->totalEnemyCount += lumv->enemy6Count; + lumv->totalEnemyCount += lumv->enemy7Count; + lumv->totalEnemyCount += lumv->enemy8Count; lumv->waterSpeed = (int)buffer[11]; lumv->waterTimer = (int)buffer[11]; @@ -301,7 +315,7 @@ bool lumberjackLoadLevel(int index) } int offset = (lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH) + 12; - ESP_LOGI (LUM_TAG, "%d",((int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8))); + ESP_LOGI (LUM_TAG, "%d total enemies",lumv->totalEnemyCount); //lumv->tile = &level; lumv->playerSpawnX = (int)buffer[offset]; lumv->playerSpawnY = (int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8); @@ -326,7 +340,10 @@ void lumberjackSetupLevel(int characterIndex) lumv->waterDirection = -1; // This needs to be taken in to account with the intro timer lumv->localPlayer = calloc(1, sizeof(lumberjackEntity_t)); + lumv->localPlayer->scoreValue = 0; + lumv->remotePlayer = calloc(1, sizeof(lumberjackEntity_t)); + lumv->remotePlayer->scoreValue = 0; lumberjackSetupPlayer(lumv->localPlayer, characterIndex); lumberjackSpawnPlayer(lumv->localPlayer, lumv->playerSpawnX, lumv->playerSpawnY, 0); @@ -525,6 +542,7 @@ void baseMode(int64_t elapsedUs) if (!attackThisFrame && lumv->localPlayer->attackPressed) { ESP_LOGI(LUM_TAG, "Attack this frame!"); + lumberjackSendAttack(0); } } @@ -648,6 +666,8 @@ void baseMode(int64_t elapsedUs) { enemy->state = LUMBERJACK_DEAD; // Enemy Death enemy->vy = -30; + lumv->score += enemy->scoreValue; + if (lumv->localPlayer->vx != 0) { enemy->direction = abs(lumv->localPlayer->vx) / lumv->localPlayer->vx; @@ -836,6 +856,7 @@ void DrawGame(void) lumv->remotePlayer->y - lumv->yOffset, false, false, 0); } + drawWsgSimple(&lumv->ui[0], (TFT_WIDTH / 2) - 12, 6); //If playing panic mode draw water lumberjackDrawWaterLevel(); @@ -856,13 +877,9 @@ void DrawGame(void) drawWsgSimple(&lumv->gameoverSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); } - char* score_display = "000"; - - drawText(&lumv->arcade, c000, score_display, 26, 18); - drawText(&lumv->arcade, c000, score_display, 26, 15); - drawText(&lumv->arcade, c000, score_display, 25, 16); - drawText(&lumv->arcade, c000, score_display, 27, 16); - drawText(&lumv->arcade, c555, score_display, 26, 16); + // + lumberjackScoreDisplay(lumv->score, 26); + lumberjackScoreDisplay(9999, 206); // Debug char debug[20] = {0}; @@ -895,6 +912,26 @@ void DrawGame(void) */ } +void lumberjackScoreDisplay(int score, int locationX) +{ + char score_display[20] = {0}; + + if (score > 0) + { + snprintf(score_display, sizeof(score_display), "%d", score); + } + else + { + snprintf(score_display, sizeof(score_display), "000"); + } + + drawText(&lumv->arcade, c000, score_display, locationX, 18); + drawText(&lumv->arcade, c000, score_display, locationX, 15); + drawText(&lumv->arcade, c000, score_display, locationX - 1, 16); + drawText(&lumv->arcade, c000, score_display, locationX + 1, 16); + drawText(&lumv->arcade, c555, score_display, locationX, 16); +} + void lumberjackSpawnCheck(int64_t elapseUs) { if (lumv->spawnTimer >= 0) diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 76f20ce23..b7252966a 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -22,6 +22,8 @@ void lumberjackGameDebugLoop(int64_t elapsedUs); void lumberjackDetectBump(lumberjackTile_t* tile); void lumberjackSpawnCheck(int64_t elapseUs); +void lumberjackScoreDisplay(int score, int locationX); + void baseMode(int64_t elapsedUs); void lumberjackSendAttack(int number); From e31d68cb8adb78da2c555376781f3e7323c42e51 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 7 Oct 2023 12:47:35 -0700 Subject: [PATCH 07/54] Removed onTitle and gameOver bools for a state machine --- main/modes/lumberjack/lumberjack.h | 3 +-- main/modes/lumberjack/lumberjackGame.c | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index ce7d6922a..9b65338bb 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -73,12 +73,11 @@ typedef struct typedef struct { bool loaded; - bool onTitle; // TODO: Make these two one state machine - bool gameOver; // TODO: Make these two one state machine font_t arcade; lumberjack_t* lumberjackMain; menu_t* menu; uint16_t btnState; ///<-- The STOLEN! ;) + lumberjackGameState_t gameState; int yOffset; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index a2e2b86bd..2bc046a6c 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -69,13 +69,12 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->axeBlocks[i]->active = false; } - lumv->gameOver = false; lumv->worldTimer = 0; lumv->liquidAnimationFrame = 0; lumv->stageAnimationFrame = 0; lumv->loaded = false; lumv->gameType = main->gameMode; - lumv->onTitle = true; + lumv->gameState = LUMBERJACK_GAMESTATE_TITLE; lumv->enemyKillCount = 0; lumv->totalEnemyCount = 0; @@ -430,7 +429,7 @@ void lumberjackTitleLoop(int64_t elapsedUs) if (lumv->btnState & PB_A) { - lumv->onTitle = false; + lumv->gameState = LUMBERJACK_GAMESTATE_PLAYING; } //Update Animation @@ -452,7 +451,7 @@ void lumberjackTitleLoop(int64_t elapsedUs) void lumberjackGameLoop(int64_t elapsedUs) { - if (lumv->onTitle == true) + if (lumv->gameState == LUMBERJACK_GAMESTATE_TITLE) { lumberjackTitleLoop(elapsedUs); return; @@ -460,7 +459,7 @@ void lumberjackGameLoop(int64_t elapsedUs) baseMode(elapsedUs); - if (lumv->gameOver) + if (lumv->gameState == LUMBERJACK_GAMESTATE_GAMEOVER) { lumv->transitionTimer -= elapsedUs/10000; @@ -472,7 +471,7 @@ void lumberjackGameLoop(int64_t elapsedUs) } //if panic mode do water - if (lumv->gameOver == false && lumv->gameType == LUMBERJACK_MODE_PANIC) + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING && lumv->gameType == LUMBERJACK_MODE_PANIC) { lumv->waterTimer -= elapsedUs/10000; if (lumv->waterTimer < 0) @@ -547,7 +546,7 @@ void baseMode(int64_t elapsedUs) } } - if (!lumv->gameOver) + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) { for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) { @@ -585,7 +584,7 @@ void baseMode(int64_t elapsedUs) // Check physics lumberjackUpdatePlayerCollision(lumv->localPlayer); - if (!lumv->gameOver) + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) { // Enemy for (int eIdx = 0; eIdx < ARRAY_SIZE(lumv->enemy); eIdx++) @@ -718,7 +717,7 @@ void baseMode(int64_t elapsedUs) } // Update animation - if (!lumv->gameOver) + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) { // Enemy Animation for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) @@ -761,7 +760,7 @@ void lumberjackOnLocalPlayerDeath(void) if (lumv->localPlayer->lives <= 0) { ESP_LOGI(LUM_TAG, "Game over!"); - lumv->gameOver = true; + lumv->gameState = LUMBERJACK_GAMESTATE_GAMEOVER; lumv->transitionTimer = 400; } } @@ -872,7 +871,7 @@ void DrawGame(void) drawWsgSimple(&lumv->minicharacters[icon], (i * 14) + 22, 32); } - if (lumv->gameOver) + if (lumv->gameState == LUMBERJACK_GAMESTATE_GAMEOVER) { drawWsgSimple(&lumv->gameoverSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); } From 8508c830fde49b9e3c20819c52ea6327d4a79919 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 8 Oct 2023 13:01:22 -0700 Subject: [PATCH 08/54] Small level format clean up Removed anim and slowload because I have no idea what those were for Fixed the variable map sizes being cut off Added LUMBERJACK_TILE_SIZE because... Added victory check when completing level to make sure player is on ground Updated level 1 as it is now made with the new Tiled level editor format --- assets/lumbers/lumberjacks_panic_1.bin | Bin 398 -> 398 bytes main/modes/lumberjack/lumberjack.h | 4 +- main/modes/lumberjack/lumberjackGame.c | 227 +++++++++++++++---------- 3 files changed, 138 insertions(+), 93 deletions(-) diff --git a/assets/lumbers/lumberjacks_panic_1.bin b/assets/lumbers/lumberjacks_panic_1.bin index eaccecae68fab1c5473aede5223be3690ea1be53..c0a559d2e93f4872efac1dbfccfe3532027506ae 100644 GIT binary patch delta 36 lcmeBU?qlW=Wo3W?xru_#6BSrDh8Qt&ROm1=ad2|5003VT1qJ{B delta 36 ncmeBU?qlW=WoCc?W@fpGg3c2aST}|kF>=K5F*0#*aloaded = false; lumv->gameType = main->gameMode; lumv->gameState = LUMBERJACK_GAMESTATE_TITLE; - lumv->enemyKillCount = 0; - lumv->totalEnemyCount = 0; ESP_LOGI(LUM_TAG, "Load Title"); loadWsg("lumbers_title.wsg", &lumv->title, true); @@ -315,6 +315,7 @@ bool lumberjackLoadLevel(int index) int offset = (lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH) + 12; ESP_LOGI (LUM_TAG, "%d total enemies",lumv->totalEnemyCount); + ESP_LOGI (LUM_TAG, "%d ", lumv->currentMapHeight* LUMBERJACK_TILE_SIZE); //lumv->tile = &level; lumv->playerSpawnX = (int)buffer[offset]; lumv->playerSpawnY = (int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8); @@ -326,6 +327,10 @@ bool lumberjackLoadLevel(int index) void lumberjackSetupLevel(int characterIndex) { + lumv->enemyKillCount = 0; + lumv->totalEnemyCount = 0; + lumv->hasWon = false; + ESP_LOGI(LUM_TAG, "LOADING LEVEL"); bool levelLoaded = lumberjackLoadLevel(0); @@ -335,7 +340,7 @@ void lumberjackSetupLevel(int characterIndex) lumv->spawnTimer = 2750; lumv->transitionTimer = 0; lumv->spawnSide = 0; - lumv->waterLevel = lumv->currentMapHeight * 16; + lumv->waterLevel = lumv->currentMapHeight * LUMBERJACK_TILE_SIZE; lumv->waterDirection = -1; // This needs to be taken in to account with the intro timer lumv->localPlayer = calloc(1, sizeof(lumberjackEntity_t)); @@ -457,6 +462,21 @@ void lumberjackGameLoop(int64_t elapsedUs) return; } + if (lumv->gameState == LUMBERJACK_GAMESTATE_WINNING) + { + lumv->levelTime += elapsedUs / 1000; + if (lumv->levelTime > 3000) + { + ESP_LOGI(LUM_TAG, "Next level"); + free(lumv->tile); + + lumberjackSetupLevel(0); + + lumv->gameState = LUMBERJACK_GAMESTATE_PLAYING; + } + + } + baseMode(elapsedUs); if (lumv->gameState == LUMBERJACK_GAMESTATE_GAMEOVER) @@ -479,9 +499,9 @@ void lumberjackGameLoop(int64_t elapsedUs) lumv->waterTimer += lumv->waterSpeed; lumv->waterLevel += lumv->waterDirection; - if (lumv->waterLevel > lumv->currentMapHeight * 16) + if (lumv->waterLevel > lumv->currentMapHeight * LUMBERJACK_TILE_SIZE) { - lumv->waterLevel = lumv->currentMapHeight * 16; + lumv->waterLevel = lumv->currentMapHeight * LUMBERJACK_TILE_SIZE; lumv->waterTimer = lumv->waterSpeed * 10; lumv->waterDirection = -1; } @@ -531,23 +551,24 @@ void baseMode(int64_t elapsedUs) } // return; - - // Check Controls - if (lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_UNSPAWNED) + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) { - bool attackThisFrame = lumv->localPlayer->attackPressed; - lumberjackDoControls(); + lumv->levelTime += elapsedUs / 1000; - if (!attackThisFrame && lumv->localPlayer->attackPressed) + // Check Controls + if (lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_UNSPAWNED) { - ESP_LOGI(LUM_TAG, "Attack this frame!"); + bool attackThisFrame = lumv->localPlayer->attackPressed; + lumberjackDoControls(); - lumberjackSendAttack(0); + if (!attackThisFrame && lumv->localPlayer->attackPressed) + { + ESP_LOGI(LUM_TAG, "Attack this frame!"); + + lumberjackSendAttack(0); + } } - } - if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) - { for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) { if (lumv->enemy[enemyIndex] == NULL) @@ -555,6 +576,14 @@ void baseMode(int64_t elapsedUs) lumberjackDoEnemyControls(lumv->enemy[enemyIndex]); } + + if (lumv->localPlayer->onGround && lumv->hasWon) + { + ESP_LOGI(LUM_TAG, "%ld ", (long)lumv->levelTime); + lumv->gameState = LUMBERJACK_GAMESTATE_WINNING; + lumv->localPlayer->state = LUMBERJACK_VICTORY; + lumv->levelTime = 0; + } } // Clear cruft @@ -630,59 +659,72 @@ void baseMode(int64_t elapsedUs) } } - // Player - if (lumv->localPlayer->ready) + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) { - lumv->localPlayer->respawn -= elapsedUs / 10000; - - if (lumv->localPlayer->respawn <= 0 && lumv->localPlayer->lives > 0) + // Player + if (lumv->localPlayer->ready) { - ESP_LOGI(LUM_TAG, "RESPAWN PLAYER!"); - // Respawn player - lumv->localPlayer->respawn = 0; - lumv->localPlayer->lives--; - lumberjackRespawn(lumv->localPlayer); - } - } - else if (lumv->localPlayer->state != LUMBERJACK_OFFSCREEN && lumv->localPlayer->state != LUMBERJACK_VICTORY) - { - lumberjackUpdateEntity(lumv->localPlayer, elapsedUs); + lumv->localPlayer->respawn -= elapsedUs / 10000; - // - for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) + if (lumv->localPlayer->respawn <= 0 && lumv->localPlayer->lives > 0) + { + ESP_LOGI(LUM_TAG, "RESPAWN PLAYER!"); + // Respawn player + lumv->localPlayer->respawn = 0; + lumv->localPlayer->lives--; + lumberjackRespawn(lumv->localPlayer); + } + } + else if (lumv->localPlayer->state != LUMBERJACK_OFFSCREEN && lumv->localPlayer->state != LUMBERJACK_VICTORY) { - lumberjackEntity_t* enemy = lumv->enemy[enemyIndex]; - - if (enemy == NULL || lumv->localPlayer->state == LUMBERJACK_DEAD || lumv->localPlayer->state == LUMBERJACK_INVINCIBLE) - continue; + lumberjackUpdateEntity(lumv->localPlayer, elapsedUs); - if (enemy->state != LUMBERJACK_DEAD && enemy->state != LUMBERJACK_OFFSCREEN) + // + for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) { - // DO AABB checking - if (checkCollision(lumv->localPlayer, enemy)) + lumberjackEntity_t* enemy = lumv->enemy[enemyIndex]; + + if (enemy == NULL || lumv->localPlayer->state == LUMBERJACK_DEAD || lumv->localPlayer->state == LUMBERJACK_INVINCIBLE) + continue; + + if (enemy->state != LUMBERJACK_DEAD && enemy->state != LUMBERJACK_OFFSCREEN) { - if (enemy->state == LUMBERJACK_BUMPED || enemy->state == LUMBERJACK_BUMPED_IDLE) + // DO AABB checking + if (checkCollision(lumv->localPlayer, enemy)) { - enemy->state = LUMBERJACK_DEAD; // Enemy Death - enemy->vy = -30; - lumv->score += enemy->scoreValue; - - if (lumv->localPlayer->vx != 0) + if (enemy->state == LUMBERJACK_BUMPED || enemy->state == LUMBERJACK_BUMPED_IDLE) { - enemy->direction = abs(lumv->localPlayer->vx) / lumv->localPlayer->vx; + enemy->state = LUMBERJACK_DEAD; // Enemy Death + enemy->vy = -30; + lumv->score += enemy->scoreValue; + + //if game mode is single player decide if you're going to clear the level + lumv->enemyKillCount ++; + + if (lumv->enemyKillCount >= lumv->totalEnemyCount) + { + //And game mode == blah + //lumv->gameState = LUMBERJACK_GAMESTATE_WINNING; + lumv->hasWon = true; + } + + if (lumv->localPlayer->vx != 0) + { + enemy->direction = abs(lumv->localPlayer->vx) / lumv->localPlayer->vx; + } + else + { + enemy->direction = 0; + } + enemy->vx = enemy->direction * 10; + enemy->active = false; } else { - enemy->direction = 0; + // Kill player + // ESP_LOGI(LUM_TAG, "KILL PLAYER"); + lumberjackOnLocalPlayerDeath(); } - enemy->vx = enemy->direction * 10; - enemy->active = false; - } - else - { - // Kill player - // ESP_LOGI(LUM_TAG, "KILL PLAYER"); - lumberjackOnLocalPlayerDeath(); } } } @@ -699,26 +741,29 @@ void baseMode(int64_t elapsedUs) lumv->stageAnimationFrame++; } - //if Panic mode... check to see if player's head is under water. - if (lumv->localPlayer->y > lumv->waterLevel && lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_OFFSCREEN) - { - //ESP_LOGW(LUM_TAG, "UNDER WATER! %d", lumv->localPlayer->submergedTimer); - lumv->localPlayer->submergedTimer -= elapsedUs / 10000; + - if (lumv->localPlayer->submergedTimer <= 0) + // Update animation + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) + { + //if Panic mode... check to see if player's head is under water. + if (lumv->localPlayer->y > lumv->waterLevel && lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_OFFSCREEN) { - lumv->localPlayer->submergedTimer = 0; - lumberjackOnLocalPlayerDeath(); + //ESP_LOGW(LUM_TAG, "UNDER WATER! %d", lumv->localPlayer->submergedTimer); + lumv->localPlayer->submergedTimer -= elapsedUs / 10000; + + if (lumv->localPlayer->submergedTimer <= 0) + { + lumv->localPlayer->submergedTimer = 0; + lumberjackOnLocalPlayerDeath(); + } } - } - else - { - lumv->localPlayer->submergedTimer = LUMBERJACK_SUBMERGE_TIMER; - } + else + { + lumv->localPlayer->submergedTimer = LUMBERJACK_SUBMERGE_TIMER; + } + - // Update animation - if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) - { // Enemy Animation for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) { @@ -745,8 +790,10 @@ void baseMode(int64_t elapsedUs) lumv->yOffset = lumv->localPlayer->y - LUMBERJACK_SCREEN_Y_OFFSET; if (lumv->yOffset < LUMBERJACK_SCREEN_Y_MIN) lumv->yOffset = LUMBERJACK_SCREEN_Y_MIN; - if (lumv->yOffset > LUMBERJACK_SCREEN_Y_MAX) - lumv->yOffset = LUMBERJACK_SCREEN_Y_MAX; + + // + if (lumv->yOffset > (lumv->currentMapHeight * LUMBERJACK_TILE_SIZE) - TFT_HEIGHT) + lumv->yOffset = (lumv->currentMapHeight * LUMBERJACK_TILE_SIZE) - TFT_HEIGHT; } void lumberjackOnLocalPlayerDeath(void) @@ -780,8 +827,8 @@ void DrawTitle(void) for (int i = 0; i < LUMBERJACK_MAP_WIDTH; i++) { - drawWsgSimple(&lumv->floorTiles[1], i * 16, 208); - drawWsgSimple(&lumv->floorTiles[7], i * 16, 224); + drawWsgSimple(&lumv->floorTiles[1], i * LUMBERJACK_TILE_SIZE, 208); + drawWsgSimple(&lumv->floorTiles[7], i * LUMBERJACK_TILE_SIZE, 224); } drawWsgSimple(&lumv->unusedBlockSprite[lumv->stageAnimationFrame % LUMBERJACK_BLOCK_ANIMATION_MAX], 8.5 * 16, 208 - 64); @@ -1090,7 +1137,7 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs if (lumberjackIsCollisionTile(tileA->type) || lumberjackIsCollisionTile(tileB->type)) { - destinationY = ((tileA->y + 1) * 16); + destinationY = ((tileA->y + 1) * LUMBERJACK_TILE_SIZE); entity->jumpTimer = 0; entity->jumping = false; entity->vy = 0; @@ -1120,7 +1167,7 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs if ((tileA != NULL && lumberjackIsCollisionTile(tileA->type)) || (tileB != NULL && lumberjackIsCollisionTile(tileB->type))) { - destinationY = ((tileA->y - entity->tileHeight) * 16); + destinationY = ((tileA->y - entity->tileHeight) * LUMBERJACK_TILE_SIZE); entity->vy = 0; onGround = true; } @@ -1136,9 +1183,9 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs entity->x = destinationX; entity->y = destinationY; - if (entity->y > 350) + if (entity->y > lumv->currentMapHeight * LUMBERJACK_TILE_SIZE) { - entity->y = 350; + entity->y = lumv->currentMapHeight * LUMBERJACK_TILE_SIZE; entity->active = false; if (entity->state == LUMBERJACK_DEAD) { @@ -1206,13 +1253,13 @@ void lumberjackTileMap(void) int tileIndex = lumv->tile[index].type; int offset = lumv->tile[index].offset; - if ((y * 16) - lumv->yOffset >= -16) + if ((y * LUMBERJACK_TILE_SIZE) - lumv->yOffset >= -16) { if (tileIndex > 0 && tileIndex < 13) { if (tileIndex < 11) { - drawWsgSimple(&lumv->floorTiles[tileIndex - 1], x * 16, (y * 16) - lumv->yOffset - offset); + drawWsgSimple(&lumv->floorTiles[tileIndex - 1], x * LUMBERJACK_TILE_SIZE, (y * LUMBERJACK_TILE_SIZE) - lumv->yOffset - offset); } } } @@ -1226,10 +1273,10 @@ void lumberjackDrawWaterLevel(void) //If GameMode is Panic... draw the water for (int i = 0; i < LUMBERJACK_MAP_WIDTH; i++) { - drawWsgSimple(&lumv->animationTiles[lumv->liquidAnimationFrame], i * 16, lumv->waterLevel - lumv->yOffset); + drawWsgSimple(&lumv->animationTiles[lumv->liquidAnimationFrame], i * LUMBERJACK_TILE_SIZE, lumv->waterLevel - lumv->yOffset); } - fillDisplayArea(0, lumv->waterLevel + 16 - lumv->yOffset, TFT_WIDTH, ((lumv->currentMapHeight+1) * 16)- lumv->yOffset , c134); + fillDisplayArea(0, lumv->waterLevel + 16 - lumv->yOffset, TFT_WIDTH, ((lumv->currentMapHeight+1) * LUMBERJACK_TILE_SIZE)- lumv->yOffset , c134); } @@ -1310,8 +1357,8 @@ void lumberjackDoControls(void) static lumberjackTile_t* lumberjackGetTile(int x, int y) { - int tx = (int)x / 16; - int ty = (int)y / 16; + int tx = (int)x / LUMBERJACK_TILE_SIZE; + int ty = (int)y / LUMBERJACK_TILE_SIZE; if (tx < 0) tx = 17; @@ -1374,9 +1421,9 @@ void lumberjackDetectBump(lumberjackTile_t* tile) if (enemy->onGround || enemy->flying) { - int tx = ((enemy->x - 8) / 16); - int ty = ((enemy->y) / 16) + 1; - int tx2 = ((enemy->x + 8) / 16); + int tx = ((enemy->x - 8) / LUMBERJACK_TILE_SIZE); + int ty = ((enemy->y) / LUMBERJACK_TILE_SIZE) + 1; + int tx2 = ((enemy->x + 8) / LUMBERJACK_TILE_SIZE); if (tx < 0) tx = 0; From 302ebc013fe97e8f9d763400c8e9cc7400a6186f Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 8 Oct 2023 16:16:21 -0700 Subject: [PATCH 09/54] Adding level continuation Continue on victory Loads multiple levels Spawnx set by file instead of magic number Added level exporting to tool --- assets/lumbers/lumberjacks_panic_2.bin | Bin 390 -> 398 bytes assets/lumbers/lumberjacks_panic_3.bin | Bin 0 -> 398 bytes assets/lumbers/lumberjacks_panic_4.bin | Bin 0 -> 740 bytes main/modes/lumberjack/lumberjack.h | 1 + main/modes/lumberjack/lumberjackGame.c | 26 ++-- main/modes/lumberjack/lumberjackPlayer.c | 4 +- main/modes/lumberjack/lumberjackPlayer.h | 4 +- tools/lumber_jacks/base.tmx | 57 +++++++++ .../exporter/lumberjacks-editor.js | 119 ++++++++++++++++++ tools/lumber_jacks/lumberjackTileset.tsx | 34 +++++ tools/lumber_jacks/tiles/bottom_floor1.png | Bin 0 -> 129 bytes tools/lumber_jacks/tiles/bottom_floor10.png | Bin 0 -> 106 bytes tools/lumber_jacks/tiles/bottom_floor2.png | Bin 0 -> 149 bytes tools/lumber_jacks/tiles/bottom_floor3.png | Bin 0 -> 194 bytes tools/lumber_jacks/tiles/bottom_floor4.png | Bin 0 -> 165 bytes tools/lumber_jacks/tiles/bottom_floor5.png | Bin 0 -> 125 bytes tools/lumber_jacks/tiles/bottom_floor6.png | Bin 0 -> 108 bytes tools/lumber_jacks/tiles/bottom_floor7.png | Bin 0 -> 132 bytes tools/lumber_jacks/tiles/bottom_floor8.png | Bin 0 -> 124 bytes tools/lumber_jacks/tiles/bottom_floor9.png | Bin 0 -> 130 bytes 20 files changed, 233 insertions(+), 12 deletions(-) create mode 100644 assets/lumbers/lumberjacks_panic_3.bin create mode 100644 assets/lumbers/lumberjacks_panic_4.bin create mode 100644 tools/lumber_jacks/base.tmx create mode 100644 tools/lumber_jacks/exporter/lumberjacks-editor.js create mode 100644 tools/lumber_jacks/lumberjackTileset.tsx create mode 100644 tools/lumber_jacks/tiles/bottom_floor1.png create mode 100644 tools/lumber_jacks/tiles/bottom_floor10.png create mode 100644 tools/lumber_jacks/tiles/bottom_floor2.png create mode 100644 tools/lumber_jacks/tiles/bottom_floor3.png create mode 100644 tools/lumber_jacks/tiles/bottom_floor4.png create mode 100644 tools/lumber_jacks/tiles/bottom_floor5.png create mode 100644 tools/lumber_jacks/tiles/bottom_floor6.png create mode 100644 tools/lumber_jacks/tiles/bottom_floor7.png create mode 100644 tools/lumber_jacks/tiles/bottom_floor8.png create mode 100644 tools/lumber_jacks/tiles/bottom_floor9.png diff --git a/assets/lumbers/lumberjacks_panic_2.bin b/assets/lumbers/lumberjacks_panic_2.bin index 58008b54674067779f26d2e9c6a227f97b375446..81a203cb24ede17113afbe70b94662035ad343ec 100644 GIT binary patch literal 398 zcmWe-Wq<)W7y}>80tOHj$ZULiu*tEo07W4NK$+N75iQ0H1W?65Ly@(iagn9)v%!vo lDM8`D1c{@WAOIN7j8G;A7;thiFtD*h*a(8B^Ke?GAzsT1(XN}XJm8_VM%sh)&i7ntHTo%A3?XUekgle& zL6&W@@5msBloaded = false; lumv->gameType = main->gameMode; lumv->gameState = LUMBERJACK_GAMESTATE_TITLE; + lumv->levelIndex = 0; ESP_LOGI(LUM_TAG, "Load Title"); loadWsg("lumbers_title.wsg", &lumv->title, true); @@ -264,9 +264,16 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) ESP_LOGI(LUM_TAG, "width %d height %d",TFT_WIDTH, TFT_HEIGHT); } -bool lumberjackLoadLevel(int index) +bool lumberjackLoadLevel() { - char* fname = "lumberjacks_panic_1.bin"; + char* levelName[] = + { + "lumberjacks_panic_1.bin", + "lumberjacks_panic_2.bin", + "lumberjacks_panic_3.bin", + "lumberjacks_panic_4.bin" + }; + char* fname = levelName[lumv->levelIndex % 4]; size_t ms; uint8_t *buffer = spiffsReadFile(fname, &ms, false); @@ -319,7 +326,7 @@ bool lumberjackLoadLevel(int index) //lumv->tile = &level; lumv->playerSpawnX = (int)buffer[offset]; lumv->playerSpawnY = (int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8); - + ESP_LOGI(LUM_TAG, "%d %d", lumv->playerSpawnX, buffer[offset]); return true; } @@ -332,7 +339,7 @@ void lumberjackSetupLevel(int characterIndex) lumv->hasWon = false; ESP_LOGI(LUM_TAG, "LOADING LEVEL"); - bool levelLoaded = lumberjackLoadLevel(0); + bool levelLoaded = lumberjackLoadLevel(); // This all to be loaded externally lumv->yOffset = 0; @@ -419,7 +426,8 @@ void lumberjackSetupLevel(int characterIndex) void restartLevel(void) { lumv->localPlayer->lives--; - lumberjackRespawn(lumv->localPlayer); + lumberjackRespawn(lumv->localPlayer, lumv->playerSpawnX); + } void lumberjackTitleLoop(int64_t elapsedUs) @@ -583,6 +591,7 @@ void baseMode(int64_t elapsedUs) lumv->gameState = LUMBERJACK_GAMESTATE_WINNING; lumv->localPlayer->state = LUMBERJACK_VICTORY; lumv->levelTime = 0; + lumv->levelIndex++; } } @@ -672,7 +681,8 @@ void baseMode(int64_t elapsedUs) // Respawn player lumv->localPlayer->respawn = 0; lumv->localPlayer->lives--; - lumberjackRespawn(lumv->localPlayer); + + lumberjackRespawn(lumv->localPlayer, lumv->playerSpawnX); } } else if (lumv->localPlayer->state != LUMBERJACK_OFFSCREEN && lumv->localPlayer->state != LUMBERJACK_VICTORY) diff --git a/main/modes/lumberjack/lumberjackPlayer.c b/main/modes/lumberjack/lumberjackPlayer.c index 7c09a9878..a7cbbf184 100644 --- a/main/modes/lumberjack/lumberjackPlayer.c +++ b/main/modes/lumberjack/lumberjackPlayer.c @@ -45,9 +45,9 @@ void lumberjackSpawnPlayer(lumberjackEntity_t* hero, int x, int y, int facing) hero->respawn = 0; } -void lumberjackRespawn(lumberjackEntity_t* hero) +void lumberjackRespawn(lumberjackEntity_t* hero, int x) { - hero->x = 130; + hero->x = x; hero->maxVX = 15; hero->y = LUMBERJACK_SPAWN_Y; hero->active = true; diff --git a/main/modes/lumberjack/lumberjackPlayer.h b/main/modes/lumberjack/lumberjackPlayer.h index dff11ff6c..2dc5bcecf 100644 --- a/main/modes/lumberjack/lumberjackPlayer.h +++ b/main/modes/lumberjack/lumberjackPlayer.h @@ -4,8 +4,8 @@ #include "lumberjack_types.h" void lumberjackSpawnPlayer(lumberjackEntity_t* hero, int x, int y, int facing); -void lumberjackRespawn(lumberjackEntity_t* hero); +void lumberjackRespawn(lumberjackEntity_t* hero, int x); int lumberjackGetPlayerAnimation(lumberjackEntity_t* hero); void lumberjackSetupPlayer(lumberjackEntity_t* hero, int character); -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/tools/lumber_jacks/base.tmx b/tools/lumber_jacks/base.tmx new file mode 100644 index 000000000..feb0118ae --- /dev/null +++ b/tools/lumber_jacks/base.tmx @@ -0,0 +1,57 @@ + + + + + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +3,3,3,3,0,0,0,3,3,3,0,0,0,3,3,3,3,3, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +3,3,3,3,3,3,3,0,0,0,0,0,0,0,3,3,3,3, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +3,3,3,3,0,0,0,0,0,0,0,0,3,3,3,3,3,3, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,3,3,3,3,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,3,3, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,3,3,3,3,3,3,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +4,4,4,4,4,4,0,0,0,0,0,0,4,4,4,4,4,4, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, +8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 + + + + + + + + + diff --git a/tools/lumber_jacks/exporter/lumberjacks-editor.js b/tools/lumber_jacks/exporter/lumberjacks-editor.js new file mode 100644 index 000000000..4898d14c1 --- /dev/null +++ b/tools/lumber_jacks/exporter/lumberjacks-editor.js @@ -0,0 +1,119 @@ +tiled.registerMapFormat("Lumber Jacks", { + name: "Lumber Jacks map format", + extension: "bin", + read: (fileName) => { + var file = new BinaryFile(fileName, BinaryFile.ReadOnly); + var filePath = FileInfo.path(fileName); + var buffer = file.read(file.size); + var view = new Uint8Array(buffer); + const tileDataOffset = 12; + const tileSizeInPixels = 16; + + var map = new TileMap(); + + //The first two bytes contain the width and height of the tilemap in tiles + var tileDataLength = 18 * view[0]; + map.setSize(18, view[0]); + map.setTileSize(tileSizeInPixels, tileSizeInPixels); + + var tileset = tiled.open(filePath + '/lumberjacks.tsx'); + + var layer = new TileLayer(); + + map.addTileset(tileset); + + layer.width = map.width; + layer.height = map.height; + layer.name = 'Main'; + + var layerEdit = layer.edit(); + var importTileX = 0; + var importTileY = 0; + + + //Import tile data + for(let i = 0; i < tileDataLength; i++){ + let tileId = view[i + tileDataOffset]; + layerEdit.setTile(importTileX, importTileY, tileset.tile(tileId)); + + importTileX++; + if(importTileX >= map.width){ + importTileY++; + importTileX=0; + } + } + + layerEdit.apply(); + + map.addLayer(layer); + file.close(); + return map; + }, + write: (map, fileName) => { + let file = new BinaryFile(filename, BinaryFile.WriteOnly); + let buffer = new ArrayBuffer(20 + layer.height * layer.width); + let view = new Uint8Array(buffer); + + view[0] = layer.height; + view[1] = 3; //Enemy 1 + view[2] = 0; //Enemy 2 + view[3] = 0; //Enemy 3 + view[4] = 0; //Enemy 4 + view[5] = 0; //Enemy 5 + view[6] = 0; //Enemy 6 + view[7] = 0; //Enemy 7 + view[8] = 0; //Enemy 8 + view[9] = 0; // + view[10] = 0; // + view[11] = 30; //Time + + //write level + const layer = map.layerAt(0); + let writePosition = 12; + for (let y = 0; y 256 + view [writePosition+1] = 30; + view [writePosition+2] = 0; + /* + + //The last 2 bytes hold the total number of "target block tiles" + //Forced into a (hopefully) unsigned 16 bit integer, little endian + //There's probably a better way to do this... + let totalTargetBlockTilesLowerByte = totalTargetBlockTiles & 255; + let totalTargetBlockTilesUpperByte = (totalTargetBlockTiles >> 8) & 255; + view[writePosition] = totalTargetBlockTilesLowerByte; + writePosition++; + view[writePosition] = totalTargetBlockTilesUpperByte; + writePosition++; + */ + + + view [writePosition+3] = 2; //Number of switches + view [writePosition+4] = 8; //WTF Troy? + view [writePosition+5] = 9; //WTF Troy? + view [writePosition+6] = 8; //WTF Troy? + view [writePosition+7] = 4; //WTF Troy? + + file.write(buffer); + file.commit(); + } + }, +); \ No newline at end of file diff --git a/tools/lumber_jacks/lumberjackTileset.tsx b/tools/lumber_jacks/lumberjackTileset.tsx new file mode 100644 index 000000000..1014422c7 --- /dev/null +++ b/tools/lumber_jacks/lumberjackTileset.tsx @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/lumber_jacks/tiles/bottom_floor1.png b/tools/lumber_jacks/tiles/bottom_floor1.png new file mode 100644 index 0000000000000000000000000000000000000000..b5c5e54d09b6a4ba883abb67435509a9292b75e1 GIT binary patch literal 129 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|tUX;ELo9le z(-ed?+J72#)ILp2P`l2salH*sy(o)B#0k@e#>R*CpPTu4d_*J;0D(c)ffbC4*&G-d Y-ukjjEDt$(7HABEr>mdKI;Vst0D8(N4*&oF literal 0 HcmV?d00001 diff --git a/tools/lumber_jacks/tiles/bottom_floor10.png b/tools/lumber_jacks/tiles/bottom_floor10.png new file mode 100644 index 0000000000000000000000000000000000000000..912565bedfee79c3cd4fd014963ebabd801e809b GIT binary patch literal 106 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|R6JcALo9le zL&6Pyoo8U|F_)i{tRQMIaZU1-hCpUFUWp|@ov}+;6gK9*Uky~x;OXk;vd$@?2>|)s B8`A&) literal 0 HcmV?d00001 diff --git a/tools/lumber_jacks/tiles/bottom_floor2.png b/tools/lumber_jacks/tiles/bottom_floor2.png new file mode 100644 index 0000000000000000000000000000000000000000..6cc50cf56535edaaf22e66a5319c1982b2835931 GIT binary patch literal 149 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|{5@S9Lo9le zL&6Pyop)eNSma{N3+l#s? t)0akE@jCwE>;D|6ZcJj9V7D=6Vz_cf%%7LB@+{D322WQ%mvv4FO#tTBEsOvF literal 0 HcmV?d00001 diff --git a/tools/lumber_jacks/tiles/bottom_floor3.png b/tools/lumber_jacks/tiles/bottom_floor3.png new file mode 100644 index 0000000000000000000000000000000000000000..8c374a903f6512350ca438b136aab094f6b2e25d GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|YCK&WLo9le zL&6Pyop)eNSma{N3jP5^=nFMheCiXX_?m(y}r)nImc zt{t;z;Nnf(7h;(<3$h8AEoSP9HTb}m(88FO;oQ))N(E%t;pW@tGoLWUm>p&~lQzR! iVqNe_)*j}0(u}9iDY12WwHN^1!QkoY=d#Wzp$P!f$v;p4 literal 0 HcmV?d00001 diff --git a/tools/lumber_jacks/tiles/bottom_floor4.png b/tools/lumber_jacks/tiles/bottom_floor4.png new file mode 100644 index 0000000000000000000000000000000000000000..977d0fed955cbd7e804f25dcf2a72a3f685faed5 GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|;yqm)Lo9le zL&6Pyop)eNSma{N3jP5^=nFMheCiXX^nyV=0~=2i{c zsi4Ju+-|%QJZuLpGwS>k{MaL_vBJwq;`+)bOvf0{_cH9fE%<`dO++7P6@#a%pUXO@ GgeCxH95!_T literal 0 HcmV?d00001 diff --git a/tools/lumber_jacks/tiles/bottom_floor5.png b/tools/lumber_jacks/tiles/bottom_floor5.png new file mode 100644 index 0000000000000000000000000000000000000000..ad46a896ccea6031d0c86aeb8a7e1a5307b9e950 GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|%spKkLo9le z1HuiG0=z$`D2N;Uz5XaU;m+4dj^xl@Lo9le z_sm@WYd#~V&5pk^GfyvApmnmre_m&!lfehJ4J$G|9)~(;_^{pMp3;7Bt+an2i`!*J dH3>$beiJ)!JNfy|8-OM;c)I$ztaD0e0sxNnDG&ev literal 0 HcmV?d00001 diff --git a/tools/lumber_jacks/tiles/bottom_floor8.png b/tools/lumber_jacks/tiles/bottom_floor8.png new file mode 100644 index 0000000000000000000000000000000000000000..3b3d39e707293a871ed51477030ab57a0957b36e GIT binary patch literal 124 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|%sgEjLo9le z_sm@WYd#~V&5pk^GfyvApmnmre_m&!lfehJ4HI6am;7w}&h#|VVby&1%Lh03ursJk Wk}@_qc;E}r1O`u6KbLh*2~7aDE-JGC literal 0 HcmV?d00001 diff --git a/tools/lumber_jacks/tiles/bottom_floor9.png b/tools/lumber_jacks/tiles/bottom_floor9.png new file mode 100644 index 0000000000000000000000000000000000000000..ca8915fe97fd7d7eca68468c2cf09acafe0c24bc GIT binary patch literal 130 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|Y&=~YLo9le z_sm@WYd#~V&5pk^GfyvApmnmre_m&!lfehJ4HI5HFAlE{yw1v;&%mu{zxcGVLC>=0 c#2I`HrZZ)}wK~4v12l)h)78&qol`;+0C`m_DgXcg literal 0 HcmV?d00001 From 1cc576a6f7b6caad56828de38a6dfaebc9058fc0 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 8 Oct 2023 18:52:43 -0700 Subject: [PATCH 10/54] Additional level updates Added level index display Fixed levels looping around not properly upgrading enemies Made network mode NOT take upgrades in to account Fixed memory problem with enemies between levels Made levels consistent between levels. --- main/modes/lumberjack/lumberjack.h | 2 + main/modes/lumberjack/lumberjackEntity.c | 5 + main/modes/lumberjack/lumberjackGame.c | 145 ++++++++++++++++++----- main/modes/lumberjack/lumberjackGame.h | 1 + main/modes/lumberjack/lumberjackPlayer.c | 1 - 5 files changed, 125 insertions(+), 29 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 1144d2628..3f8f4deb2 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -82,6 +82,8 @@ typedef struct int yOffset; int levelIndex; + int upgrade; + int lives; int64_t worldTimer; int64_t levelTime; diff --git a/main/modes/lumberjack/lumberjackEntity.c b/main/modes/lumberjack/lumberjackEntity.c index cc91fd300..fae79c0d4 100644 --- a/main/modes/lumberjack/lumberjackEntity.c +++ b/main/modes/lumberjack/lumberjackEntity.c @@ -79,6 +79,7 @@ void lumberjackUpdateEnemy(lumberjackEntity_t* enemy, int newIndex) enemy->spriteOffset = 0; enemy->maxLevel = 2; enemy->scoreValue = 100; + enemy->type = newIndex; enemy->cW = 15; enemy->cH = 15; @@ -94,6 +95,8 @@ void lumberjackUpdateEnemy(lumberjackEntity_t* enemy, int newIndex) enemy->cW = 15; enemy->scoreValue = 250; enemy->cH = 15; + enemy->type = newIndex; + } else if (newIndex == 2) { @@ -106,6 +109,8 @@ void lumberjackUpdateEnemy(lumberjackEntity_t* enemy, int newIndex) enemy->cW = 15; enemy->scoreValue = 500; enemy->cH = 15; + enemy->type = newIndex; + } } diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 8f71c6867..b80bb5aae 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -35,6 +35,8 @@ #define LUMBERJACK_MAP_WIDTH 18 #define LUMBERJACK_BLOCK_ANIMATION_MAX 7 #define LUMBERJACK_RESPAWN_TIMER 3750 +#define LUMBERJACK_RESPAWN_MIN 1250 +#define LUMBERJACK_UPGRADE_TIMER_OFFSET 250 #define LUMBERJACK_SUBMERGE_TIMER 300 #define LUMBERJACK_TILE_SIZE 16 @@ -77,6 +79,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->gameType = main->gameMode; lumv->gameState = LUMBERJACK_GAMESTATE_TITLE; lumv->levelIndex = 0; + lumv->lives = 3; ESP_LOGI(LUM_TAG, "Load Title"); loadWsg("lumbers_title.wsg", &lumv->title, true); @@ -266,19 +269,35 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) bool lumberjackLoadLevel() { - char* levelName[] = + char* fname = "lumberjacks_panic_4.bin"; + + lumv->upgrade = 0; + if (lumv->gameType == LUMBERJACK_MODE_PANIC) { - "lumberjacks_panic_1.bin", - "lumberjacks_panic_2.bin", - "lumberjacks_panic_3.bin", - "lumberjacks_panic_4.bin" - }; - char* fname = levelName[lumv->levelIndex % 4]; + + char* levelName[] = + { + "lumberjacks_panic_1.bin", + "lumberjacks_panic_2.bin", + "lumberjacks_panic_3.bin", + "lumberjacks_panic_4.bin" + }; + ESP_LOGI(LUM_TAG, "Level # %d", (int)(lumv->levelIndex % ARRAY_SIZE(levelName))); + fname = levelName[lumv->levelIndex % ARRAY_SIZE(levelName)]; + + if (!lumv->lumberjackMain->networked) + { + lumv->upgrade = (int)(lumv->levelIndex / ARRAY_SIZE(levelName)); + } + } + + + size_t ms; uint8_t *buffer = spiffsReadFile(fname, &ms, false); - ESP_LOGI(LUM_TAG, "HEIGHT = %d", (int)buffer[0]); + ESP_LOGI(LUM_TAG, "Level = %s", fname); // Buffer 0 = map height lumv->tile = (lumberjackTile_t*)malloc((int)buffer[0] * LUMBERJACK_MAP_WIDTH * sizeof(lumberjackTile_t)); lumv->currentMapHeight = (int)buffer[0]; @@ -292,7 +311,7 @@ bool lumberjackLoadLevel() lumv->enemy6Count = (int) buffer[6]; lumv->enemy7Count = (int) buffer[7]; lumv->enemy8Count = (int) buffer[8]; - lumv->totalEnemyCount = lumv->enemy1Count; + lumv->totalEnemyCount = lumv->enemy1Count; lumv->totalEnemyCount += lumv->enemy2Count; lumv->totalEnemyCount += lumv->enemy3Count; lumv->totalEnemyCount += lumv->enemy4Count; @@ -301,6 +320,20 @@ bool lumberjackLoadLevel() lumv->totalEnemyCount += lumv->enemy7Count; lumv->totalEnemyCount += lumv->enemy8Count; + + if (lumv->upgrade == 1) + { + lumv->enemy3Count += lumv->enemy2Count; + lumv->enemy2Count = lumv->enemy1Count; + lumv->enemy1Count = 0; // + } + else if (lumv->upgrade >= 2) + { + lumv->enemy3Count += lumv->enemy2Count + lumv->enemy1Count; + lumv->enemy2Count = 0; + lumv->enemy1Count = 0; + } + lumv->waterSpeed = (int)buffer[11]; lumv->waterTimer = (int)buffer[11]; @@ -312,12 +345,7 @@ bool lumberjackLoadLevel() lumv->tile[i].type = (int)buffer[i+12]; lumv->tile[i].offset = 0; lumv->tile[i].offset_time = 0; - - if (i < 10) - { - ESP_LOGI(LUM_TAG, "Tile = %d", lumv->tile[i].x); - } - + } int offset = (lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH) + 12; @@ -361,9 +389,13 @@ void lumberjackSetupLevel(int characterIndex) strcpy(lumv->localPlayer->name, " Dennis"); // If you see this... this name means nothing int offset = 0; + //Load enemies + + // START ENEMY 1 for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy1Count; eSpawnIndex++) { + ESP_LOGI(LUM_TAG, ":D %d %d", eSpawnIndex, lumv->enemy1Count); lumv->enemy[eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); lumberjackSetupEnemy(lumv->enemy[eSpawnIndex], 0); } @@ -372,15 +404,17 @@ void lumberjackSetupLevel(int characterIndex) for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy2Count; eSpawnIndex++) { lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); - lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 1); } offset += lumv->enemy2Count; for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy3Count; eSpawnIndex++) { lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); - lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 2); } + //END ENEMY 1 + offset += lumv->enemy3Count; for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy4Count; eSpawnIndex++) @@ -420,12 +454,24 @@ void lumberjackSetupLevel(int characterIndex) ESP_LOGI(LUM_TAG, "LOADED"); } +void lumberjackUnloadLevel(void) +{ + free(lumv->tile); + + //Unload previous enemies + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + { + free(lumv->enemy[i]); + lumv->enemy[i] = NULL; + } +} + /** * @brief TODO use this somewhere */ void restartLevel(void) { - lumv->localPlayer->lives--; + lumv->lives--; lumberjackRespawn(lumv->localPlayer, lumv->playerSpawnX); } @@ -476,7 +522,7 @@ void lumberjackGameLoop(int64_t elapsedUs) if (lumv->levelTime > 3000) { ESP_LOGI(LUM_TAG, "Next level"); - free(lumv->tile); + lumberjackUnloadLevel(); lumberjackSetupLevel(0); @@ -505,7 +551,7 @@ void lumberjackGameLoop(int64_t elapsedUs) if (lumv->waterTimer < 0) { lumv->waterTimer += lumv->waterSpeed; - lumv->waterLevel += lumv->waterDirection; + lumv->waterLevel += lumv->waterDirection * (lumv->upgrade + 1); if (lumv->waterLevel > lumv->currentMapHeight * LUMBERJACK_TILE_SIZE) { @@ -675,12 +721,12 @@ void baseMode(int64_t elapsedUs) { lumv->localPlayer->respawn -= elapsedUs / 10000; - if (lumv->localPlayer->respawn <= 0 && lumv->localPlayer->lives > 0) + if (lumv->localPlayer->respawn <= 0 && lumv->lives > 0) { ESP_LOGI(LUM_TAG, "RESPAWN PLAYER!"); // Respawn player lumv->localPlayer->respawn = 0; - lumv->localPlayer->lives--; + lumv->lives--; lumberjackRespawn(lumv->localPlayer, lumv->playerSpawnX); } @@ -814,7 +860,7 @@ void lumberjackOnLocalPlayerDeath(void) lumv->localPlayer->jumping = false; lumv->localPlayer->jumpTimer = 0; - if (lumv->localPlayer->lives <= 0) + if (lumv->lives <= 0) { ESP_LOGI(LUM_TAG, "Game over!"); lumv->gameState = LUMBERJACK_GAMESTATE_GAMEOVER; @@ -917,7 +963,7 @@ void DrawGame(void) lumberjackDrawWaterLevel(); - for (int i = 0; i < lumv->localPlayer->lives; i++) + for (int i = 0; i < lumv->lives; i++) { int icon = lumv->localPlayer->type; @@ -936,6 +982,29 @@ void DrawGame(void) // lumberjackScoreDisplay(lumv->score, 26); lumberjackScoreDisplay(9999, 206); + + + + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING && lumv->levelTime < 5000) + { + char level_display[20] = {0}; + + if (lumv->levelIndex < 9) + { + snprintf(level_display, sizeof(level_display), "Level 0%d", (lumv->levelIndex + 1)); + } + else + { + snprintf(level_display, sizeof(level_display), "Level %d", (lumv->levelIndex + 1)); + } + + drawText(&lumv->arcade, c000, level_display, (TFT_WIDTH/2) - 36, TFT_HEIGHT - 18); + drawText(&lumv->arcade, c000, level_display, (TFT_WIDTH/2) - 36, TFT_HEIGHT - 21); + drawText(&lumv->arcade, c000, level_display, (TFT_WIDTH/2) - 36 - 1, TFT_HEIGHT - 20); + drawText(&lumv->arcade, c000, level_display, (TFT_WIDTH/2) - 36 + 1, TFT_HEIGHT - 20); + drawText(&lumv->arcade, c555, level_display, (TFT_WIDTH/2) - 36, TFT_HEIGHT - 20); + } + // Debug char debug[20] = {0}; @@ -1009,7 +1078,12 @@ void lumberjackSpawnCheck(int64_t elapseUs) lumv->spawnSide++; lumv->spawnSide %= 2; - lumv->spawnTimer = LUMBERJACK_RESPAWN_TIMER; + lumv->spawnTimer = LUMBERJACK_RESPAWN_TIMER - (lumv->upgrade * LUMBERJACK_UPGRADE_TIMER_OFFSET); + + if (lumv->spawnTimer < LUMBERJACK_RESPAWN_MIN) + { + lumv->spawnTimer = LUMBERJACK_RESPAWN_MIN; + } lumberjackRespawnEnemy(lumv->enemy[enemyIndex], lumv->spawnSide); spawnReady = false; @@ -1040,7 +1114,14 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs if (entity->state == LUMBERJACK_BUMPED) { entity->vy -= 2; - entity->respawn = 1500; + entity->respawn = 1500 - (lumv->upgrade * LUMBERJACK_UPGRADE_TIMER_OFFSET); + + if (entity->respawn < LUMBERJACK_UPGRADE_TIMER_OFFSET) + { + entity->respawn = LUMBERJACK_UPGRADE_TIMER_OFFSET; + } + + if (entity->vy >= 0) { @@ -1205,7 +1286,7 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs if (entity->respawn == 0) { // ESP_LOGI(LUM_TAG, "DEAD & hit the ground %d", entity->respawn); - entity->respawn = 250; + entity->respawn = LUMBERJACK_UPGRADE_TIMER_OFFSET; entity->ready = true; return; } @@ -1231,8 +1312,16 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs entity->ready = true; } } - if (entity->state != LUMBERJACK_DEAD) + if (entity->state != LUMBERJACK_DEAD && !lumv->hasWon) entity->state = LUMBERJACK_OFFSCREEN; + + if (entity->state != LUMBERJACK_DEAD && entity->state != LUMBERJACK_OFFSCREEN && lumv->hasWon) + { + lumv->gameState = LUMBERJACK_GAMESTATE_WINNING; + lumv->localPlayer->state = LUMBERJACK_VICTORY; + lumv->levelTime = 0; + lumv->levelIndex++; + } } } diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index b7252966a..2e02197c6 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -5,6 +5,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex); void lumberjackExitGameMode(void); void lumberjackSetupLevel(int index); +void lumberjackUnloadLevel(void); void lumberjackDoControls(void); void lumberjackTileMap(void); void lumberjackDrawWaterLevel(void); diff --git a/main/modes/lumberjack/lumberjackPlayer.c b/main/modes/lumberjack/lumberjackPlayer.c index a7cbbf184..cd68a5d48 100644 --- a/main/modes/lumberjack/lumberjackPlayer.c +++ b/main/modes/lumberjack/lumberjackPlayer.c @@ -25,7 +25,6 @@ void lumberjackSetupPlayer(lumberjackEntity_t* hero, int character) hero->maxLevel = character; hero->type = character; hero->state = LUMBERJACK_UNSPAWNED; - hero->lives = 3; } From 7efc2a034926d135daab6f2e3608ec6d23ea948d Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 8 Oct 2023 18:58:13 -0700 Subject: [PATCH 11/54] Didn't want to lose the main file in the merge commit --- main/swadge2024.c | 160 +++++++++++++++++++++------------------------- 1 file changed, 74 insertions(+), 86 deletions(-) diff --git a/main/swadge2024.c b/main/swadge2024.c index 3330b074d..ff9b595c2 100644 --- a/main/swadge2024.c +++ b/main/swadge2024.c @@ -155,8 +155,9 @@ #define RTC_DATA_ATTR #endif -#define EXIT_TIME_US 1000000 -#define PAUSE_TIME_US 500000 +#define EXIT_TIME_US 1000000 +#define PAUSE_TIME_US 500000 +#define DEFAULT_FRAME_RATE_US 40000 //============================================================================== // Variables @@ -168,18 +169,19 @@ static swadgeMode_t* cSwadgeMode = &mainMenuMode; /// @brief A pending Swadge mode to use after a deep sleep static RTC_DATA_ATTR swadgeMode_t* pendingSwadgeMode = NULL; -/// @brief Whether or not the quck settings overlay mode is shown -static bool showQuickSettings = false; +/// @brief Flag set if the quick settings should be shown synchronously +static bool shouldShowQuickSettings = false; +/// @brief Flag set if the quick settings should be hidden synchronously +static bool shouldHideQuickSettings = false; +/// @brief A pointer to the Swadge mode under the quick settings +static swadgeMode_t* modeBehindQuickSettings = NULL; /// 25 FPS by default -static uint32_t frameRateUs = 40000; +static uint32_t frameRateUs = DEFAULT_FRAME_RATE_US; /// @brief Timer to return to the main menu static int64_t timeExitPressed = 0; -/// @brief Timer to open quick settings menu -static int64_t timePausePressed = 0; - //============================================================================== // Function declarations //============================================================================== @@ -365,7 +367,7 @@ void app_main(void) tAccumDraw -= frameRateUs; // Call the mode's main loop - if (NULL != cSwadgeMode->fnMainLoop || showQuickSettings) + if (NULL != cSwadgeMode->fnMainLoop) { // Keep track of the time between main loop calls static uint64_t tLastMainLoopCall = 0; @@ -374,24 +376,15 @@ void app_main(void) tLastMainLoopCall = tNowUs; } - if (showQuickSettings) - { - // Call the overlay mode's main loop if there is one - quickSettingsMode.fnMainLoop(tNowUs - tLastMainLoopCall); - } - else - { - // Otherwise, call the regular swadge mode's main loop - cSwadgeMode->fnMainLoop(tNowUs - tLastMainLoopCall); - } + cSwadgeMode->fnMainLoop(tNowUs - tLastMainLoopCall); tLastMainLoopCall = tNowUs; } // If the menu button is being held - if (0 != timeExitPressed && !showQuickSettings) + if (0 != timeExitPressed) { // Figure out for how long - int64_t tHeldUs = tNowUs - timeExitPressed; + int64_t tHeldUs = esp_timer_get_time() - timeExitPressed; // If it has been held for more than the exit time if (tHeldUs > EXIT_TIME_US) { @@ -407,44 +400,34 @@ void app_main(void) fillDisplayArea(0, TFT_HEIGHT - 10, numPx, TFT_HEIGHT, c333); } } - else if (0 != timePausePressed) - { - int64_t tHeldUs = tNowUs - timePausePressed; - - if (tHeldUs > PAUSE_TIME_US) - { - if (showQuickSettings) - { - // Quick settings is active, just quit that - quickSettingsMode.fnExitMode(); - showQuickSettings = false; - } - else - { - // Quick settings not active, set it up - quickSettingsMode.fnEnterMode(); - showQuickSettings = true; - } - - // Reset the count - timePausePressed = 0; - } - else - { - int16_t r = QUICK_SETTINGS_PANEL_R; - int16_t numPx = (tHeldUs * (QUICK_SETTINGS_PANEL_W - r * 2)) / PAUSE_TIME_US; - - if (numPx < 0) - numPx = abs(numPx); - drawCircleFilled(QUICK_SETTINGS_PANEL_X + r, 0, r, c333); - fillDisplayArea(QUICK_SETTINGS_PANEL_X + r, 0, QUICK_SETTINGS_PANEL_X + r + numPx, r + 1, c333); - drawCircleFilled(QUICK_SETTINGS_PANEL_X + numPx + r, 0, r, c333); - } + // If quick settings should be shown or hidden, do that before drawing the TFT + if (shouldShowQuickSettings) + { + // Lower the flag + shouldShowQuickSettings = false; + // Pause the buzzer + bzrPause(); + // Save the current mode + modeBehindQuickSettings = cSwadgeMode; + cSwadgeMode = &quickSettingsMode; + // Show the quick settings + quickSettingsMode.fnEnterMode(); + } + else if (shouldHideQuickSettings) + { + // Lower the flag + shouldHideQuickSettings = false; + // Hide the quick settings + quickSettingsMode.fnExitMode(); + // Restore the mode + cSwadgeMode = modeBehindQuickSettings; + // Resume the buzzer + bzrResume(); } // Draw to the TFT - drawDisplayTft(showQuickSettings ? NULL : cSwadgeMode->fnBackgroundDrawCallback); + drawDisplayTft(cSwadgeMode->fnBackgroundDrawCallback); } // If the mode should be switched, do it now @@ -571,6 +554,9 @@ static void setSwadgeMode(void* swadgeMode) */ void switchToSwadgeMode(swadgeMode_t* mode) { + // Set the framerate back to default + setFrameRateUs(DEFAULT_FRAME_RATE_US); + pendingSwadgeMode = mode; } @@ -588,7 +574,7 @@ void softSwitchToPendingSwadge(void) } // Stop the buzzer - bzrStop(); + bzrStop(true); // Switch the mode pointer cSwadgeMode = pendingSwadgeMode; @@ -623,47 +609,49 @@ void softSwitchToPendingSwadge(void) */ bool checkButtonQueueWrapper(buttonEvt_t* evt) { + // Check the button queue bool retval = checkButtonQueue(evt); - // Intercept button presses for PB_SELECT - if (retval) + // Check for intercept + if (retval && // If there was a button press + (!cSwadgeMode->overrideSelectBtn) && // And PB_SELECT isn't overridden + (evt->button == PB_SELECT)) // And the button was PB_SELECT { - // Don't intercept the button on the main menu - if (cSwadgeMode != &mainMenuMode) + if (evt->down) { - if (evt->button == PB_SELECT && !showQuickSettings) + // Button was pressed, start the timer + timeExitPressed = esp_timer_get_time(); + } + else + { + // Button was released, stop the timer + timeExitPressed = 0; + + // If the mode hasn't exited yet, toggle quick settings + if (cSwadgeMode != &quickSettingsMode) { - if (evt->down) - { - // Button was pressed, start the timer - timeExitPressed = esp_timer_get_time(); - } - else - { - // Button was released, stop the timer - timeExitPressed = 0; - } + shouldShowQuickSettings = true; } - else if (evt->button == PB_START && !timeExitPressed) + else { - ESP_LOGI("UTL", "START EVET"); - // Handle the start button for the quick-settings menu, - // but only if we're not already handling select and the - // quick-settings menu is not already enabled - if (evt->down) - { - // Button was pressed, start the timer - timePausePressed = esp_timer_get_time(); - } - else - { - // Button was relesaed, stop the timer - timePausePressed = 0; - } + shouldHideQuickSettings = true; } } + + // Don't pass this button to the mode + retval = false; } // Return if there was an event or not return retval; } + +/** + * @brief Set the framerate, in microseconds + * + * @param newFrameRateUs The time between frame draws, in microseconds + */ +void setFrameRateUs(uint32_t newFrameRateUs) +{ + frameRateUs = newFrameRateUs; +} \ No newline at end of file From f1328782d19072b84e931978c9d127835bd86511 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 8 Oct 2023 20:42:13 -0700 Subject: [PATCH 12/54] Bug Fixes Removed second bumped frame from enemy animation Added a free buffer to stop level from crashing Added a button buffer to stop the game from trying to load twice. --- components/hdw-btn/include/hdw-btn.h | 4 +-- main/modes/lumberjack/lumberjack.c | 12 ++++----- main/modes/lumberjack/lumberjack.h | 1 - main/modes/lumberjack/lumberjackEntity.c | 2 +- main/modes/lumberjack/lumberjackGame.c | 33 ++++++++---------------- main/modes/lumberjack/lumberjackGame.h | 1 - 6 files changed, 19 insertions(+), 34 deletions(-) diff --git a/components/hdw-btn/include/hdw-btn.h b/components/hdw-btn/include/hdw-btn.h index cec51ffc2..b1398ed3d 100644 --- a/components/hdw-btn/include/hdw-btn.h +++ b/components/hdw-btn/include/hdw-btn.h @@ -100,8 +100,8 @@ typedef enum __attribute__((packed)) { PB_UP = 0x0001, //!< The up button's bit - PB_DOWN = 0x0002, //!< The down button's bit - PB_LEFT = 0x0004, //!< The left button's bit + PB_DOWN = 0x0004, //!< The down button's bit + PB_LEFT = 0x0002, //!< The left button's bit PB_RIGHT = 0x0008, //!< The right button's bit PB_A = 0x0010, //!< The A button's bit PB_B = 0x0020, //!< The B button's bit diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index dfd54e2b9..1619d4de9 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -238,7 +238,6 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) uint8_t frame = (uint8_t)payload[5]; printf("Got %d,%d %d|", locX, locY, frame); - lumberjackUpdateRemote(locX, locY, frame); } } @@ -275,23 +274,22 @@ static void lumberjackMsgTxCbFn(p2pInfo* p2p, messageStatus_t status, const uint static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingVal) { - ESP_LOGI(LUM_TAG, "Info "); if (selected) { + if (lumberjack->screen != LUMBERJACK_MENU) + { + return; + } + if (label == lumberjackPanic) { ESP_LOGI(LUM_TAG, "Panic"); lumberjack->gameMode = LUMBERJACK_MODE_PANIC; - // lumberjack->screen = LUMBERJACK_A; - // lumberjackStartGameMode(LUMBERJACK_MODE_PANIC, lumberjack->selected); } else if (label == lumberjackAttack) { ESP_LOGI(LUM_TAG, "Attack"); lumberjack->gameMode = LUMBERJACK_MODE_ATTACK; - - // lumberjack->screen = LUMBERJACK_B; - // lumberjackStartGameMode(LUMBERJACK_MODE_ATTACK, lumberjack->selected); } if (label == lumberjackMenuMultiPlayerHost) diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 3f8f4deb2..7e7b8ba93 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -147,7 +147,6 @@ typedef struct lumberjackAxeBlock_t* axeBlocks[8]; lumberjackEntity_t* localPlayer; - lumberjackEntity_t* remotePlayer; lumberjackGameType_t gameType; diff --git a/main/modes/lumberjack/lumberjackEntity.c b/main/modes/lumberjack/lumberjackEntity.c index fae79c0d4..8255cc8f2 100644 --- a/main/modes/lumberjack/lumberjackEntity.c +++ b/main/modes/lumberjack/lumberjackEntity.c @@ -168,7 +168,7 @@ uint8_t lumberjackGetEnemyAnimation(lumberjackEntity_t* enemy) if (animation == LUMBERJACK_BUMPED) { const int anim[] = {4}; - return anim[enemy->currentFrame % 2]; + return anim[0]; } if (animation == LUMBERJACK_BUMPED_IDLE) diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 1091a3567..eff73133f 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -26,7 +26,6 @@ #define LUMBERJACK_TILEANIMATION_SPEED 150500 #define LUMBERJACK_SCREEN_X_OFFSET 299 -#define LUMBERJACK_SCREEN_X_MIN 0 #define LUMBERJACK_SCREEN_X_MAX 270 #define LUMBERJACK_SCREEN_Y_OFFSET 140 @@ -356,18 +355,19 @@ bool lumberjackLoadLevel() lumv->playerSpawnY = (int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8); ESP_LOGI(LUM_TAG, "%d %d", lumv->playerSpawnX, buffer[offset]); + free(buffer); + return true; } void lumberjackSetupLevel(int characterIndex) -{ - +{ lumv->enemyKillCount = 0; lumv->totalEnemyCount = 0; lumv->hasWon = false; ESP_LOGI(LUM_TAG, "LOADING LEVEL"); - bool levelLoaded = lumberjackLoadLevel(); + lumberjackLoadLevel(); // This all to be loaded externally lumv->yOffset = 0; @@ -381,8 +381,6 @@ void lumberjackSetupLevel(int characterIndex) lumv->localPlayer = calloc(1, sizeof(lumberjackEntity_t)); lumv->localPlayer->scoreValue = 0; - lumv->remotePlayer = calloc(1, sizeof(lumberjackEntity_t)); - lumv->remotePlayer->scoreValue = 0; lumberjackSetupPlayer(lumv->localPlayer, characterIndex); lumberjackSpawnPlayer(lumv->localPlayer, lumv->playerSpawnX, lumv->playerSpawnY, 0); @@ -574,14 +572,6 @@ void lumberjackGameLoop(int64_t elapsedUs) DrawGame(); } -void lumberjackUpdateRemote(int remoteX, int remoteY, int remoteFrame) -{ - lumv->remotePlayer->x = remoteX; - lumv->remotePlayer->y = remoteY; - lumv->remotePlayer->drawFrame = remoteFrame; - lumv->remotePlayer->active = true; -} - void baseMode(int64_t elapsedUs) { // Ignore the first frame because everything was loading @@ -952,12 +942,6 @@ void DrawGame(void) lumv->localPlayer->y - lumv->yOffset, lumv->localPlayer->flipped, false, 0); } - if (lumv->remotePlayer->active) - { - drawWsg(&lumv->playerSprites[lumv->remotePlayer->drawFrame], lumv->remotePlayer->x - 4, - lumv->remotePlayer->y - lumv->yOffset, false, false, 0); - } - drawWsgSimple(&lumv->ui[0], (TFT_WIDTH / 2) - 12, 6); //If playing panic mode draw water @@ -1007,8 +991,8 @@ void DrawGame(void) // Debug - char debug[20] = {0}; /* + char debug[20] = {0}; snprintf(debug, sizeof(debug), "Debug: %d %d %d", lumv->localPlayer->x, lumv->localPlayer->y, lumv->localPlayer->cH); @@ -1611,6 +1595,11 @@ void lumberjackExitGameMode(void) freeWsg(&lumv->alertSprite); + for (int i = 0; i < ARRAY_SIZE(lumv->axeBlocks); i++) + { + free(lumv->axeBlocks[i]); + } + freeFont(&lumv->arcade); free(lumv); -} +} \ No newline at end of file diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 2e02197c6..22663b22d 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -14,7 +14,6 @@ void lumberjackUpdate(int64_t elapseUs); void lumberjackTitleLoop(int64_t elapsedUs); void lumberjackGameLoop(int64_t elapsedUs); void lumberjackUpdateLocation(int ghostX, int ghostY, int frame); -void lumberjackUpdateRemote(int remoteX, int remoteY, int remoteFrame); void restartLevel(void); From 4cd3a563e493cebc60db1695e72e98dacfa6aa0d Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 8 Oct 2023 21:41:55 -0700 Subject: [PATCH 13/54] Quick bug fixes Increased the upper level y so you can see more of the level Fixed the bits I replaced for hardware --- components/hdw-btn/include/hdw-btn.h | 4 ++-- main/modes/lumberjack/lumberjackGame.c | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/hdw-btn/include/hdw-btn.h b/components/hdw-btn/include/hdw-btn.h index b1398ed3d..cec51ffc2 100644 --- a/components/hdw-btn/include/hdw-btn.h +++ b/components/hdw-btn/include/hdw-btn.h @@ -100,8 +100,8 @@ typedef enum __attribute__((packed)) { PB_UP = 0x0001, //!< The up button's bit - PB_DOWN = 0x0004, //!< The down button's bit - PB_LEFT = 0x0002, //!< The left button's bit + PB_DOWN = 0x0002, //!< The down button's bit + PB_LEFT = 0x0004, //!< The left button's bit PB_RIGHT = 0x0008, //!< The right button's bit PB_A = 0x0010, //!< The A button's bit PB_B = 0x0020, //!< The B button's bit diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index eff73133f..30650290a 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -29,7 +29,7 @@ #define LUMBERJACK_SCREEN_X_MAX 270 #define LUMBERJACK_SCREEN_Y_OFFSET 140 -#define LUMBERJACK_SCREEN_Y_MIN -16 +#define LUMBERJACK_SCREEN_Y_MIN -36 #define LUMBERJACK_MAP_WIDTH 18 #define LUMBERJACK_BLOCK_ANIMATION_MAX 7 @@ -273,7 +273,6 @@ bool lumberjackLoadLevel() lumv->upgrade = 0; if (lumv->gameType == LUMBERJACK_MODE_PANIC) { - char* levelName[] = { "lumberjacks_panic_1.bin", @@ -350,7 +349,7 @@ bool lumberjackLoadLevel() int offset = (lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH) + 12; ESP_LOGI (LUM_TAG, "%d total enemies",lumv->totalEnemyCount); ESP_LOGI (LUM_TAG, "%d ", lumv->currentMapHeight* LUMBERJACK_TILE_SIZE); - //lumv->tile = &level; + lumv->playerSpawnX = (int)buffer[offset]; lumv->playerSpawnY = (int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8); ESP_LOGI(LUM_TAG, "%d %d", lumv->playerSpawnX, buffer[offset]); From 397e4e360e24266a827723a223c4b032b78c903c Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 14 Oct 2023 21:18:54 -0700 Subject: [PATCH 14/54] Ghost officially added Ghost enemy added in code Duck is useful Removed lumberjackDoEnemyControls as it wasn't doing anything --- assets/lumbers/lumberjacks.tsx | 37 ++++++ assets/lumbers/lumberjacks_panic_1.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_panic_4.bin | Bin 740 -> 740 bytes dependencies.lock | 2 +- main/modes/lumberjack/lumberjack.h | 4 + main/modes/lumberjack/lumberjackEntity.c | 6 - main/modes/lumberjack/lumberjackEntity.h | 12 +- main/modes/lumberjack/lumberjackGame.c | 150 +++++++++++++++++++++-- 8 files changed, 195 insertions(+), 16 deletions(-) create mode 100644 assets/lumbers/lumberjacks.tsx diff --git a/assets/lumbers/lumberjacks.tsx b/assets/lumbers/lumberjacks.tsx new file mode 100644 index 000000000..5ba723a98 --- /dev/null +++ b/assets/lumbers/lumberjacks.tsx @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/lumbers/lumberjacks_panic_1.bin b/assets/lumbers/lumberjacks_panic_1.bin index c0a559d2e93f4872efac1dbfccfe3532027506ae..6dc05072f2e5479c5a143911c05ef271097a4932 100644 GIT binary patch delta 28 gcmeBU?qe1ZWo2MsWB>v#200+fJyFnkW3V+N04}@(rT_o{ delta 27 ccmeBU?qlW=Wo3W?xru_#6BSrDhFCEI05g6BLI3~& diff --git a/assets/lumbers/lumberjacks_panic_4.bin b/assets/lumbers/lumberjacks_panic_4.bin index a033252ea3cb79709a81cf4cde64d5c268ccc02b..5716157a22becacf52ff7abd337f614213548f96 100644 GIT binary patch delta 17 ZcmaFD`h<1EY(_@ziGos_w=wE50suNC1%Lnm delta 15 XcmaFD`h<1EY{rQS(wnz2>M;TUGwB6{ diff --git a/dependencies.lock b/dependencies.lock index e1a93f5ef..7df236114 100644 --- a/dependencies.lock +++ b/dependencies.lock @@ -16,6 +16,6 @@ dependencies: source: type: idf version: 5.1.1 -manifest_hash: c303dbd840e0549311e5e896c5c6cd8b947bcfd99febcdae64b08facea506735 +manifest_hash: 0ce67e1d80ed73bd9bd927ccfee5e9d88c845e6ea0e140d95932eff90234a40c target: esp32s2 version: 1.0.0 diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 7e7b8ba93..226f9e6a3 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -148,6 +148,10 @@ typedef struct lumberjackAxeBlock_t* axeBlocks[8]; lumberjackEntity_t* localPlayer; + //Ghost + lumberjackGhost_t* ghost; + int ghostSpawnTime; + lumberjackGameType_t gameType; } lumberjackVars_t; diff --git a/main/modes/lumberjack/lumberjackEntity.c b/main/modes/lumberjack/lumberjackEntity.c index 8255cc8f2..6d98d537b 100644 --- a/main/modes/lumberjack/lumberjackEntity.c +++ b/main/modes/lumberjack/lumberjackEntity.c @@ -114,12 +114,6 @@ void lumberjackUpdateEnemy(lumberjackEntity_t* enemy, int newIndex) } } -void lumberjackDoEnemyControls(lumberjackEntity_t* enemy) -{ - // pick between types I guess - // if enemy->type 1, 2, or 3... continue - // enemy->direction = -1; -} void lumberjackUpdateEnemyCollision(lumberjackEntity_t* enemy) { diff --git a/main/modes/lumberjack/lumberjackEntity.h b/main/modes/lumberjack/lumberjackEntity.h index 84b3f60e4..5bdbd52b9 100644 --- a/main/modes/lumberjack/lumberjackEntity.h +++ b/main/modes/lumberjack/lumberjackEntity.h @@ -55,13 +55,23 @@ typedef struct } lumberjackEntity_t; +typedef struct { + bool active; + int x; + int y; + int startSide; + int currentFrame; + int64_t spawnTime; + int64_t timerFrameUpdate; +} lumberjackGhost_t; + + void lumberjackSetupEnemy(lumberjackEntity_t* enemy, int character); uint8_t lumberjackGetEnemyAnimation(lumberjackEntity_t* enemy); void lumberjackResetEnemy(lumberjackEntity_t* enemy); void lumberjackRespawnEnemy(lumberjackEntity_t* enemy, int side); bool checkCollision(lumberjackEntity_t* AA, lumberjackEntity_t* BB); void lumberjackUpdateEnemy(lumberjackEntity_t* enemy, int newIndex); -void lumberjackDoEnemyControls(lumberjackEntity_t* enemy); void lumberjackUpdateEnemyCollision(lumberjackEntity_t* enemy); void lumberjackUpdatePlayerCollision(lumberjackEntity_t* player); diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 30650290a..077c1b7e1 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -11,6 +11,9 @@ #include "lumberjackEntity.h" #include "lumberjackPlayer.h" +#include "esp_random.h" + + //redundancy #include "hdw-spiffs.h" @@ -38,6 +41,12 @@ #define LUMBERJACK_UPGRADE_TIMER_OFFSET 250 #define LUMBERJACK_SUBMERGE_TIMER 300 +#define LUMBERJACK_GHOST_SPAWNTIME_MIN 10000 +#define LUMBERJACK_GHOST_SPEED_NORMAL 3 +#define LUMBERJACK_GHOST_SPEED_FAST 3 +#define LUMBERJACK_GHOST_BOX 28 +#define LUMBERJACK_GHOST_ANIMATION 2500 + #define LUMBERJACK_TILE_SIZE 16 @@ -71,6 +80,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->axeBlocks[i]->active = false; } + lumv->ghost = NULL; lumv->worldTimer = 0; lumv->liquidAnimationFrame = 0; lumv->stageAnimationFrame = 0; @@ -309,10 +319,13 @@ bool lumberjackLoadLevel() lumv->enemy6Count = (int) buffer[6]; lumv->enemy7Count = (int) buffer[7]; lumv->enemy8Count = (int) buffer[8]; + ESP_LOGI(LUM_TAG, "Enemy count %d", lumv->enemy4Count); + if (lumv->enemy4Count > 1) lumv->enemy4Count = 1; //Only one ghost + lumv->totalEnemyCount = lumv->enemy1Count; lumv->totalEnemyCount += lumv->enemy2Count; lumv->totalEnemyCount += lumv->enemy3Count; - lumv->totalEnemyCount += lumv->enemy4Count; + //lumv->totalEnemyCount += lumv->enemy4Count; //Ghost don't count lumv->totalEnemyCount += lumv->enemy5Count; lumv->totalEnemyCount += lumv->enemy6Count; lumv->totalEnemyCount += lumv->enemy7Count; @@ -332,6 +345,14 @@ bool lumberjackLoadLevel() lumv->enemy1Count = 0; } + if (lumv->enemy4Count > 0) + { + lumv->ghostSpawnTime = (int)buffer[9] * 1000; + + if (lumv->ghostSpawnTime < LUMBERJACK_GHOST_SPAWNTIME_MIN) lumv->ghostSpawnTime = LUMBERJACK_GHOST_SPAWNTIME_MIN; //Make sure if the ghost is active at least 10 seconds must past before spawning + + } + lumv->waterSpeed = (int)buffer[11]; lumv->waterTimer = (int)buffer[11]; @@ -392,7 +413,6 @@ void lumberjackSetupLevel(int characterIndex) // START ENEMY 1 for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy1Count; eSpawnIndex++) { - ESP_LOGI(LUM_TAG, ":D %d %d", eSpawnIndex, lumv->enemy1Count); lumv->enemy[eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); lumberjackSetupEnemy(lumv->enemy[eSpawnIndex], 0); } @@ -414,11 +434,20 @@ void lumberjackSetupLevel(int characterIndex) offset += lumv->enemy3Count; - for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy4Count; eSpawnIndex++) + + //GHOST + if (lumv->enemy4Count > 0) { - lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); - lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); - } + lumv->enemy4Count = 1; + lumv->ghost = calloc(1, sizeof(lumberjackGhost_t)); + lumv->ghost->spawnTime = lumv->ghostSpawnTime ; + } + + // for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy4Count; eSpawnIndex++) + // { + // lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + // lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + // } offset += lumv->enemy4Count; for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy5Count; eSpawnIndex++) @@ -448,6 +477,8 @@ void lumberjackSetupLevel(int characterIndex) lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); } + //Ghost is separate for reasons + ESP_LOGI(LUM_TAG, "LOADED"); } @@ -461,6 +492,9 @@ void lumberjackUnloadLevel(void) free(lumv->enemy[i]); lumv->enemy[i] = NULL; } + + free(lumv->ghost); + lumv->ghost = NULL; } /** @@ -617,7 +651,30 @@ void baseMode(int64_t elapsedUs) if (lumv->enemy[enemyIndex] == NULL) continue; - lumberjackDoEnemyControls(lumv->enemy[enemyIndex]); + } + + //Do Ghost Controls + if (lumv->ghost != NULL && lumv->ghost->active) + { + if (lumv->localPlayer->state != LUMBERJACK_DEAD) + { + lumv->ghost->x += LUMBERJACK_GHOST_SPEED_NORMAL * -lumv->ghost->startSide * elapsedUs / 100000.0; + } + else + { + lumv->ghost->x += LUMBERJACK_GHOST_SPEED_FAST * -lumv->ghost->startSide * elapsedUs / 100000.0; + } + + if (lumv->localPlayer->y < lumv->ghost->y) + { + lumv->ghost->y -= 1; + + } + if (lumv->localPlayer->y > lumv->ghost->y) + { + lumv->ghost->y += 1; + } + } if (lumv->localPlayer->onGround && lumv->hasWon) @@ -832,6 +889,17 @@ void baseMode(int64_t elapsedUs) lumv->localPlayer->timerFrameUpdate = 0; //; } + if (NULL != lumv->ghost && lumv->ghost->active) + { + lumv->ghost->timerFrameUpdate += elapsedUs; + if (lumv->ghost->timerFrameUpdate > LUMBERJACK_GHOST_ANIMATION) + { + lumv->ghost->timerFrameUpdate -= LUMBERJACK_GHOST_ANIMATION; + lumv->ghost->currentFrame++; + lumv->ghost->currentFrame %= 4; + } + } + lumv->yOffset = lumv->localPlayer->y - LUMBERJACK_SCREEN_Y_OFFSET; if (lumv->yOffset < LUMBERJACK_SCREEN_Y_MIN) lumv->yOffset = LUMBERJACK_SCREEN_Y_MIN; @@ -941,6 +1009,15 @@ void DrawGame(void) lumv->localPlayer->y - lumv->yOffset, lumv->localPlayer->flipped, false, 0); } + //This is where we draw the ghost + if (NULL != lumv->ghost && true == lumv->ghost->active && lumv->ghost->currentFrame % 2 == 0) + { + if (lumv->ghost->currentFrame == 2) + drawWsg(&lumv->enemySprites[21], lumv->ghost->x, lumv->ghost->y - lumv->yOffset, (lumv->ghost->startSide == 1), false, 0); + else + drawWsg(&lumv->enemySprites[22], lumv->ghost->x, lumv->ghost->y - lumv->yOffset, (lumv->ghost->startSide == 1), false, 0); + } + drawWsgSimple(&lumv->ui[0], (TFT_WIDTH / 2) - 12, 6); //If playing panic mode draw water @@ -1042,11 +1119,46 @@ void lumberjackScoreDisplay(int score, int locationX) void lumberjackSpawnCheck(int64_t elapseUs) { + float elapse = (elapseUs / 1000); + if (lumv->ghost != NULL && lumv->ghost->active == false) + { + lumv->ghost->spawnTime -= elapse; + + if (lumv->ghost->spawnTime <= 0) + { + lumv->ghost->spawnTime = lumv->ghostSpawnTime; + + lumv->ghost->active = true; + + if (esp_random() % 2 > 0) + { + lumv->ghost->startSide = -1; + lumv->ghost->x = -5; + } + else + { + lumv->ghost->startSide = 1; + lumv->ghost->x = 280; + } + + lumv->ghost->y = lumv->localPlayer->y; + + if (esp_random() % 2 > 0) + { + lumv->ghost->y -= 32; + } + else + { + lumv->ghost->y += 32; + } + } + + } + if (lumv->spawnTimer >= 0) { bool spawnReady = true; - float elapse = (elapseUs / 1000); lumv->spawnTimer -= elapse; if (lumv->spawnTimer < 0) @@ -1306,6 +1418,19 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs lumv->levelIndex++; } } + + if (entity == lumv->localPlayer && lumv->ghost != NULL && lumv->ghost->active) + { + if (lumv->localPlayer->x < lumv->ghost->x + LUMBERJACK_GHOST_BOX && lumv->localPlayer->x + lumv->localPlayer->width > lumv->ghost->x + && lumv->localPlayer->y < lumv->ghost->y + LUMBERJACK_GHOST_BOX && lumv->localPlayer->y + lumv->localPlayer->height > lumv->ghost->y + && lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_DUCK && lumv->localPlayer->state != LUMBERJACK_INVINCIBLE) + { + lumberjackOnLocalPlayerDeath(); + } + + /*return (AA->x < BB->x + BB->width && AA->x + AA->width > BB->x && AA->y < BB->y + BB->height + && AA->y + AA->height > BB->y);*/ + } } void lumberjackUpdate(int64_t elapseUs) @@ -1322,6 +1447,15 @@ void lumberjackUpdate(int64_t elapseUs) } } } + + if (lumv->ghost != NULL && lumv->ghost->active) + { + if ((lumv->ghost->x < -28 && lumv->ghost->startSide > 0) || (lumv->ghost->x > 290 && lumv->ghost->startSide < 0 )) + { + ESP_LOGI(LUM_TAG, "Remove ghost!"); + lumv->ghost->active = false; + } + } } void lumberjackTileMap(void) From 514f0130917ca685cc313322b4cea5cd9fccbc20 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 14 Oct 2023 23:05:23 -0700 Subject: [PATCH 15/54] Added water drain block for panic mode Made the block appear where it needs to be. Added animated axe block --- assets/lumbers/lumberjacks_panic_1.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_panic_3.bin | Bin 398 -> 398 bytes assets/lumbers/lumbers_itemused_block.png | Bin 0 -> 204 bytes main/modes/lumberjack/lumberjack.h | 4 + main/modes/lumberjack/lumberjackGame.c | 87 +++++++++++++++++++--- main/modes/lumberjack/lumberjackGame.h | 2 + 6 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 assets/lumbers/lumbers_itemused_block.png diff --git a/assets/lumbers/lumberjacks_panic_1.bin b/assets/lumbers/lumberjacks_panic_1.bin index 6dc05072f2e5479c5a143911c05ef271097a4932..309470effac779e7d266454b268d81dd83369b4b 100644 GIT binary patch delta 28 gcmeBU?qe1ZWo2MsWB>vY200+fJyFnkW3V+N053=bumAu6 delta 28 gcmeBU?qe1ZWo2MsWB>v#200+fJyFnkW3V+N04}@(rT_o{ diff --git a/assets/lumbers/lumberjacks_panic_3.bin b/assets/lumbers/lumberjacks_panic_3.bin index cfdd246a2c4bbe3e01e030a84982d8103026a558..dd84ae1a240de2a02f2de0430357d2366e66e167 100644 GIT binary patch delta 27 ecmeBU?qlW=Wo3W>eg?UT3ymlCaBOsUX9NH{TLnM> delta 27 ccmeBU?qlW=Wo3W?xrqynC-!h`ba!V206LfjF#rGn diff --git a/assets/lumbers/lumbers_itemused_block.png b/assets/lumbers/lumbers_itemused_block.png new file mode 100644 index 0000000000000000000000000000000000000000..889611fff3fb540d24bf0532c98d643a23cb698a GIT binary patch literal 204 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|+B{txLo9le zd(NLoP5=UnjgL>%vk5gctuj+)1_EKtSsNJLN?8~G=K%ukyu4J9s*18Xg6rG7#r=&9 zfI#QP`t$`|+z|;pGtL@F7c@#=f4}I1X4%0NjLiobDy$lg+E>{uZmuq07jT`m=iR!E pAd`6b^Ws%C%{P7K2v9d?V$i;-=)cZ0>k`mK44$rjF6*2UngBczLZbix literal 0 HcmV?d00001 diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 226f9e6a3..074d97475 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -151,6 +151,10 @@ typedef struct //Ghost lumberjackGhost_t* ghost; int ghostSpawnTime; + + //Item Block + int itemBlockTime; + bool itemBlockReady; lumberjackGameType_t gameType; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 077c1b7e1..5c1126b2a 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -47,8 +47,9 @@ #define LUMBERJACK_GHOST_BOX 28 #define LUMBERJACK_GHOST_ANIMATION 2500 -#define LUMBERJACK_TILE_SIZE 16 +#define LUMBERJACK_ITEM_RESETTIME 2500 +#define LUMBERJACK_TILE_SIZE 16 static lumberjackTile_t* lumberjackGetTile(int x, int y); static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs); @@ -121,6 +122,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("bottom_floor8.wsg", &lumv->floorTiles[7], true); loadWsg("bottom_floor9.wsg", &lumv->floorTiles[8], true); loadWsg("bottom_floor10.wsg", &lumv->floorTiles[9], true); + loadWsg("lumbers_itemused_block.wsg", &lumv->floorTiles[10], true); ESP_LOGI(LUM_TAG, "Loading Animation Tiles"); loadWsg("water_floor1.wsg", &lumv->animationTiles[0], true); @@ -136,6 +138,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("water_floor_b3.wsg", &lumv->animationTiles[10], true); loadWsg("water_floor_b4.wsg", &lumv->animationTiles[11], true); + ESP_LOGI(LUM_TAG, "Loading Characters"); ESP_LOGI(LUM_TAG, "*Loading character icons"); @@ -310,6 +313,8 @@ bool lumberjackLoadLevel() lumv->tile = (lumberjackTile_t*)malloc((int)buffer[0] * LUMBERJACK_MAP_WIDTH * sizeof(lumberjackTile_t)); lumv->currentMapHeight = (int)buffer[0]; lumv->levelTime = 0; + lumv->itemBlockTime = 0; + lumv->itemBlockReady = true; lumv->enemy1Count = (int) buffer[1]; lumv->enemy2Count = (int) buffer[2]; @@ -533,8 +538,6 @@ void lumberjackTitleLoop(int64_t elapsedUs) lumv->stageAnimationFrame++; } - - DrawTitle(); } @@ -578,6 +581,18 @@ void lumberjackGameLoop(int64_t elapsedUs) //if panic mode do water if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING && lumv->gameType == LUMBERJACK_MODE_PANIC) { + if (lumv->itemBlockTime > 0) + { + lumv->itemBlockTime -= elapsedUs/10000; + + if (lumv->itemBlockTime < 0) + { + lumv->itemBlockReady = true; + lumv->itemBlockTime = 0; + //Play note? + } + } + lumv->waterTimer -= elapsedUs/10000; if (lumv->waterTimer < 0) { @@ -1330,18 +1345,35 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs if (lumberjackIsCollisionTile(tileA->type)) { - lumv->tile[tileA->index].offset = 10; - lumv->tile[tileA->index].offset_time = 100; + if (tileA->type != 11 || lumv->itemBlockReady == true) + { + lumv->tile[tileA->index].offset = 10; + lumv->tile[tileA->index].offset_time = 100; + + lumberjackDetectBump(tileA); + if (tileA->type == 11) + { + lumberjackUseBlock(); + } + } - lumberjackDetectBump(tileA); } if (lumberjackIsCollisionTile(tileB->type)) { - lumberjackDetectBump(tileB); + if (tileB->type != 11 || lumv->itemBlockReady == true) + { + + lumberjackDetectBump(tileB); - lumv->tile[tileB->index].offset = 10; - lumv->tile[tileB->index].offset_time = 100; + lumv->tile[tileB->index].offset = 10; + lumv->tile[tileB->index].offset_time = 100; + + if (tileB->type == 11) + { + lumberjackUseBlock(); + } + } } } } @@ -1477,7 +1509,19 @@ void lumberjackTileMap(void) { drawWsgSimple(&lumv->floorTiles[tileIndex - 1], x * LUMBERJACK_TILE_SIZE, (y * LUMBERJACK_TILE_SIZE) - lumv->yOffset - offset); } + else if (tileIndex == 11) + { + if (lumv->itemBlockReady) + { + drawWsgSimple(&lumv->unusedBlockSprite[lumv->stageAnimationFrame % LUMBERJACK_BLOCK_ANIMATION_MAX], x * LUMBERJACK_TILE_SIZE, (y * LUMBERJACK_TILE_SIZE) - lumv->yOffset - offset); + } + else + { + drawWsgSimple(&lumv->floorTiles[tileIndex - 1], x * LUMBERJACK_TILE_SIZE, (y * LUMBERJACK_TILE_SIZE) - lumv->yOffset - offset); + } + } } + } } } @@ -1677,6 +1721,31 @@ void lumberjackDetectBump(lumberjackTile_t* tile) } } +void lumberjackUseBlock() +{ + lumv->itemBlockReady = false; + ESP_LOGI(LUM_TAG, "JACKED"); + + if (lumv->gameType == LUMBERJACK_MODE_PANIC) + { + + lumv->waterDirection = 6; + lumv->waterTimer = lumv->waterSpeed; + lumv->waterLevel += lumv->waterDirection; + + lumv->itemBlockTime = LUMBERJACK_ITEM_RESETTIME; + + if (lumv->lumberjackMain->networked) + { + //Increase speed of opponent's water! + } + else + { + + } + } +} + /// /// diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 22663b22d..de380d729 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -27,4 +27,6 @@ void lumberjackScoreDisplay(int score, int locationX); void baseMode(int64_t elapsedUs); void lumberjackSendAttack(int number); +void lumberjackUseBlock(void); + #endif \ No newline at end of file From 2a1ce06b66cc4920292e305ef385cd48b8b8a2dc Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 14 Oct 2023 23:53:12 -0700 Subject: [PATCH 16/54] Spawn Fix Assure that player spawns in the Y location that they are suppose to Fixed spawnpoint in current maps --- assets/lumbers/lumberjacks_panic_1.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_panic_2.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_panic_3.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_panic_4.bin | Bin 740 -> 740 bytes main/modes/lumberjack/lumberjackGame.c | 9 ++++----- main/modes/lumberjack/lumberjackPlayer.c | 7 +++---- main/modes/lumberjack/lumberjackPlayer.h | 2 +- 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/assets/lumbers/lumberjacks_panic_1.bin b/assets/lumbers/lumberjacks_panic_1.bin index 309470effac779e7d266454b268d81dd83369b4b..1dc604a241261742d697a6d7acf3459f3eb923e7 100644 GIT binary patch delta 27 hcmeBU?qlW=Wo2MsWB>vY2DyoX&Jz__H-=a-0su6W1Xln6 delta 28 gcmeBU?qe1ZWo2MsWB>vY200+fJyFnkW3V+N053=bumAu6 diff --git a/assets/lumbers/lumberjacks_panic_2.bin b/assets/lumbers/lumberjacks_panic_2.bin index 81a203cb24ede17113afbe70b94662035ad343ec..e0d888a713f7a27408ccb969cdaead9a51daefca 100644 GIT binary patch delta 15 WcmeBU?qlB2&d4sn$i%_P!2$ps%L0-B delta 15 WcmeBU?qlB2&d9FA$i%_P!2$ptj{>d$ diff --git a/assets/lumbers/lumberjacks_panic_3.bin b/assets/lumbers/lumberjacks_panic_3.bin index dd84ae1a240de2a02f2de0430357d2366e66e167..8bf03b46e5a7ab18b3126666a74dba52b518311a 100644 GIT binary patch delta 15 WcmeBU?qlB2&d4sn$i%_P!2$ps%L0-B delta 15 WcmeBU?qlB2&dAQdz{J7H!2$psRRVzk diff --git a/assets/lumbers/lumberjacks_panic_4.bin b/assets/lumbers/lumberjacks_panic_4.bin index 5716157a22becacf52ff7abd337f614213548f96..10f67f3809978ee138d28184a38c35c48c9c6ea8 100644 GIT binary patch delta 14 VcmaFD`h<1EJtj6LCJs&x762yu1Bw6u delta 14 VcmaFD`h<1EJtj6rCJs&x762yo1Bn0t diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 5c1126b2a..1585d2c8b 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -378,7 +378,7 @@ bool lumberjackLoadLevel() lumv->playerSpawnX = (int)buffer[offset]; lumv->playerSpawnY = (int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8); - ESP_LOGI(LUM_TAG, "%d %d", lumv->playerSpawnX, buffer[offset]); + ESP_LOGI(LUM_TAG, "%d %d", lumv->playerSpawnY, buffer[offset]); free(buffer); @@ -508,7 +508,7 @@ void lumberjackUnloadLevel(void) void restartLevel(void) { lumv->lives--; - lumberjackRespawn(lumv->localPlayer, lumv->playerSpawnX); + lumberjackRespawn(lumv->localPlayer, lumv->playerSpawnX, lumv->playerSpawnY); } @@ -628,7 +628,7 @@ void baseMode(int64_t elapsedUs) { lumv->loaded = true; - ESP_LOGI(LUM_TAG, "Load Time %ld", (long)elapsedUs); + //ESP_LOGI(LUM_TAG, "Load Time %ld", (long)elapsedUs); // If networked, send "Loaded complete!" ? @@ -788,8 +788,7 @@ void baseMode(int64_t elapsedUs) // Respawn player lumv->localPlayer->respawn = 0; lumv->lives--; - - lumberjackRespawn(lumv->localPlayer, lumv->playerSpawnX); + lumberjackRespawn(lumv->localPlayer, lumv->playerSpawnX, lumv->playerSpawnY); } } else if (lumv->localPlayer->state != LUMBERJACK_OFFSCREEN && lumv->localPlayer->state != LUMBERJACK_VICTORY) diff --git a/main/modes/lumberjack/lumberjackPlayer.c b/main/modes/lumberjack/lumberjackPlayer.c index cd68a5d48..6c86e7138 100644 --- a/main/modes/lumberjack/lumberjackPlayer.c +++ b/main/modes/lumberjack/lumberjackPlayer.c @@ -7,7 +7,6 @@ #define LUMBERJACK_DEFAULT_ANIMATION_SPEED 150000 #define LUMBERJACK_INVINCIBLE_ANIMATION_SPEED 25000 -#define LUMBERJACK_SPAWN_Y 270 #define LUMBERJACK_HERO_WIDTH 24 #define LUMBERJACK_HERO_HEIGHT 31 #define LUMBERJACK_HERO_DUCK_HEIGHT 31 @@ -31,7 +30,7 @@ void lumberjackSetupPlayer(lumberjackEntity_t* hero, int character) void lumberjackSpawnPlayer(lumberjackEntity_t* hero, int x, int y, int facing) { hero->x = x; - hero->y = LUMBERJACK_SPAWN_Y; + hero->y = y; hero->vx = 0; hero->maxVX = 15; hero->vy = 0; @@ -44,11 +43,11 @@ void lumberjackSpawnPlayer(lumberjackEntity_t* hero, int x, int y, int facing) hero->respawn = 0; } -void lumberjackRespawn(lumberjackEntity_t* hero, int x) +void lumberjackRespawn(lumberjackEntity_t* hero, int x, int y) { hero->x = x; hero->maxVX = 15; - hero->y = LUMBERJACK_SPAWN_Y; + hero->y = y; hero->active = true; hero->ready = false; hero->vx = 0; diff --git a/main/modes/lumberjack/lumberjackPlayer.h b/main/modes/lumberjack/lumberjackPlayer.h index 2dc5bcecf..ba1dbc9c5 100644 --- a/main/modes/lumberjack/lumberjackPlayer.h +++ b/main/modes/lumberjack/lumberjackPlayer.h @@ -4,7 +4,7 @@ #include "lumberjack_types.h" void lumberjackSpawnPlayer(lumberjackEntity_t* hero, int x, int y, int facing); -void lumberjackRespawn(lumberjackEntity_t* hero, int x); +void lumberjackRespawn(lumberjackEntity_t* hero, int x, int y); int lumberjackGetPlayerAnimation(lumberjackEntity_t* hero); void lumberjackSetupPlayer(lumberjackEntity_t* hero, int character); From 99380683831afcbc3503b2a7e7b0954a1d324730 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Thu, 19 Oct 2023 18:39:04 -0700 Subject: [PATCH 17/54] Shifted levels around a bit more Added an easy level 1 Added flipping tiles. Started basis of Attack mode. --- assets/lumbers/lumberjacks_panic_1.bin | Bin 398 -> 254 bytes assets/lumbers/lumberjacks_panic_10.bin | Bin 0 -> 740 bytes assets/lumbers/lumberjacks_panic_2.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_panic_3.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_panic_4.bin | Bin 740 -> 398 bytes assets/lumbers/lumberjacks_panic_5.bin | Bin 0 -> 470 bytes assets/lumbers/lumbers_rtile_1.png | Bin 0 -> 243 bytes assets/lumbers/lumbers_rtile_2.png | Bin 0 -> 197 bytes assets/lumbers/lumbers_rtile_3.png | Bin 0 -> 124 bytes assets/lumbers/lumbers_rtile_4.png | Bin 0 -> 186 bytes main/modes/lumberjack/lumberjack.h | 4 + main/modes/lumberjack/lumberjackGame.c | 137 +++++++++++++++++++++-- main/modes/lumberjack/lumberjackGame.h | 1 + tools/lumber_jacks/lumberjackTileset.tsx | 8 +- 14 files changed, 138 insertions(+), 12 deletions(-) create mode 100644 assets/lumbers/lumberjacks_panic_10.bin create mode 100644 assets/lumbers/lumberjacks_panic_5.bin create mode 100644 assets/lumbers/lumbers_rtile_1.png create mode 100644 assets/lumbers/lumbers_rtile_2.png create mode 100644 assets/lumbers/lumbers_rtile_3.png create mode 100644 assets/lumbers/lumbers_rtile_4.png diff --git a/assets/lumbers/lumberjacks_panic_1.bin b/assets/lumbers/lumberjacks_panic_1.bin index 1dc604a241261742d697a6d7acf3459f3eb923e7..2fce60cb01f0b0f36f00ec6497e241aa0e5d20fe 100644 GIT binary patch literal 254 xcmd;OWPkxV7=tvL1qcv2P)wmyk+E bCIkQmHxRI~bHD&67m#0}!^p(J$-x2u2MPi# diff --git a/assets/lumbers/lumberjacks_panic_10.bin b/assets/lumbers/lumberjacks_panic_10.bin new file mode 100644 index 0000000000000000000000000000000000000000..295ea18f7c4e0b34094866c294092a7da7fd4b45 GIT binary patch literal 740 zcmbtQK@xx<2n40l`a|cQ(X)JhpjmiuMrseRI_$c5ctnJZy))wmyk+E bCIkQmHxRI~bHD&67m#1U$H>IN$-x2u1~>u^ literal 398 zcmWe-Wq<)W7y}>80tOHj$ZULiu*tEo07W4NK$+N75iQ0H1W?65Ly@(iagn9)v%!vo lDM8`D1c{@WAOIN7j8G;A7;thiFtD*h*a-rROdOmXEC2>40v7-P diff --git a/assets/lumbers/lumberjacks_panic_3.bin b/assets/lumbers/lumberjacks_panic_3.bin index 8bf03b46e5a7ab18b3126666a74dba52b518311a..e0d888a713f7a27408ccb969cdaead9a51daefca 100644 GIT binary patch literal 398 zcmWe-Wq<)W7y}>80tOHj$ZULiu*tEo07W4NK$+N75iQ0H1W?65Ly@(iagn9)v%!vo lDM8`D1c{@WAOIN7j8G;A7;thiFtD*h*a-rROdOmXEC2>40v7-P literal 398 zcmWe-Wq<&F2018;M2ZCjpnAY;7>7i2z{(*8P+|hm7=(imEYckV)C)BW#vt7cuntBh f5CDcVoWaJ<0R&tO3~V5plZ(MkfRTxVlY<2S`ltcs diff --git a/assets/lumbers/lumberjacks_panic_4.bin b/assets/lumbers/lumberjacks_panic_4.bin index 10f67f3809978ee138d28184a38c35c48c9c6ea8..8bf03b46e5a7ab18b3126666a74dba52b518311a 100644 GIT binary patch literal 398 zcmWe-Wq<&F2018;M2ZCjpnAY;7>7i2z{(*8P+|hm7=(imEYckV)C)BW#vt7cuntBh f5CDcVoWaJ<0R&tO3~V5plZ(MkfRTxVlY<2S`ltcs literal 740 zcmbu4K^A}@2t-M(u

hV{|N!pI8{|oY!B-pv>?*BPoXptj0=p^s{wXM4OhJ%Ih=| z%(70=Jrc~3@qcc=5YF1Y-*)4llC6TeKczQF^;w8hXH(T_+%N`NGz$cP^dd3IGK!!kpao!SczB=;5SI*qa5Bu%xD6o? kI?T+>5WR2)Zlho_U@buP5G^nRV6sHh6#|S*9Go010Dp-A=l}o! literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_rtile_1.png b/assets/lumbers/lumbers_rtile_1.png new file mode 100644 index 0000000000000000000000000000000000000000..3858ed9fe37917717679ac988c874ae8d047d32c GIT binary patch literal 243 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|)_S@)hFJ6_ z_nbeGoB#wC8y}yjXA^2@>0wf41_EKtSsNJLN?8~G=K%ukyu4J9s*18Xg6rG7#r=&9 zfI#QP`t$`|+z|;pGtLH0o3P-9;bWdIr+yw`HXvvV)qc0ABlt~|V}?V^E^}ufZgYxx zbfueB!b2nH$SMJ~y2n;ilNsMJMQ}N9XOz9OySR0iUP4KEFT|#T-&&qKCr+K*Znaa8 Z!S9?l_l9?Er9g)>c)I$ztaD0e0s!4JR5Jho literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_rtile_2.png b/assets/lumbers/lumbers_rtile_2.png new file mode 100644 index 0000000000000000000000000000000000000000..c32026873d6f4ad8f4f92b7e675a116dbc8e0286 GIT binary patch literal 197 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|>OEZ?Lo9le z6C^SYtXP-uWxf#e42@Do?w*a0o`taiL0kH9$<9j=Qy#d=it{WocoDsU*Y(k*qn9;m zY-@u>KC=G(8dAo%>m+AuuLf7*!n}uq?Mi-oBOJ^n#dnlH=VAte!>g^IuXw@~tn3dq n&;Nbgq$zSYDp@2}K4M}}ou<-#nuG5c&?yX_u6{1-oD!MWMjfHZcRJYKc6_1-5`I`d|9AIGByORB{ U=7M=~Kob}|UHx3vIVCg!0OfloorTiles[8], true); loadWsg("bottom_floor10.wsg", &lumv->floorTiles[9], true); loadWsg("lumbers_itemused_block.wsg", &lumv->floorTiles[10], true); + loadWsg("lumbers_rtile_1.wsg", &lumv->floorTiles[11], true); ESP_LOGI(LUM_TAG, "Loading Animation Tiles"); loadWsg("water_floor1.wsg", &lumv->animationTiles[0], true); @@ -137,6 +139,11 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("water_floor_b2.wsg", &lumv->animationTiles[9], true); loadWsg("water_floor_b3.wsg", &lumv->animationTiles[10], true); loadWsg("water_floor_b4.wsg", &lumv->animationTiles[11], true); + loadWsg("lumbers_rtile_1.wsg", &lumv->animationTiles[12], true); + loadWsg("lumbers_rtile_2.wsg", &lumv->animationTiles[13], true); + loadWsg("lumbers_rtile_3.wsg", &lumv->animationTiles[14], true); + loadWsg("lumbers_rtile_4.wsg", &lumv->animationTiles[15], true); + ESP_LOGI(LUM_TAG, "Loading Characters"); @@ -288,20 +295,39 @@ bool lumberjackLoadLevel() { char* levelName[] = { - "lumberjacks_panic_1.bin", + "lumberjacks_panic_5.bin", "lumberjacks_panic_2.bin", "lumberjacks_panic_3.bin", - "lumberjacks_panic_4.bin" + "lumberjacks_panic_4.bin", + "lumberjacks_panic_5.bin", + "lumberjacks_panic_10.bin", }; ESP_LOGI(LUM_TAG, "Level # %d", (int)(lumv->levelIndex % ARRAY_SIZE(levelName))); fname = levelName[lumv->levelIndex % ARRAY_SIZE(levelName)]; + } + + if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + char* attackLevelName[] = + { + "lumberjacks_attack_1.bin" + }; + + fname = attackLevelName[lumv->levelIndex % ARRAY_SIZE(attackLevelName)]; + if (!lumv->lumberjackMain->networked) { - lumv->upgrade = (int)(lumv->levelIndex / ARRAY_SIZE(levelName)); + lumv->upgrade = (int)(lumv->levelIndex / ARRAY_SIZE(attackLevelName)); } - } + for (int i = 0; i < 8; i++) + { + lumv->attackQueue[i] = 0; + lumv->receiveQueue[i] = 0; + } + + } @@ -706,7 +732,16 @@ void baseMode(int64_t elapsedUs) lumberjackUpdate(elapsedUs); // Check spawn - lumberjackSpawnCheck(elapsedUs); + + if (lumv->gameType == LUMBERJACK_MODE_PANIC) + { + lumberjackSpawnCheck(elapsedUs); + } + if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + + } + for (int colTileIndex = 0; colTileIndex < ARRAY_SIZE(lumberjackCollisionCheckTiles); colTileIndex++) { @@ -1032,7 +1067,11 @@ void DrawGame(void) drawWsg(&lumv->enemySprites[22], lumv->ghost->x, lumv->ghost->y - lumv->yOffset, (lumv->ghost->startSide == 1), false, 0); } - drawWsgSimple(&lumv->ui[0], (TFT_WIDTH / 2) - 12, 6); + + if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + drawWsgSimple(&lumv->ui[0], (TFT_WIDTH / 2) - 12, 6); + } //If playing panic mode draw water lumberjackDrawWaterLevel(); @@ -1209,6 +1248,51 @@ void lumberjackSpawnCheck(int64_t elapseUs) } } + +void lumberjackAttackCheck(int64_t elapseUs) +{ + float elapse = (elapseUs / 1000); + + if (lumv->spawnTimer >= 0) + { + bool spawnReady = true; + + lumv->spawnTimer -= elapse; + + if (lumv->spawnTimer < 0) + { + for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) + { + if (lumv->enemy[enemyIndex] == NULL) + continue; + + if (lumv->enemy[enemyIndex]->ready && lumv->enemy[enemyIndex]->state != LUMBERJACK_DEAD) + { + lumv->spawnSide++; + lumv->spawnSide %= 2; + + lumv->spawnTimer = LUMBERJACK_RESPAWN_TIMER - (lumv->upgrade * LUMBERJACK_UPGRADE_TIMER_OFFSET); + + if (lumv->spawnTimer < LUMBERJACK_RESPAWN_MIN) + { + lumv->spawnTimer = LUMBERJACK_RESPAWN_MIN; + } + + lumberjackRespawnEnemy(lumv->enemy[enemyIndex], lumv->spawnSide); + spawnReady = false; + break; + } + } + + if (spawnReady) + { + // No one was spawned. + lumv->spawnTimer = 500; + } + } + } +} + static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs) { bool onGround = false; @@ -1349,7 +1433,14 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs lumv->tile[tileA->index].offset = 10; lumv->tile[tileA->index].offset_time = 100; - lumberjackDetectBump(tileA); + if (tileA->type == 12) + { + lumv->tile[tileA->index].type = 13; + lumv->tile[tileA->index].offset *= 10; + lumv->tile[tileA->index].offset_time *= 10; + } + + if (lumv->tile[tileA->index].type != 13) lumberjackDetectBump(tileA); if (tileA->type == 11) { lumberjackUseBlock(); @@ -1360,19 +1451,27 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs if (lumberjackIsCollisionTile(tileB->type)) { + if (tileB->type != 11 || lumv->itemBlockReady == true) { - lumberjackDetectBump(tileB); lumv->tile[tileB->index].offset = 10; lumv->tile[tileB->index].offset_time = 100; + if (tileB->type == 12) + { + lumv->tile[tileB->index].type = 13; + lumv->tile[tileB->index].offset *= 10; + lumv->tile[tileB->index].offset_time *= 10; + } + if (lumv->tile[tileB->index].type != 13) lumberjackDetectBump(tileB); if (tileB->type == 11) { lumberjackUseBlock(); } } + } } } @@ -1475,6 +1574,11 @@ void lumberjackUpdate(int64_t elapseUs) { lumv->tile[tileIndex].offset_time += 2500; lumv->tile[tileIndex].offset--; + + if (lumv->tile[tileIndex].type == 13 && lumv->tile[tileIndex].offset <= 0) + { + lumv->tile[tileIndex].type = 12; + } } } } @@ -1502,7 +1606,7 @@ void lumberjackTileMap(void) if ((y * LUMBERJACK_TILE_SIZE) - lumv->yOffset >= -16) { - if (tileIndex > 0 && tileIndex < 13) + if (tileIndex > 0 && tileIndex < 15) { if (tileIndex < 11) { @@ -1519,6 +1623,14 @@ void lumberjackTileMap(void) drawWsgSimple(&lumv->floorTiles[tileIndex - 1], x * LUMBERJACK_TILE_SIZE, (y * LUMBERJACK_TILE_SIZE) - lumv->yOffset - offset); } } + else if (tileIndex == 12) + { + drawWsgSimple(&lumv->animationTiles[12], x * LUMBERJACK_TILE_SIZE, (y * LUMBERJACK_TILE_SIZE) - lumv->yOffset); + } + else if (tileIndex == 13) + { + drawWsgSimple(&lumv->animationTiles[12 + (offset % LUMBERJACK_ROTATE_ANIMATION_MAX)], x * LUMBERJACK_TILE_SIZE, (y * LUMBERJACK_TILE_SIZE) - lumv->yOffset); + } } } @@ -1659,9 +1771,11 @@ static lumberjackTile_t* lumberjackGetTile(int x, int y) static bool lumberjackIsCollisionTile(int index) { - if (index == 0 || index == 1 || index == 6 || index == 5 || index == 10) + if (index == 0 || index == 1 || index == 6 || index == 5 || index == 10 || index == 13) return false; + + return true; } @@ -1708,7 +1822,8 @@ void lumberjackDetectBump(lumberjackTile_t* tile) if (enemy->state == LUMBERJACK_BUMPED_IDLE) { enemy->state = LUMBERJACK_RUN; - enemy->direction = enemy->flipped ? -1 : 1; + enemy->direction = enemy->flipped ? 1 : -1; // Go opposite direction + enemy->flipped = !enemy->flipped; } else { diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index de380d729..66a1eb18a 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -21,6 +21,7 @@ void lumberjackGameDebugLoop(int64_t elapsedUs); void lumberjackDetectBump(lumberjackTile_t* tile); void lumberjackSpawnCheck(int64_t elapseUs); +void lumberjackAttackCheck(int64_t elapseUs); void lumberjackScoreDisplay(int score, int locationX); diff --git a/tools/lumber_jacks/lumberjackTileset.tsx b/tools/lumber_jacks/lumberjackTileset.tsx index 1014422c7..9a4e7e038 100644 --- a/tools/lumber_jacks/lumberjackTileset.tsx +++ b/tools/lumber_jacks/lumberjackTileset.tsx @@ -1,5 +1,5 @@ - + @@ -31,4 +31,10 @@ + + + + + + From 0361dd7b1a5917867845fcb61b66ba304bc7587b Mon Sep 17 00:00:00 2001 From: MrTroy Date: Fri, 20 Oct 2023 17:49:29 -0700 Subject: [PATCH 18/54] Cho nuff update Added Cho to game Fixed the ghost not spawning in levels 3 through 5 Added flip as lives icon for Cho --- assets/lumbers/lumberjacks_panic_3.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_panic_4.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_panic_5.bin | Bin 470 -> 470 bytes assets/lumbers/lumbers_cho_1.png | Bin 0 -> 583 bytes assets/lumbers/lumbers_cho_10.png | Bin 0 -> 480 bytes assets/lumbers/lumbers_cho_11.png | Bin 0 -> 532 bytes assets/lumbers/lumbers_cho_12.png | Bin 0 -> 531 bytes assets/lumbers/lumbers_cho_13.png | Bin 0 -> 542 bytes assets/lumbers/lumbers_cho_14.png | Bin 0 -> 577 bytes assets/lumbers/lumbers_cho_15.png | Bin 0 -> 542 bytes assets/lumbers/lumbers_cho_16.png | Bin 0 -> 544 bytes assets/lumbers/lumbers_cho_17.png | Bin 0 -> 518 bytes assets/lumbers/lumbers_cho_18.png | Bin 0 -> 576 bytes assets/lumbers/lumbers_cho_2.png | Bin 0 -> 592 bytes assets/lumbers/lumbers_cho_3.png | Bin 0 -> 523 bytes assets/lumbers/lumbers_cho_4.png | Bin 0 -> 557 bytes assets/lumbers/lumbers_cho_5.png | Bin 0 -> 518 bytes assets/lumbers/lumbers_cho_6.png | Bin 0 -> 546 bytes assets/lumbers/lumbers_cho_7.png | Bin 0 -> 512 bytes assets/lumbers/lumbers_cho_8.png | Bin 0 -> 533 bytes assets/lumbers/lumbers_cho_9.png | Bin 0 -> 530 bytes assets/lumbers/lumbers_cho_lives.png | Bin 0 -> 311 bytes main/modes/lumberjack/lumberjack.c | 23 +++++++++++++----- main/modes/lumberjack/lumberjack.h | 2 +- main/modes/lumberjack/lumberjackGame.c | 31 ++++++++++++++++++++++--- 25 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 assets/lumbers/lumbers_cho_1.png create mode 100644 assets/lumbers/lumbers_cho_10.png create mode 100644 assets/lumbers/lumbers_cho_11.png create mode 100644 assets/lumbers/lumbers_cho_12.png create mode 100644 assets/lumbers/lumbers_cho_13.png create mode 100644 assets/lumbers/lumbers_cho_14.png create mode 100644 assets/lumbers/lumbers_cho_15.png create mode 100644 assets/lumbers/lumbers_cho_16.png create mode 100644 assets/lumbers/lumbers_cho_17.png create mode 100644 assets/lumbers/lumbers_cho_18.png create mode 100644 assets/lumbers/lumbers_cho_2.png create mode 100644 assets/lumbers/lumbers_cho_3.png create mode 100644 assets/lumbers/lumbers_cho_4.png create mode 100644 assets/lumbers/lumbers_cho_5.png create mode 100644 assets/lumbers/lumbers_cho_6.png create mode 100644 assets/lumbers/lumbers_cho_7.png create mode 100644 assets/lumbers/lumbers_cho_8.png create mode 100644 assets/lumbers/lumbers_cho_9.png create mode 100644 assets/lumbers/lumbers_cho_lives.png diff --git a/assets/lumbers/lumberjacks_panic_3.bin b/assets/lumbers/lumberjacks_panic_3.bin index e0d888a713f7a27408ccb969cdaead9a51daefca..50452d92afc977882fb603873489dc92fb84620e 100644 GIT binary patch delta 24 bcmeBU?qlW=Wo2MsWB>!XiGeB`4dNI9D4GMV delta 24 YcmeBU?qlW=Wo3W?xru=)8x7(Z0Vsww2Dym~jVJbSY;<>L1OPj21wjA+ delta 27 ecmeBU?qlW=Wo3W>eg?UT3ymlCaBOsUX9NH{TLnM> diff --git a/assets/lumbers/lumberjacks_panic_5.bin b/assets/lumbers/lumberjacks_panic_5.bin index abfd7565d8e0dc07683e280c01fe8a88d2fec891..ee6485fa7df0e43695a7b41b6ed91f1ff4aaae0c 100644 GIT binary patch delta 40 icmcb{e2sZRq!a@buz&!V&BFttcz7lj`ffZR#s~m+Vg=Cv delta 27 gcmcb{e2sZRBo_+{0}!wP!Nl{H6Ajci9u{T<09?EV#{d8T diff --git a/assets/lumbers/lumbers_cho_1.png b/assets/lumbers/lumbers_cho_1.png new file mode 100644 index 0000000000000000000000000000000000000000..fd3482c284e2f272e22dd5fd036ca0ae1da1fb35 GIT binary patch literal 583 zcmV-N0=WH&P)Px%0ZBwbR9J=8mcMQkF%ZUoj%Y%+QktYVq$@}$k*`D7MWVTem)PxTcnTh1{RUJt z*O3Mg-MI#(IEibniF5@>Af;G}@!X!xZZ4Yy?eaBik7sPpH-FZK080tL@yr5nc#;8- z*)aeczl^@uKYju5^KxC$0k+HyfGZ3D2VIQ+1s>@@J)h4fkwRWp71T^D-9@x+%e>Qp zsr_&m_`Ti$wa0Df>aoHXPKUa`fdMdJbTFGOfI0{EF>znG!VH6fZ4RvG9)OqAk3b!> zwwUk4G}24u*_#&zAln?u+>Rq=`)5Eqpw{`-=WiA4&vswgXl`AL+-e+JI&2cXUY#nJT4Kzmi}^Sp3UU9V?v4Z!KiWwbsV2DA^f;?+pL?^m6w zWOVf10IaT_h@7HPzkdc&fiiNAy!|ea-mM+3G~%I8{*^ZDF1m^RD6xN8+>GHeFh%NkLLS$D zsPj*czb3&JJ(8Ev2+>>dtnr-Q8EEYTg!g++obEeyp4#3@|NrR&inOymw0`dl`~kyx Vt?Y0|h@}7k002ovPDHLkV1mW)79{`x literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_cho_10.png b/assets/lumbers/lumbers_cho_10.png new file mode 100644 index 0000000000000000000000000000000000000000..8e284de172a11649009732a8a52d3bfbd08f6204 GIT binary patch literal 480 zcmV<60U!Q}P)Px$nn^@KR9J=8mZ4L_FcgQs?B)QmyO|k81vey@+Myb`Ei}NX0uL5AD za{zj+o<4$vxtPiq0HS1C9AhDy+-N2RbcsOI95|HL?_V7wAejR&oQwhZUc4QI#7gI4 z`+gv!T8@P$V4M$R1i(t?HRmRKZ4$nIV2>M}UyTI7&&RS`1o}SbJ{gC)kN`-bca9s~ z^d15Djm`vs&da#q1cYSnbng51wh}FN&b!tGh^tfyPr&Q}CI^g$ld%AQKiKCyRb_SE zPaXuo?e(HI-yH&`4|sKVS^hqKwyKitH2^fJGd?(hzVFR8WGd&TzKP>Px$&PhZ;R9J=0mp@MeF&KxR8XQP;xC93n83bK>D^858PVUFY@LQO0vmb%Yk+{)a z85m_TVZcNa2OR1vv}r+O^!i)Kz4Xt$Pv8F9Q+!G@0-!n20MuI<0GVzBurzb$_kHyW zz{_m0CZKlFSKIx|p$awQAQ=5eeZAITFa=;SHfsPqDuNx%uymed?L@1`Ck3#YEo6K< z4nrU%0)2f4K)dJ%*Yvj%a?OEO0ON5Eq(tDmHSk+WO&oVxKuQF}2O7OD0MC<$KP4e^ zS5H7P-*P-BbE#gRM9dHTxaj=)QUTOknX}6(Cs2!J9+PBf*7nTM%Iu7bI*S`SVf|DA z%(F`%0Rl=h3T7T#dtZeKpK`nA1js*2rFsH#21pHv8ojQ9xF77xd|2Aub=A9702gNy z=l^sFh!6NWI&A`Qc=86o@_zZFU9uU-dOt7L`{f=Ws-A!!*dpROVwt<`raCyF$&DAV z{WEOQEV2F4yAg?e0^)36LFKMt9tMFnE(x<4SJ~%82-Nm9@H6&Rm`E*Pf^lEz66iCx zo=xF6WZ`92;u6^03*5NB3q+L@h#GppA$NW+>>%UJk-ii9ik%f(+V>^p?0a986Zim7 W0IAt_f=wv^0000XP)Px$%}GQ-R9J=8mOE0zFc5}6F;qMXm!xz7H6tG(Ww?gia|4bM-+(%FaD?apP`FG= z7vVKS5eix3tRg3b0*k+~y`#6= z=RVJ_waZs_XWZ-h=pKOg{8Rzh+T{&SKxteV^v&@;BF3tn_e0IB+Z*oe1CRoNv3>-g zv9(y8naG(#7i12t5~B)vzk6RIdqEi3 zAmTcsuj`_ed1fAc;8ur3j{AQE=150{Zu90^#BCuvUr5N4$#CVb8@jKCOy@xVo}f$V zsA|{3#$Ez!JNHVLfL9+0gRFb+Jf~3rH5t(F+$((oUY#1jAj002ovPDHLkV1l6K>^1-Z literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_cho_13.png b/assets/lumbers/lumbers_cho_13.png new file mode 100644 index 0000000000000000000000000000000000000000..3ecee6bf6a5cff069ed8c65904320b7ebfe84dab GIT binary patch literal 542 zcmV+(0^$9MP)Px$*hxe|R9J=0m#b34Koo|*WiUVynZdL&0Gw<{L=?#GA`}vX% z9iHU|VE<_3#jDZ)u+??*f5_;UJf8wEzqCsLnG|bpuw~_4x2fWGg{=uxSsn4aE9?SQ?*v-M znRde%cYePn?VJZI=eCXy+?kJO|BWc@x_Akw)=bJJKoQh?rMV59hmJ$VPe9cmvFXjp gop?4lSM^Td1DYzaP>@_sm;e9(07*qoM6N<$g5nwe%K!iX literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_cho_14.png b/assets/lumbers/lumbers_cho_14.png new file mode 100644 index 0000000000000000000000000000000000000000..75f744a96de9ecc56999635095a488c228d25ab4 GIT binary patch literal 577 zcmV-H0>1r;P)Px$`$N&)of8TTOoO`Y4p{W5#3k|?=mH?3G9DvrY zz30>B4*MjMom$3t??; z6>OP|hk+~o8GyXJn)K>C3wh0Twjkue}Tu)I76;Ni>ny>7#<@#Otm z1(3AIuB~$~#%5<=A(o5c4J{8@YCETx+7IsMhmTD~jF1*KJ!<6~z6toqoQp8?4M5(9$e<+*~e z9_+HbGVXR=7atVBS$6M@$HRc=KnSl=R~bDv?OwM;Vkb?U);Dc7K935BfPsa4i7?T= z>ubSJ&f>?WJ!s>m%|`2r1Q$GV-s}uK%Z5M)TP-h*ds?&d7V10gwe8ARK5W_VTlwAF zbKu%d^n5=@wpTTx)fjc{guzC zV0H$Ax1j93Wd^8uyUy;+g$_S@7@iHJt**Hz-Px$*hxe|R9J=0m%mQrFc617Bbt+FB3-jrrdZLN_BzVtHJoR%U*oQW3R+x)C{jWJ zQks*l^cBhM#j|l1C`hJ?$A9Aa?B7gc7|i)3kNXFJ*o1MD??2BCz}wwp05811n1JKpRp z058AeY{Vs#yCWpJ*!F%!Vm$;T^2*i#bg}(Z|w3Pd0$0ZVuJP!m8v*36gv5_hgtbl;o?d~(jw;vVo|J$x~CxTXq(z!nK z+Fcrezt3GZZg~RoAo+lyZcF68xyU9oz9$w#?ze6r*{D0?a}x5-^?nhF*=AbLI&$sT zT99>OK_%-WP}3QJKrZ0D&PD#)U-@A_U8Qli$X(cw8aS&|BPySy|z?I4LMd8 gv++9e)%_X$17BLjZ1h07*qoM6N<$f@etof&c&j literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_cho_16.png b/assets/lumbers/lumbers_cho_16.png new file mode 100644 index 0000000000000000000000000000000000000000..f68810ad0a3e736f7a0540733a4fd3fd8f1d350d GIT binary patch literal 544 zcmV+*0^j|KP)Px$+DSw~R9J=0m$6RdFc5}6qisMmk+$IqiWDb$Z@b+-i}N44s;C?)w;Wa zqo4rkiqlFINOxr@>>nIXwwg6PR2H?d#w*B~WeW3vMxA$$D z+gGJ)74iXaG}(PeV>kH)J6nBj!cRiKtn<6nkfsMWfpf;QA zJN^6fmjZacyvq`q(iDmL323%i=V`Tn)_E!+0VpVlz=H5ZsrI+`*@USsn2Mi%KlAYi zKW}Cypk(rG@YQ)kovn#O=YcgYS{tjgc?9ya6IjR(alXSpVbksaaLPsrJqOWRNND8= zxYj#2&X<_gF<7aEatIu%^qq@CT$u3^4$IWJYmyyCw<6>}WL%O^mXkcPOb<=vi~FQa?>d)klgr?gY? i!2~{WkAwCXL*Nawrnzz(lhUsM0000Px$z)3_wR9J=OmoZMmFcgMAqb?wdREeb>vlOZ0>xx)9W@X_3$vHSia{w+tHYUVc zk4UsbN4g+YqD2fH!jQPCLz0#j6ifU|l=#`n`~2H}f&VVGZ%1LcQ=BHOY(Luf1Aa?u z0w$xjF8~~OS^%`f17NPF)^)Y`1YkLtB}D^!!9Z>HkHTWu?hx?(5dgDTCjc@G3Ond9 zvhK^`j27cp1+bXR%=qaznK#@aFpviTykJl`r-#arYx|-A;l zM8NC==a&}%ygj}ADGBrL`U#lKH+DQLbK~AaNtBIKJAp=7=4Hz7ghqK{c@3`T3Sg!0 z09eWm-~a(73=1>gb?yWGvy$Ro`wHMz$AAL_8ZGe@fDR+;4CwXFtmkgjB?iKnf&`U#i{hiqs1kP`r&^?L#^BK1N)EA0%4NQw{5vQ@BdpNe%~JArR!0gwRb zB>mDv*;Q>nOF%|;Cc1CWE!y_XDPsk&q?p%rnvcsu_e)q^=j);Uzp&wn zbXDd46Wk$Sl=nh_J+~1;l`7)hB+%FvP?2$-Ua}>=P_+~I0>7G|*Jn2IGynhq07*qo IM6N<$g42cLcK`qY literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_cho_18.png b/assets/lumbers/lumbers_cho_18.png new file mode 100644 index 0000000000000000000000000000000000000000..70d788b3f479da3dbd90426c98751a360d03de53 GIT binary patch literal 576 zcmV-G0>AxPx$`bk7VR9J=0mNAdhFc^j(qYfMrNR`UaE=UkGC(NUt1Sm$*V zZ|1cqBDBtHZ#@tnoPd&-?ED;ne4Ta9>EFr}Hu~0fsvso-dh-?7zXtxbE~eLs5s+0m z-%bGdczW4MqB*CM*Ni_s8!Ld5nXjU(9!G0zZ~`N7E_L4LT%=X(luEb8KRE3GrWZE~ z{@h1~Cva=8KghYvu`d0$b-}rb^CT{M^7#ya>)iuSLgzpN1Qc%5>Rg=m5h<+d{NFkz zun5G4Cm?5ltO3z{J5jK|D*Bu+DqmgID}V6oPjPjmLqPU{eVTl`2f*dSA4gTm{L9u8 zd~_N{TD0aTK%l8WWV!NAR!beNjY|2+vyEGW4n38wh~n95tpMs}9!88wq)UKsmvgF& zew$7Anz4(xOY^%w|06X5qyCgwrt}U9+t@jEI3teiFI@sJjNj^%tD^e1q0ZmDd>2i& zeO)*J-MATP^IrLO&sxVBoIr0CNZpHW)p@h+Vfm?5K`((L+8&ml8i8Lm;K48D3m~EZ O0000Px%3Q0skR9J=8mOX15K@f(YwGAOQDFpdIDl8DePU=-BoHPniqW@I(>;P!A*k zPa8Go|FIqda5MP_z@PJ9u^(fR)B`C1PEXqaEEPHYKV-!>*v#!0hEeQfI8=SdUq)e} z3(pQt%((>V(h(5$M-U7ExVicZKy&w9A#Sro_mrdCT1Y9dkZ*5&e#m<>Mfe8Gx&7jz z9OsqE*-rr#sDYG%uKWbRQ1vY;3v0mV)FS2EYx^Am@M`%b0Bg+`F~GCUMhsO#z)m=l z%(J-Hv2=8)=GetogQRQ;fL7Rb>aIEnnQ z`FOu^3{1CM-u@5uy-||u&dMN=*1){X=S{?{%zMggyS?B*0BknSXZn?nK$?b~gkwE) zCg78u*8<@B=tsW!kRZ1H{6YYXE}OE2B5U?*4D{uG>z<12-wi7NACPVFQ3YkPw zxbvWfDVA|!_mQX$0#@!I5d#cxx0@Oa76#O9H>94%6GpEX0)=;h>Lssb?Q*T8nf>zK ziN#V~1hz1J+$MDUKk4%?tKU4bjUV32XdUA>;_b|PN=G2G3qstzey7jPx$#Ysd#R9J=8mN84jKoEt$6)VBwKpTq_t`TiF-Jz9sT3A@wZ+aVlg@t9(Tl)jF z66|hUg#!;f1RLQB1q+KZ z91H-EItVakWa5*mt*%h<|Jhy!s*tA%080C{&MhT!Dq=R;%fL2fjuVu>8|<9lEZqmi zHhu)U(Z%?U*(|-MaRw@N0L&C9{C58_=V9zz{{Ke@971LLZU4p@_ym;?m(jN7Darr< N002ovPDHLkV1gyd@W=oF literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_cho_4.png b/assets/lumbers/lumbers_cho_4.png new file mode 100644 index 0000000000000000000000000000000000000000..36f55ea86ba11b7e00e03a76b4bc1c273d347056 GIT binary patch literal 557 zcmV+|0@D47P)Px$=Sf6CR9J=8ma$GFF%X77BN~n>5)@DbDa}FcwCN(zq&Xg9x92_X0oE^ZO*&|R zHm*Swkw_CEkWw6{JBcD!*psZyE+iJ?21v~nUENp%V0BIWNRJXGM!+L zBm~M@5coHp0dGBzwXVk^n;UtR{S`ETz#<|CgAq_41Dlq~RWk@IVqiM70G#%&faRTi z_Rd9r9-e}{-#yw7$R;PCqym;I-W=*ZFGX`8v5)6FSzr16=diqcQF;P>eF1#z`DdlC z&z#4P69DYkRa`T6q|y`66qTN@ngy9v@6K193DEVSlAb^u1ERg&u>yF$xvM1fk>|N_ z*>yhnsQ|to-Usu|As}_2RzKSA`D?OLmPqWh_Z}3$rlULfOClC(^kv^{XyTny6 zJ9qh8DCeP#zLnbVWYEEQ3l}UiKOU1vPGGxkLOdVg!&N*SxxPW$Xn`9>cSER_BItl( zHJ3o0Ozt}-8{W0?Nc5W(@2j~4dbm99l7;#2^ZfeTZFJerj;Jqa%gUb~Y0*Qo=dxUy~9J~@H^wWXPx$z)3_wR9J=WmM>4kKp2OgTZUp2O=gCyfCWRy)e;PHe2v!gJ@^2d#Nlz^u$+g9 zN@_?dMhJqWh~5jkqc>OrX$6nEzW2U&`TctT6qf1q4uImyQ~-LG(uB$8&UYv;L_WV! z0Hw(R=xtQ}2PkQr=xYGt^rZTWiG1hAQ>~y&4*YZt{1(fH$BsFmnE^05ngH;0d;cp= zlqOfJ-;s`;HP*fZqCCyw)91npvar(7*Rdjau8^G$%k}mrDB%$Q>YSKo}iO6ok)%@04fr zdUu^o&lSMl&cf;MjstQI_$-eH032++0g&IkZnR7G#~1azUqnuS!D*dG26VvzKd|CR z1)ux6Qkj#N*|=a5ci(H{ew)v6ojF@~pf3$kK4u9(!LW{dC)!88v5Jz+)_ac3>i0#% z-5|TI8}EU>A1D}B04cTdxmA`~MS{tay5R~(r*59$k0-S5z?TPx$+(|@1R9J=0m%UEIFce15MJzxWBC)h%hQf;64Y4uiIg*|C-~pO9U}u93b;En< zkP#N74n;69guyYbO&orNh`*(^ukGX>Uw=u2Mv5r_!%P9NGfDtRR0_aSSI+O->J@>rMt{<07Nwz?+&hs6HLvO54CuXGKdrg`fGU6f8cG%lp7yb)NFjEBIP zx&|Q4&pP+?xAMsiGbIocf$!G9Uukv!5E%jM0|%!^06g8!|AfR+SF+hoRO-}N{{(F2 z8;<8>ZmZWP5%L4S-)b-(3Ve3X-U)1nG7rgSsB81gP@+5gt&X=Y0eDIG1VC42T<-)# zF>TE}wD-PpEuHbUYXVG~Qt6+7eFoSXusS$B5(xXjSD6>3IbG-3g#a9m7EU}K0@epY z+BL?=%bXvbl9Q8H0hrBp+&G2P?w>#?utCPuhHB3Fo$1ft)_{~eH(i8n+niKqzxkYh5m zdp*JPfp#z-d%rQ?5_Re>UIHmgf%TpHB=9mBjE4Z|qHG;+*Q-dJ>-0|GOD9ZO0#K3o kUrf%q4vqISkIo0)0cLZ$VcmQ0=l}o!07*qoM6N<$f~iCH!2kdN literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_cho_7.png b/assets/lumbers/lumbers_cho_7.png new file mode 100644 index 0000000000000000000000000000000000000000..78166e3604bf558367fceb4c5c2599758e742632 GIT binary patch literal 512 zcmV+b0{{JqP)Px$x=BPqR9J=8mc3HKKomyLGBl1@WQHb`DUjA#S~|+SfG?2ryoV2veF4YbPC8q+ zSBjL@(0nNCa3uhl02 z?~7$ljfS&O09;%SO7kif0CegO|A&Nq3BxAycI|U1RdWGrlE*_} zDjxs{qG|0n{j0Xg`JohWOaz+dz@fByc|9@$wh#0tBLLnWpASMJ)2Y}Tdon2HSo;L5 z^No&Ia&EJCn}n+$Y|mTuhQ5H`owIcUU6*s0tV5lfJ3|UxJ8yN>xdY%MI2QmqHTzm8 zAS6kpbJw@uR-{Gkdev_NjEhuhpMbpsYz|oUCnEvwez41VtW0&y!W#i_Iarj|kB5Nm z11|N3KCrIerd1-Z4I+JOvRxBb?r)#Kt_>T6a#+{-&!i|ji;ML%HnHcbx-(j}PN2K* zfk+vLNj$Dx*JINGy{XqI-sut0$~ad@*A4)(dDbZ2=@F2T`R}M4_r4`S7L>;hogjhO z)V<9Bn+s9lROzBqdTFD0trOV06Yd+^bq83rPT(8VY@wKR2^|Xn00002WZ literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_cho_8.png b/assets/lumbers/lumbers_cho_8.png new file mode 100644 index 0000000000000000000000000000000000000000..55bb1eb25cc58d74e3ef114fe53f1dfaab9202d2 GIT binary patch literal 533 zcmV+w0_y#VP)Px$&q+ikQb0Z_?X{2x;CCk!6}nBJKsfF4F$7nnG4p0nbzG)^8AtVx!K zz(C&v(2fSVXS%O^a?MaHC=-F-*1(}Of0>kwfcQY8-v!`p^n4H!Gc#73&w*|`HC8+U z$$Z1{oXn+qeG*xI;E#*you-1ca~4jZnw5E$Btx^b-wdrx?zrfpatpwF`&a>(v5hO7 zfYJ=NW}bESz9OS?=eNBRptmZO;t9w%Kx#nL=yw%l`@ycv*vFz;*c*`{cBYFb;16sNu{EK+jEp6aa>}LK_oio@_yAip zGi?70iSiQ=XZsmc?iu#n>GeLwBeLGtI$>D|RCfjV8T-C_wq9r6;9wA XL{YIz=xT7Y00000NkvXXu0mjf)(`pc literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_cho_9.png b/assets/lumbers/lumbers_cho_9.png new file mode 100644 index 0000000000000000000000000000000000000000..e06328773e4f4132431f1b4e13adf6a9d9f217d1 GIT binary patch literal 530 zcmV+t0`2{YP)Px$%t=H+R9J=0makL8Fc^lP?B)QmyO|;o72LpanH>r_gT{A%)2cBj3=Z5Zu^b>O z5Y%v2F%DZq_KhV=2D@X|zGh3l{OJ4i%hxCt8jl|VDDO-Spr;ujnMv-nW8-2f@&^S_ znF4^$R%jED9F7%oz!c>?kckQ@;8M*{`%dhna`Np4Tq z)#zFQoS)2`czXy)9f<1k$o}5GZFNdS8e8)Xhc?c{i8oIm7FZ!u!^-&{S_e9_U(Y;q z&wH(0heMXc79?6mp!?T>zH^c9cw042U@Zsa-6zZeC^-n;5i?Avd#N0oGpC8&Bo&(5vCcshPU(^b07*qoM6N<$g6-1oF8}}l literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_cho_lives.png b/assets/lumbers/lumbers_cho_lives.png new file mode 100644 index 0000000000000000000000000000000000000000..d8eca2e12f2ee91b0e028772222dc58a0c04fac4 GIT binary patch literal 311 zcmV-70m%M|P)Px#@kvBMR5*>rlgW|AAPhtwza}FQlZZ)*3B{y2fH7YFTt~i8qPyK%fd7sHAXo;i z>=%ON9el?ups40S5G(~tv3v*|cNYhunutJ~8Piv*(aQS!?)YaR4B$$(I32g?C|W7K zE47kAE2qFlK8S9LHeWe61<5S6l;IJ6rYU8Lf zQ{%gngKasM6M+6cfrE$&WBL4Cq`jHc@Adx~qW!V!uej|^`~u*;gOESnr?LP5002ov JPDHLkV1gTzg|Gks literal 0 HcmV?d00001 diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index 1619d4de9..dc0dab453 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -36,8 +36,9 @@ static const char lumberjackBack[] = "Back"; // static const char lumberjackNone[] = "None"; static const char lumberjackRedCharacter[] = "Character: Red"; -static const char lumberjackGreen[] = "Character: Green"; +static const char lumberjackGreenCharacter[] = "Character: Green"; static const char lumberjackSpecialCharacter[] = "Character: Special"; +static const char lumberjackChoCharacter[] = "Character: Cho"; static const char lumberjackMenuSinglePlayer[] = "Single Player"; static const char lumberjackMenuMultiPlayerHost[] = "Multi-Player"; @@ -91,16 +92,18 @@ static void lumberjackEnterMode(void) addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerClient); lumberjack->menu = endSubMenu(lumberjack->menu); - if (true) // Ignore this line + + // TODO: Make this a dynamic array that reads what characters have been unlocked. + if (false) // Ignore this line { - static const char* defaultCharacters[] = {lumberjackRedCharacter, lumberjackGreen}; + static const char* defaultCharacters[] = {lumberjackRedCharacter, lumberjackGreenCharacter}; addMultiItemToMenu(lumberjack->menu, defaultCharacters, ARRAY_SIZE(defaultCharacters), 0); } else { static const char* defaultCharacterswUnlocks[] - = {lumberjackRedCharacter, lumberjackGreen, lumberjackSpecialCharacter}; + = {lumberjackRedCharacter, lumberjackGreenCharacter, lumberjackSpecialCharacter, lumberjackChoCharacter}; addMultiItemToMenu(lumberjack->menu, defaultCharacterswUnlocks, ARRAY_SIZE(defaultCharacterswUnlocks), 0); } @@ -319,7 +322,7 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV { lumberjack->selected = 0; } - else if (label == lumberjackGreen) + else if (label == lumberjackGreenCharacter) { lumberjack->selected = 1; } @@ -327,6 +330,10 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV { lumberjack->selected = 2; } + else if (label == lumberjackChoCharacter) + { + lumberjack->selected = 3; + } if (label == lumberjackBack) { @@ -339,13 +346,17 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV { lumberjack->selected = 0; } - else if (label == lumberjackGreen) + else if (label == lumberjackGreenCharacter) { lumberjack->selected = 1; } else if (label == lumberjackSpecialCharacter) { lumberjack->selected = 2; + }else if (label == lumberjackChoCharacter) + { + lumberjack->selected = 3; + } } } \ No newline at end of file diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 74ffebaa7..6d131cf0e 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -124,7 +124,7 @@ typedef struct wsg_t floorTiles[20]; wsg_t animationTiles[20]; - wsg_t minicharacters[3]; + wsg_t minicharacters[4]; wsg_t title; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 89b5c8a69..1f94c53b2 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -152,6 +152,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_red_lives.wsg", &lumv->minicharacters[0], true); loadWsg("lumbers_green_lives.wsg", &lumv->minicharacters[1], true); loadWsg("secret_swadgeland_lives.wsg", &lumv->minicharacters[2], true); + loadWsg("lumbers_cho_lives.wsg", &lumv->minicharacters[3], true); ESP_LOGI(LUM_TAG, "*Loading character sprites"); if (characterIndex == 0) @@ -218,6 +219,27 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("secret_swadgeland_17.wsg", &lumv->playerSprites[16], true); loadWsg("secret_swadgeland_22.wsg", &lumv->playerSprites[17], true); } + else if (characterIndex == 3) + { + loadWsg("lumbers_cho_1.wsg", &lumv->playerSprites[0], true); + loadWsg("lumbers_cho_2.wsg", &lumv->playerSprites[1], true); + loadWsg("lumbers_cho_3.wsg", &lumv->playerSprites[2], true); + loadWsg("lumbers_cho_4.wsg", &lumv->playerSprites[3], true); + loadWsg("lumbers_cho_5.wsg", &lumv->playerSprites[4], true); + loadWsg("lumbers_cho_6.wsg", &lumv->playerSprites[5], true); + loadWsg("lumbers_cho_7.wsg", &lumv->playerSprites[6], true); + loadWsg("lumbers_cho_8.wsg", &lumv->playerSprites[7], true); + loadWsg("lumbers_cho_9.wsg", &lumv->playerSprites[8], true); + loadWsg("lumbers_cho_10.wsg", &lumv->playerSprites[9], true); + loadWsg("lumbers_cho_11.wsg", &lumv->playerSprites[10], true); + loadWsg("lumbers_cho_12.wsg", &lumv->playerSprites[11], true); + loadWsg("lumbers_cho_13.wsg", &lumv->playerSprites[12], true); + loadWsg("lumbers_cho_14.wsg", &lumv->playerSprites[13], true); + loadWsg("lumbers_cho_15.wsg", &lumv->playerSprites[14], true); + loadWsg("lumbers_cho_16.wsg", &lumv->playerSprites[15], true); + loadWsg("lumbers_cho_17.wsg", &lumv->playerSprites[16], true); + loadWsg("lumbers_cho_18.wsg", &lumv->playerSprites[17], true); + } ESP_LOGI(LUM_TAG, "Loading Enemies"); loadWsg("lumbers_enemy_a1.wsg", &lumv->enemySprites[0], true); @@ -584,7 +606,7 @@ void lumberjackGameLoop(int64_t elapsedUs) ESP_LOGI(LUM_TAG, "Next level"); lumberjackUnloadLevel(); - lumberjackSetupLevel(0); + lumberjackSetupLevel(lumv->localPlayer->type); //Troy lumv->gameState = LUMBERJACK_GAMESTATE_PLAYING; } @@ -986,6 +1008,11 @@ void DrawTitle(void) { drawWsgSimple(&lumv->subtitle_green, (TFT_WIDTH/2)- 36, (TFT_HEIGHT/2) -9); } + else + { + drawWsgSimple(&lumv->subtitle_white, (TFT_WIDTH/2)- 36, (TFT_HEIGHT/2) -9); + + } for (int i = 0; i < LUMBERJACK_MAP_WIDTH; i++) { @@ -1558,8 +1585,6 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs lumberjackOnLocalPlayerDeath(); } - /*return (AA->x < BB->x + BB->width && AA->x + AA->width > BB->x && AA->y < BB->y + BB->height - && AA->y + AA->height > BB->y);*/ } } From 144e172c511d99826e68ef0646d8e1d6229da70e Mon Sep 17 00:00:00 2001 From: MrTroy Date: Fri, 20 Oct 2023 21:58:40 -0700 Subject: [PATCH 19/54] Ghostly fixes Shortened ghost spawn time Fixed game over crash if no ghost was available Added better but temporary secret character code Stopped building level before game was started Game now remembers character chosen, not individual characters High score updates when you beat it --- assets/lumbers/lumberjacks_panic_10.bin | Bin 740 -> 740 bytes assets/lumbers/lumberjacks_panic_4.bin | Bin 398 -> 398 bytes main/modes/lumberjack/lumberjack.c | 48 +++++++++++++++--- main/modes/lumberjack/lumberjack.h | 1 + main/modes/lumberjack/lumberjackGame.c | 60 ++++++++++++++--------- main/modes/lumberjack/lumberjackPlayer.c | 1 - 6 files changed, 79 insertions(+), 31 deletions(-) diff --git a/assets/lumbers/lumberjacks_panic_10.bin b/assets/lumbers/lumberjacks_panic_10.bin index 295ea18f7c4e0b34094866c294092a7da7fd4b45..6f3fd99cc3297684bb338f376a8a9b33f5f2de6f 100644 GIT binary patch delta 31 jcmaFD`h=B7gN2cSkpT?kCJGu(RA8Mf$H>0Xb2bwITY?4z delta 31 jcmaFD`h=B7gPD<$kpT?kCJGu(RA8Mf$H>0Xb2bwITYv@x diff --git a/assets/lumbers/lumberjacks_panic_4.bin b/assets/lumbers/lumberjacks_panic_4.bin index 70282f5e11fbe4f6fe14e8fd8471eda822491f7d..9ac2710a129ce24d511fdd335de72471b2cf3047 100644 GIT binary patch delta 33 icmeBU?qi~ diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index dc0dab453..07aa82441 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -28,6 +28,8 @@ static void lumberjackMsgTxCbFn(p2pInfo* p2p, messageStatus_t status, const uint static void lumberjackMenuCb(const char*, bool selected, uint32_t settingVal); static void lumberjackJoinGame(void); +static bool lumberjackChoUnlocked(void); +static bool lumberjackSpecialUnlocked(void); static const char lumberjackName[] = "Lumber Jack"; static const char lumberjackPanic[] = "Panic"; @@ -92,22 +94,37 @@ static void lumberjackEnterMode(void) addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerClient); lumberjack->menu = endSubMenu(lumberjack->menu); + int characters = 2; - // TODO: Make this a dynamic array that reads what characters have been unlocked. - if (false) // Ignore this line + if (lumberjackChoUnlocked()) { - static const char* defaultCharacters[] = {lumberjackRedCharacter, lumberjackGreenCharacter}; + characters++; + } - addMultiItemToMenu(lumberjack->menu, defaultCharacters, ARRAY_SIZE(defaultCharacters), 0); + if (lumberjackSpecialUnlocked()) + { + characters++; } - else + + char** charactersArray = calloc(characters, sizeof(char*)); + + charactersArray[0] = lumberjackRedCharacter; + charactersArray[1] = lumberjackGreenCharacter; + + int index = 2; + + if (lumberjackChoUnlocked()) { - static const char* defaultCharacterswUnlocks[] - = {lumberjackRedCharacter, lumberjackGreenCharacter, lumberjackSpecialCharacter, lumberjackChoCharacter}; + charactersArray[index++] = lumberjackChoCharacter; + } - addMultiItemToMenu(lumberjack->menu, defaultCharacterswUnlocks, ARRAY_SIZE(defaultCharacterswUnlocks), 0); + if (lumberjackSpecialUnlocked()) + { + charactersArray[index++] = lumberjackSpecialCharacter; } + addMultiItemToMenu(lumberjack->menu, charactersArray, characters, 0); + lumberjack->screen = LUMBERJACK_MENU; // Lumberjack. Game 19 @@ -188,6 +205,21 @@ static void lumberjackBackgroundDrawCallback(int16_t x, int16_t y, int16_t w, in // Are we drawing the game here? } + +//============================================================================== +// UNLOCKS +//============================================================================== + +static bool lumberjackChoUnlocked() +{ + return false; +} + +static bool lumberjackSpecialUnlocked() +{ + return true; +} + //============================================================================== // ESP_NOW //============================================================================== diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 6d131cf0e..281365f1d 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -100,6 +100,7 @@ typedef struct int score; int highscore; + int localPlayerType; int enemyAttackQueue; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 1f94c53b2..e32c8997e 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -41,8 +41,9 @@ #define LUMBERJACK_RESPAWN_MIN 1250 #define LUMBERJACK_UPGRADE_TIMER_OFFSET 250 #define LUMBERJACK_SUBMERGE_TIMER 300 +#define LUMBERJACK_WORLD_WRAP 295 -#define LUMBERJACK_GHOST_SPAWNTIME_MIN 10000 +#define LUMBERJACK_GHOST_SPAWNTIME_MIN 2000 #define LUMBERJACK_GHOST_SPEED_NORMAL 3 #define LUMBERJACK_GHOST_SPEED_FAST 3 #define LUMBERJACK_GHOST_BOX 28 @@ -67,8 +68,11 @@ lumberjackTile_t lumberjackCollisionCheckTiles[32] = {}; void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) { - lumv = calloc(1, sizeof(lumberjackVars_t)); - lumv->lumberjackMain = main; + lumv = calloc(1, sizeof(lumberjackVars_t)); + lumv->lumberjackMain = main; + lumv->localPlayerType = characterIndex; + lumv->score = 0; + lumv->highscore = 5000; loadFont("eightbit_atari_grube2.font", &lumv->arcade, false); @@ -296,15 +300,6 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_alert.wsg", &lumv->alertSprite, true); - if (lumv->gameType == LUMBERJACK_MODE_ATTACK) - { - lumberjackSetupLevel(characterIndex); - } - else if (lumv->gameType == LUMBERJACK_MODE_PANIC) - { - lumberjackSetupLevel(characterIndex); - } - ESP_LOGI(LUM_TAG, "width %d height %d",TFT_WIDTH, TFT_HEIGHT); } @@ -317,7 +312,7 @@ bool lumberjackLoadLevel() { char* levelName[] = { - "lumberjacks_panic_5.bin", + "lumberjacks_panic_1.bin", "lumberjacks_panic_2.bin", "lumberjacks_panic_3.bin", "lumberjacks_panic_4.bin", @@ -327,6 +322,11 @@ bool lumberjackLoadLevel() ESP_LOGI(LUM_TAG, "Level # %d", (int)(lumv->levelIndex % ARRAY_SIZE(levelName))); fname = levelName[lumv->levelIndex % ARRAY_SIZE(levelName)]; + if (!lumv->lumberjackMain->networked) + { + lumv->upgrade = (int)(lumv->levelIndex / ARRAY_SIZE(levelName)); + } + } if (lumv->gameType == LUMBERJACK_MODE_ATTACK) @@ -570,9 +570,10 @@ void lumberjackTitleLoop(int64_t elapsedUs) lumv->btnState = evt.state; } - if (lumv->btnState & PB_A) + if (lumv->btnState & PB_A) // And Game Ready! { lumv->gameState = LUMBERJACK_GAMESTATE_PLAYING; + lumberjackSetupLevel(lumv->localPlayerType); } //Update Animation @@ -601,12 +602,16 @@ void lumberjackGameLoop(int64_t elapsedUs) if (lumv->gameState == LUMBERJACK_GAMESTATE_WINNING) { lumv->levelTime += elapsedUs / 1000; + + if (lumv->ghost != NULL && lumv->ghost->active) + lumv->ghost->currentFrame = 0; + if (lumv->levelTime > 3000) { ESP_LOGI(LUM_TAG, "Next level"); lumberjackUnloadLevel(); - lumberjackSetupLevel(lumv->localPlayer->type); //Troy + lumberjackSetupLevel(lumv->localPlayerType); lumv->gameState = LUMBERJACK_GAMESTATE_PLAYING; } @@ -871,6 +876,11 @@ void baseMode(int64_t elapsedUs) enemy->vy = -30; lumv->score += enemy->scoreValue; + if (lumv->score > lumv->highscore) + { + lumv->highscore = lumv->score; + } + //if game mode is single player decide if you're going to clear the level lumv->enemyKillCount ++; @@ -960,7 +970,8 @@ void baseMode(int64_t elapsedUs) lumv->localPlayer->timerFrameUpdate = 0; //; } - if (NULL != lumv->ghost && lumv->ghost->active) + if (NULL != lumv->ghost && lumv->ghost->active && + lumv->gameState != LUMBERJACK_GAMESTATE_GAMEOVER) { lumv->ghost->timerFrameUpdate += elapsedUs; if (lumv->ghost->timerFrameUpdate > LUMBERJACK_GHOST_ANIMATION) @@ -990,6 +1001,9 @@ void lumberjackOnLocalPlayerDeath(void) if (lumv->lives <= 0) { + if (lumv->ghost != NULL && lumv->ghost->active) + lumv->ghost->currentFrame = 0; + ESP_LOGI(LUM_TAG, "Game over!"); lumv->gameState = LUMBERJACK_GAMESTATE_GAMEOVER; lumv->transitionTimer = 400; @@ -1000,11 +1014,11 @@ void DrawTitle(void) { drawWsgSimple(&lumv->title, (TFT_WIDTH / 2) - 51, (TFT_HEIGHT / 2) - 48); - if (lumv->localPlayer->type == 0) + if (lumv->localPlayerType == 0) { drawWsgSimple(&lumv->subtitle_red, (TFT_WIDTH/2)- 36, (TFT_HEIGHT/2) -9); } - else if (lumv->localPlayer->type == 1) + else if (lumv->localPlayerType == 1) { drawWsgSimple(&lumv->subtitle_green, (TFT_WIDTH/2)- 36, (TFT_HEIGHT/2) -9); } @@ -1020,6 +1034,8 @@ void DrawTitle(void) drawWsgSimple(&lumv->floorTiles[7], i * LUMBERJACK_TILE_SIZE, 224); } + //Press A To Start + drawWsgSimple(&lumv->unusedBlockSprite[lumv->stageAnimationFrame % LUMBERJACK_BLOCK_ANIMATION_MAX], 8.5 * 16, 208 - 64); } @@ -1105,7 +1121,7 @@ void DrawGame(void) for (int i = 0; i < lumv->lives; i++) { - int icon = lumv->localPlayer->type; + int icon = lumv->localPlayerType; if (icon > ARRAY_SIZE(lumv->minicharacters)) { @@ -1121,7 +1137,7 @@ void DrawGame(void) // lumberjackScoreDisplay(lumv->score, 26); - lumberjackScoreDisplay(9999, 206); + lumberjackScoreDisplay(lumv->highscore, 206); @@ -1325,10 +1341,10 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs bool onGround = false; // World wrap - entity->x %= 295; + entity->x %= LUMBERJACK_WORLD_WRAP; if (entity->x < -20) { - entity->x += 295; + entity->x += LUMBERJACK_WORLD_WRAP; } if (entity->state == LUMBERJACK_BUMPED) diff --git a/main/modes/lumberjack/lumberjackPlayer.c b/main/modes/lumberjack/lumberjackPlayer.c index 6c86e7138..45318200c 100644 --- a/main/modes/lumberjack/lumberjackPlayer.c +++ b/main/modes/lumberjack/lumberjackPlayer.c @@ -63,7 +63,6 @@ void lumberjackRespawn(lumberjackEntity_t* hero, int x, int y) int lumberjackGetPlayerAnimation(lumberjackEntity_t* hero) { - // int animationNone[] = {0}; int animation = hero->state; hero->animationSpeed = LUMBERJACK_DEFAULT_ANIMATION_SPEED; From b3d20ac3703b4b189c0ef6f2adfcf0851ff1bb2f Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 21 Oct 2023 14:24:43 -0700 Subject: [PATCH 20/54] Multiplayer madness starts Updated the map editor tiles Removed logging cruft Created multiplayer map for panic Added basic multiplayer for panic --- assets/lumbers/lumberjacks.tsx | 5 +- assets/lumbers/lumberjacks_panic_vs.bin | Bin 0 -> 920 bytes main/modes/lumberjack/lumberjack.c | 76 +++++++-- main/modes/lumberjack/lumberjack.h | 1 + main/modes/lumberjack/lumberjackGame.c | 159 ++++++++++++------ main/modes/lumberjack/lumberjackGame.h | 8 +- .../exporter/lumberjacks-editor.js | 116 ++++++++----- 7 files changed, 254 insertions(+), 111 deletions(-) create mode 100644 assets/lumbers/lumberjacks_panic_vs.bin diff --git a/assets/lumbers/lumberjacks.tsx b/assets/lumbers/lumberjacks.tsx index 5ba723a98..de65a31e2 100644 --- a/assets/lumbers/lumberjacks.tsx +++ b/assets/lumbers/lumberjacks.tsx @@ -1,5 +1,5 @@ - + @@ -34,4 +34,7 @@ + + + diff --git a/assets/lumbers/lumberjacks_panic_vs.bin b/assets/lumbers/lumberjacks_panic_vs.bin new file mode 100644 index 0000000000000000000000000000000000000000..a7e34e66c066a476881b7d498828c64404c3a746 GIT binary patch literal 920 zcmbVJQ5M1=46AJV(De)+!V7vuk7P1qz`${ zq;5U8Sj0OcR~7LqMzd<$c>7q?e*)dBwiVuCsT_(hSpjTaEmi1d%!JtuB7H>5mH0nw zgp2p, esp_now_info->src_addr, data, len, rssi); } @@ -242,19 +253,28 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) { ESP_LOGI(LUM_TAG, "LumberJack.Net ready! %d", (int)p2pGetPlayOrder(p2p)); + uint8_t payload[1 + LUMBERJACK_VLEN] = {VERSION_MSG}; + memcpy(&payload[1], LUMBERJACK_VERSION, LUMBERJACK_VLEN); + if (GOING_FIRST == p2pGetPlayOrder(p2p)) { - ESP_LOGI(LUM_TAG, "HOST?"); const uint8_t testMsg[] = {0x01, 0x02, 0x03, 0x04}; - p2pSendMsg(&lumberjack->p2p, testMsg, ARRAY_SIZE(testMsg), lumberjackMsgTxCbFn); } + else + { + const uint8_t testMsg[] = {0x01, 0x02, 0x03, 0x04}; + p2pSendMsg(&lumberjack->p2p, testMsg, ARRAY_SIZE(testMsg), lumberjackMsgTxCbFn); + } + + p2pSendMsg(&lumberjack->p2p, payload, sizeof(payload), lumberjackMsgTxCbFn); + lumberjackGameReady(); } if (evt == CON_LOST) { // Do we attempt to get it back? - ESP_LOGW(LUM_TAG, "We lost connection!"); + ESP_LOGI(LUM_TAG, "We lost connection!"); } lumberjack->conStatus = evt; @@ -263,9 +283,30 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) { // Do anything + ESP_LOGI(LUM_TAG, "Ya boi got something! %d", len); - if (len > 1) + if (len > 0) { + if (payload[0] == VERSION_MSG) + { + ESP_LOGI(LUM_TAG, "Version received!"); + if (memcmp(&payload[1], LUMBERJACK_VERSION, LUMBERJACK_VLEN)) + { + ESP_LOGI("LUM_TAG", "We're in!"); + } + } + + if (payload[0] == READY_MSG) + { + printf ("Test message"); + lumberjackPlayGame(); + } + + if (payload[0] == ATTACK_MSG) + { + lumberjackOnReceiveAttack(&payload); + } + if (payload[0] == 0x19) { int locX = (int)payload[1] << 0 | (uint32_t)payload[2] << 8; @@ -276,23 +317,31 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) } } + printf("Received %d %d!\n", *payload, len); } -void lumberjackSendAttack(int number) +void lumberjackSendGo(void) { if (lumberjack->networked) { - const uint8_t testMsg[] = {0x13}; - p2pSendMsg(&lumberjack->p2p, testMsg, ARRAY_SIZE(testMsg), lumberjackMsgTxCbFn); + const uint8_t msg[] = {READY_MSG}; + p2pSendMsg(&lumberjack->p2p, msg, ARRAY_SIZE(msg), lumberjackMsgTxCbFn); } } -void lumberjackUpdateLocation(int ghostX, int ghostY, int frame) +void lumberjackSendAttack(uint8_t* number) { - const uint8_t locationMessage[6] - = {0x19, (uint8_t)(ghostX >> 0), (uint8_t)(ghostX >> 8), (uint8_t)(ghostY >> 0), (uint8_t)(ghostY >> 8), frame}; - p2pSendMsg(&lumberjack->p2p, locationMessage, ARRAY_SIZE(locationMessage), lumberjackMsgTxCbFn); + if (lumberjack->networked) + { + const uint8_t testMsg[] = {ATTACK_MSG}; + + + uint8_t payload[9] = {ATTACK_MSG}; + memcpy(&payload[1], number, 8); + + p2pSendMsg(&lumberjack->p2p, payload, ARRAY_SIZE(payload), lumberjackMsgTxCbFn); + } } /** @@ -305,6 +354,7 @@ void lumberjackUpdateLocation(int ghostX, int ghostY, int frame) */ static void lumberjackMsgTxCbFn(p2pInfo* p2p, messageStatus_t status, const uint8_t* data, uint8_t len) { + ESP_LOGI(LUM_TAG, "Ya boi sent something! %d", status); } static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingVal) diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 281365f1d..dce814f87 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -74,6 +74,7 @@ typedef struct { bool loaded; bool hasWon; + bool gameReady; font_t arcade; lumberjack_t* lumberjackMain; menu_t* menu; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index e32c8997e..063132de4 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -49,6 +49,10 @@ #define LUMBERJACK_GHOST_BOX 28 #define LUMBERJACK_GHOST_ANIMATION 2500 +#define LUMBERJACK_WATER_FAST_DRAIN 6 +#define LUMBERJACK_WATER_SLOW_DRAIN 3 +#define LUMBERJACK_WATER_INCREASE 10 + #define LUMBERJACK_ITEM_RESETTIME 2500 #define LUMBERJACK_TILE_SIZE 16 @@ -95,8 +99,9 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->gameState = LUMBERJACK_GAMESTATE_TITLE; lumv->levelIndex = 0; lumv->lives = 3; + lumv->gameReady = !(main->networked); - ESP_LOGI(LUM_TAG, "Load Title"); + //ESP_LOGI(LUM_TAG, "Load Title"); loadWsg("lumbers_title.wsg", &lumv->title, true); if (main->screen == LUMBERJACK_A) @@ -116,7 +121,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_game_over.wsg", &lumv->gameoverSprite, true); - ESP_LOGI(LUM_TAG, "Loading floor Tiles"); + //ESP_LOGI(LUM_TAG, "Loading floor Tiles"); loadWsg("bottom_floor1.wsg", &lumv->floorTiles[0], true); loadWsg("bottom_floor2.wsg", &lumv->floorTiles[1], true); loadWsg("bottom_floor3.wsg", &lumv->floorTiles[2], true); @@ -129,7 +134,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("bottom_floor10.wsg", &lumv->floorTiles[9], true); loadWsg("lumbers_itemused_block.wsg", &lumv->floorTiles[10], true); loadWsg("lumbers_rtile_1.wsg", &lumv->floorTiles[11], true); - ESP_LOGI(LUM_TAG, "Loading Animation Tiles"); + //ESP_LOGI(LUM_TAG, "Loading Animation Tiles"); loadWsg("water_floor1.wsg", &lumv->animationTiles[0], true); loadWsg("water_floor2.wsg", &lumv->animationTiles[1], true); @@ -150,15 +155,15 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) - ESP_LOGI(LUM_TAG, "Loading Characters"); + //ESP_LOGI(LUM_TAG, "Loading Characters"); - ESP_LOGI(LUM_TAG, "*Loading character icons"); + //ESP_LOGI(LUM_TAG, "*Loading character icons"); loadWsg("lumbers_red_lives.wsg", &lumv->minicharacters[0], true); loadWsg("lumbers_green_lives.wsg", &lumv->minicharacters[1], true); loadWsg("secret_swadgeland_lives.wsg", &lumv->minicharacters[2], true); loadWsg("lumbers_cho_lives.wsg", &lumv->minicharacters[3], true); - ESP_LOGI(LUM_TAG, "*Loading character sprites"); + //ESP_LOGI(LUM_TAG, "*Loading character sprites"); if (characterIndex == 0) { loadWsg("lumbers_red_1.wsg", &lumv->playerSprites[0], true); @@ -245,7 +250,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_cho_18.wsg", &lumv->playerSprites[17], true); } - ESP_LOGI(LUM_TAG, "Loading Enemies"); + //ESP_LOGI(LUM_TAG, "Loading Enemies"); loadWsg("lumbers_enemy_a1.wsg", &lumv->enemySprites[0], true); loadWsg("lumbers_enemy_a2.wsg", &lumv->enemySprites[1], true); loadWsg("lumbers_enemy_a3.wsg", &lumv->enemySprites[2], true); @@ -295,37 +300,38 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_normal_ax_block7.wsg", &lumv->unusedBlockSprite[6], true); loadWsg("lumbers_item_ui.wsg", &lumv->ui[0], true); - - ESP_LOGI(LUM_TAG, "AXE %d", lumv->axeBlocks[0]->active); - loadWsg("lumbers_alert.wsg", &lumv->alertSprite, true); - ESP_LOGI(LUM_TAG, "width %d height %d",TFT_WIDTH, TFT_HEIGHT); } bool lumberjackLoadLevel() { - char* fname = "lumberjacks_panic_4.bin"; + char* fname = "lumberjacks_panic_vs.bin"; lumv->upgrade = 0; if (lumv->gameType == LUMBERJACK_MODE_PANIC) { - char* levelName[] = - { - "lumberjacks_panic_1.bin", - "lumberjacks_panic_2.bin", - "lumberjacks_panic_3.bin", - "lumberjacks_panic_4.bin", - "lumberjacks_panic_5.bin", - "lumberjacks_panic_10.bin", - }; - ESP_LOGI(LUM_TAG, "Level # %d", (int)(lumv->levelIndex % ARRAY_SIZE(levelName))); - fname = levelName[lumv->levelIndex % ARRAY_SIZE(levelName)]; if (!lumv->lumberjackMain->networked) { + char* levelName[] = + { + "lumberjacks_panic_1.bin", + "lumberjacks_panic_2.bin", + "lumberjacks_panic_3.bin", + "lumberjacks_panic_4.bin", + "lumberjacks_panic_5.bin", + "lumberjacks_panic_10.bin", + }; + + fname = levelName[lumv->levelIndex % ARRAY_SIZE(levelName)]; + lumv->upgrade = (int)(lumv->levelIndex / ARRAY_SIZE(levelName)); } + else + { + fname = "lumberjacks_panic_vs.bin"; + } } @@ -352,7 +358,6 @@ bool lumberjackLoadLevel() } - size_t ms; uint8_t *buffer = spiffsReadFile(fname, &ms, false); @@ -426,6 +431,8 @@ bool lumberjackLoadLevel() lumv->playerSpawnX = (int)buffer[offset]; lumv->playerSpawnY = (int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8); + //lumv->yOffset = lumv->playerSpawnY - LUMBERJACK_SCREEN_Y_OFFSET; + ESP_LOGI(LUM_TAG, "%d %d", lumv->playerSpawnY, buffer[offset]); free(buffer); @@ -496,12 +503,6 @@ void lumberjackSetupLevel(int characterIndex) lumv->ghost->spawnTime = lumv->ghostSpawnTime ; } - // for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy4Count; eSpawnIndex++) - // { - // lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); - // lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); - // } - offset += lumv->enemy4Count; for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy5Count; eSpawnIndex++) { @@ -570,10 +571,14 @@ void lumberjackTitleLoop(int64_t elapsedUs) lumv->btnState = evt.state; } - if (lumv->btnState & PB_A) // And Game Ready! + if (lumv->btnState & PB_A && lumv->gameReady) // And Game Ready! { - lumv->gameState = LUMBERJACK_GAMESTATE_PLAYING; - lumberjackSetupLevel(lumv->localPlayerType); + lumberjackPlayGame(); + + if (lumv->lumberjackMain->networked && lumv->lumberjackMain->conStatus == CON_ESTABLISHED) + { + lumberjackSendGo(); + } } //Update Animation @@ -590,6 +595,17 @@ void lumberjackTitleLoop(int64_t elapsedUs) DrawTitle(); } +void lumberjackPlayGame() +{ + lumv->gameState = LUMBERJACK_GAMESTATE_PLAYING; + lumberjackSetupLevel(lumv->localPlayerType); +} + +void lumberjackGameReady(void) +{ + lumv->gameReady = true; +} + void lumberjackGameLoop(int64_t elapsedUs) { @@ -630,6 +646,7 @@ void lumberjackGameLoop(int64_t elapsedUs) switchToSwadgeMode(&lumberjackMode); } } + ESP_LOGI(LUM_TAG, "Time remaining %d %d",lumv->itemBlockTime, lumv->waterSpeed); //if panic mode do water if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING && lumv->gameType == LUMBERJACK_MODE_PANIC) @@ -638,7 +655,7 @@ void lumberjackGameLoop(int64_t elapsedUs) { lumv->itemBlockTime -= elapsedUs/10000; - if (lumv->itemBlockTime < 0) + if (lumv->itemBlockTime <= 0) { lumv->itemBlockReady = true; lumv->itemBlockTime = 0; @@ -655,7 +672,7 @@ void lumberjackGameLoop(int64_t elapsedUs) if (lumv->waterLevel > lumv->currentMapHeight * LUMBERJACK_TILE_SIZE) { lumv->waterLevel = lumv->currentMapHeight * LUMBERJACK_TILE_SIZE; - lumv->waterTimer = lumv->waterSpeed * 10; + lumv->waterTimer = lumv->waterSpeed * LUMBERJACK_WATER_INCREASE; // Magic number lumv->waterDirection = -1; } @@ -666,10 +683,8 @@ void lumberjackGameLoop(int64_t elapsedUs) } - // If networked - if (lumv->lumberjackMain->networked && lumv->lumberjackMain->conStatus == CON_ESTABLISHED) - lumberjackUpdateLocation(lumv->localPlayer->x, lumv->localPlayer->y, lumv->localPlayer->drawFrame); } + DrawGame(); } @@ -710,7 +725,7 @@ void baseMode(int64_t elapsedUs) { ESP_LOGI(LUM_TAG, "Attack this frame!"); - lumberjackSendAttack(0); + lumberjackSendAttack(lumv->attackQueue); } } @@ -1034,7 +1049,20 @@ void DrawTitle(void) drawWsgSimple(&lumv->floorTiles[7], i * LUMBERJACK_TILE_SIZE, 224); } - //Press A To Start + if (lumv->gameReady) + { + //Press A To Start + lumberjackTitleDisplayText("Press A to start", (TFT_WIDTH/2) - 70, 180); + } + else if (lumv->lumberjackMain->networked && lumv->lumberjackMain->host) + { + lumberjackTitleDisplayText("Waiting for client", (TFT_WIDTH/2) - 80, 180); + } + else if (lumv->lumberjackMain->networked && !lumv->lumberjackMain->host) + { + lumberjackTitleDisplayText("Looking for host", (TFT_WIDTH/2) - 80, 180); + } + drawWsgSimple(&lumv->unusedBlockSprite[lumv->stageAnimationFrame % LUMBERJACK_BLOCK_ANIMATION_MAX], 8.5 * 16, 208 - 64); } @@ -1078,9 +1106,12 @@ void DrawGame(void) // ESP_LOGI(LUM_TAG, "DEAD %d", currentFrame); // If panic mode - lumv->waterDirection = 3; - lumv->waterTimer = lumv->waterSpeed; - lumv->waterLevel += lumv->waterDirection; + if (lumv->gameType == LUMBERJACK_MODE_PANIC) + { + lumv->waterDirection = LUMBERJACK_WATER_SLOW_DRAIN; + lumv->waterTimer = lumv->waterSpeed; + lumv->waterLevel += lumv->waterDirection; + } } @@ -1139,8 +1170,6 @@ void DrawGame(void) lumberjackScoreDisplay(lumv->score, 26); lumberjackScoreDisplay(lumv->highscore, 206); - - if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING && lumv->levelTime < 5000) { char level_display[20] = {0}; @@ -1193,6 +1222,16 @@ void DrawGame(void) */ } +void lumberjackTitleDisplayText(char* string, int locationX, int locationY) +{ + + drawText(&lumv->arcade, c000, string, locationX, locationY + 2); + drawText(&lumv->arcade, c000, string, locationX, locationY - 1); + drawText(&lumv->arcade, c000, string, locationX - 1, locationY); + drawText(&lumv->arcade, c000, string, locationX + 1, locationY); + drawText(&lumv->arcade, c555, string, locationX, locationY); +} + void lumberjackScoreDisplay(int score, int locationX) { char score_display[20] = {0}; @@ -1291,6 +1330,25 @@ void lumberjackSpawnCheck(int64_t elapseUs) } } +void lumberjackOnReceiveAttack(uint8_t* attack) +{ + if (lumv->gameType == LUMBERJACK_MODE_PANIC) + { + + lumv->waterDirection = -1; //Even if it is draining + lumv->waterSpeed -= 5; + if (lumv->waterSpeed < 0) + { + lumv->waterSpeed = 0; + } + } + + if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + + } +} + void lumberjackAttackCheck(int64_t elapseUs) { @@ -1559,10 +1617,6 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs return; } } - else - { - // Entity is not local player - } } if (entity->state != LUMBERJACK_OFFSCREEN && entity->state != LUMBERJACK_DEAD) @@ -1884,7 +1938,7 @@ void lumberjackUseBlock() if (lumv->gameType == LUMBERJACK_MODE_PANIC) { - lumv->waterDirection = 6; + lumv->waterDirection = LUMBERJACK_WATER_FAST_DRAIN; lumv->waterTimer = lumv->waterSpeed; lumv->waterLevel += lumv->waterDirection; @@ -1893,10 +1947,7 @@ void lumberjackUseBlock() if (lumv->lumberjackMain->networked) { //Increase speed of opponent's water! - } - else - { - + lumberjackSendAttack(lumv->attackQueue); } } } diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 66a1eb18a..487a07235 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -13,7 +13,6 @@ void lumberjackUpdate(int64_t elapseUs); void lumberjackTitleLoop(int64_t elapsedUs); void lumberjackGameLoop(int64_t elapsedUs); -void lumberjackUpdateLocation(int ghostX, int ghostY, int frame); void restartLevel(void); @@ -24,9 +23,14 @@ void lumberjackSpawnCheck(int64_t elapseUs); void lumberjackAttackCheck(int64_t elapseUs); void lumberjackScoreDisplay(int score, int locationX); +void lumberjackTitleDisplayText(char* string, int locationX, int locationY); void baseMode(int64_t elapsedUs); -void lumberjackSendAttack(int number); +void lumberjackSendAttack(uint8_t* number); +void lumberjackOnReceiveAttack(uint8_t* attack); +void lumberjackGameReady(void); +void lumberjackPlayGame(void); +void lumberjackSendGo(void); void lumberjackUseBlock(void); diff --git a/tools/lumber_jacks/exporter/lumberjacks-editor.js b/tools/lumber_jacks/exporter/lumberjacks-editor.js index 4898d14c1..8ea812d71 100644 --- a/tools/lumber_jacks/exporter/lumberjacks-editor.js +++ b/tools/lumber_jacks/exporter/lumberjacks-editor.js @@ -9,6 +9,7 @@ tiled.registerMapFormat("Lumber Jacks", { const tileDataOffset = 12; const tileSizeInPixels = 16; + var map = new TileMap(); //The first two bytes contain the width and height of the tilemap in tiles @@ -26,6 +27,20 @@ tiled.registerMapFormat("Lumber Jacks", { layer.height = map.height; layer.name = 'Main'; + map.setProperty("enemy1", view[1]); + map.setProperty("enemy2", view[2]); + map.setProperty("enemy3", view[3]); + map.setProperty("enemy4", view[4]); + map.setProperty("enemy5", view[5]); + map.setProperty("enemy6", view[6]); + map.setProperty("enemy7", view[7]); + map.setProperty("enemy8", view[8]); + + map.setProperty("ghost spawn time", view[9]); //Seriously Troy! Document your code! + //map.setProperty("???", view[10]); // - The maniac who knows where you live! + + map.setProperty("time", view[11]); //Time + var layerEdit = layer.edit(); var importTileX = 0; var importTileY = 0; @@ -33,9 +48,11 @@ tiled.registerMapFormat("Lumber Jacks", { //Import tile data for(let i = 0; i < tileDataLength; i++){ - let tileId = view[i + tileDataOffset]; - layerEdit.setTile(importTileX, importTileY, tileset.tile(tileId)); - + let tileId = view[i + 12] - 1; + + if (tileId >= 0) + layerEdit.setTile(importTileX, importTileY, tileset.tile(tileId)); + importTileX++; if(importTileX >= map.width){ importTileY++; @@ -43,69 +60,86 @@ tiled.registerMapFormat("Lumber Jacks", { } } - layerEdit.apply(); - + var writePosition = 12 + tileDataLength; + map.setProperty("spawnx", view[writePosition]); + map.setProperty("spawny", (view[writePosition + 1]) + (view[writePosition + 2] << 8)); + map.setProperty("switches", view[writePosition+3]); + tiled.log(writePosition); + /* + //I need to decide where to put the switches. I believe this is where the switches layout was going to be. + view [writePosition+4] = 8; //WTF Troy? + view [writePosition+5] = 9; //WTF Troy? + view [writePosition+6] = 8; //WTF Troy? + view [writePosition+7] = 4; //WTF Troy?*/ + + //map.setProperty("???", view[writePosition+4]); //Yay more undocumented variables! + //map.setProperty("???", view[writePosition+5]); //Yay more undocumented variables! + //map.setProperty("???", view[writePosition+6]); //Yay more undocumented variables! + //map.setProperty("???", view[writePosition+7]); //Yay more undocumented variables! + + layerEdit.apply(); map.addLayer(layer); + + + + file.close(); return map; }, write: (map, fileName) => { - let file = new BinaryFile(filename, BinaryFile.WriteOnly); + var layer; + + for (let i = 0; i < map.layerCount; ++i) + { + layer = map.layerAt(0); + if (layer.isTileLayer) break; + } + + if (!layer.isTileLayer) + { + return; + } + + let file = new BinaryFile(fileName, BinaryFile.WriteOnly); let buffer = new ArrayBuffer(20 + layer.height * layer.width); let view = new Uint8Array(buffer); - + let writePosition = 12; view[0] = layer.height; - view[1] = 3; //Enemy 1 - view[2] = 0; //Enemy 2 - view[3] = 0; //Enemy 3 - view[4] = 0; //Enemy 4 - view[5] = 0; //Enemy 5 - view[6] = 0; //Enemy 6 - view[7] = 0; //Enemy 7 - view[8] = 0; //Enemy 8 - view[9] = 0; // + view[1] = map.property("enemy1"); //Enemy 1 + view[2] = map.property("enemy2"); //Enemy 2 + view[3] = map.property("enemy3"); //Enemy 3 + view[4] = map.property("enemy4"); //Enemy 4 + view[5] = map.property("enemy5"); //Enemy 5 + view[6] = map.property("enemy6"); //Enemy 6 + view[7] = map.property("enemy7"); //Enemy 7 + view[8] = map.property("enemy8"); //Enemy 8 + view[9] = map.property("ghost spawn time"); // Only if Enemy 4 is set to 1 or higher view[10] = 0; // view[11] = 30; //Time - + //write level - const layer = map.layerAt(0); - let writePosition = 12; for (let y = 0; y 256 - view [writePosition+1] = 30; - view [writePosition+2] = 0; - /* - - //The last 2 bytes hold the total number of "target block tiles" - //Forced into a (hopefully) unsigned 16 bit integer, little endian - //There's probably a better way to do this... - let totalTargetBlockTilesLowerByte = totalTargetBlockTiles & 255; - let totalTargetBlockTilesUpperByte = (totalTargetBlockTiles >> 8) & 255; - view[writePosition] = totalTargetBlockTilesLowerByte; - writePosition++; - view[writePosition] = totalTargetBlockTilesUpperByte; - writePosition++; - */ - - + view [writePosition] = map.property("spawnx") % 240; // Player X starting position Always < 256 + view [writePosition + 1] = map.property("spawny") & 255; + view [writePosition + 2] = map.property("spawny") >> 8; + + //extra data for I don't know what view [writePosition+3] = 2; //Number of switches view [writePosition+4] = 8; //WTF Troy? view [writePosition+5] = 9; //WTF Troy? From 6669ece1765d8a29cb1622b1b4e0e744b3f7ea69 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 21 Oct 2023 18:57:47 -0700 Subject: [PATCH 21/54] Added You Win You now win in mutliplayer instead of it saying game over --- assets/lumbers/lumbers_game_over_win.png | Bin 0 -> 367 bytes main/modes/lumberjack/lumberjack.c | 16 +++++- main/modes/lumberjack/lumberjack.h | 5 +- main/modes/lumberjack/lumberjackGame.c | 63 +++++++++++++++++++---- main/modes/lumberjack/lumberjackGame.h | 3 ++ 5 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 assets/lumbers/lumbers_game_over_win.png diff --git a/assets/lumbers/lumbers_game_over_win.png b/assets/lumbers/lumbers_game_over_win.png new file mode 100644 index 0000000000000000000000000000000000000000..58bb05d43c0fea89f22d3f0b0cacba6054d72744 GIT binary patch literal 367 zcmV-#0g(QQP)Px$DM>^@RA_*+s=~Hv)k2D&ONCc)AdtUz^O?dB<_{AbwhzcKwoFP<)n$%3BQD zlkXj~Bg6LT*(r|s4X(cr#5_bdjNYf73Y08}R)Mgda84;GRaxM?M^i;k(4Z8iyiJ?i zM3V}XxG?8H%BrI~quxMcTuT*HAg%>bVQ-R;xRZa&b#wYV&?VR6|2gr$(6HXfct}kcGy|M~RT=Y^PG5e>`YQQ@_8k$3lR-#d) z0{KDMxZ-SC_^&?4kop)CLa literal 0 HcmV?d00001 diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index cce530a5b..8c5e53a5b 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -223,7 +223,7 @@ static void lumberjackBackgroundDrawCallback(int16_t x, int16_t y, int16_t w, in static bool lumberjackChoUnlocked() { - return false; + return true; } static bool lumberjackSpecialUnlocked() @@ -307,6 +307,11 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) lumberjackOnReceiveAttack(&payload); } + if (payload[0] == DEATH_MSG) + { + lumberjackOnReceiveDeath(payload[1] != 0x00); + } + if (payload[0] == 0x19) { int locX = (int)payload[1] << 0 | (uint32_t)payload[2] << 8; @@ -344,6 +349,15 @@ void lumberjackSendAttack(uint8_t* number) } } +void lumberjackSendDeath(bool gameover) +{ + if (lumberjack->networked) + { + const uint8_t payload[2] = {DEATH_MSG, (gameover ? 0x01 : 0x00)}; + p2pSendMsg(&lumberjack->p2p, payload, ARRAY_SIZE(payload), lumberjackMsgTxCbFn); + } +} + /** * @brief TODO use this somewhere * diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index dce814f87..d81b036a4 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -121,8 +121,8 @@ typedef struct int enemy7Count; int enemy8Count; - int attackQueue[8]; - int receiveQueue[8]; + uint8_t attackQueue[8]; + uint8_t receiveQueue[8]; wsg_t floorTiles[20]; wsg_t animationTiles[20]; @@ -134,6 +134,7 @@ typedef struct wsg_t subtitle_green; wsg_t subtitle_white; wsg_t gameoverSprite; + wsg_t gamewinSprite; lumberjackTile_t* tile; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 063132de4..becc6dbc6 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -120,6 +120,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) } loadWsg("lumbers_game_over.wsg", &lumv->gameoverSprite, true); + if (lumv->lumberjackMain->networked) loadWsg("lumbers_game_over_win.wsg", &lumv->gamewinSprite, true); //ESP_LOGI(LUM_TAG, "Loading floor Tiles"); loadWsg("bottom_floor1.wsg", &lumv->floorTiles[0], true); @@ -646,7 +647,6 @@ void lumberjackGameLoop(int64_t elapsedUs) switchToSwadgeMode(&lumberjackMode); } } - ESP_LOGI(LUM_TAG, "Time remaining %d %d",lumv->itemBlockTime, lumv->waterSpeed); //if panic mode do water if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING && lumv->gameType == LUMBERJACK_MODE_PANIC) @@ -762,11 +762,22 @@ void baseMode(int64_t elapsedUs) if (lumv->localPlayer->onGround && lumv->hasWon) { - ESP_LOGI(LUM_TAG, "%ld ", (long)lumv->levelTime); - lumv->gameState = LUMBERJACK_GAMESTATE_WINNING; - lumv->localPlayer->state = LUMBERJACK_VICTORY; - lumv->levelTime = 0; - lumv->levelIndex++; + lumv->localPlayer->flipped = 1; + if (lumv->lumberjackMain->networked) + { + lumv->localPlayer->state = LUMBERJACK_VICTORY; + lumv->gameState = LUMBERJACK_GAMESTATE_GAMEOVER; + lumv->transitionTimer = 400; + } + else + { + lumv->gameState = LUMBERJACK_GAMESTATE_WINNING; + lumv->localPlayer->state = LUMBERJACK_VICTORY; + lumv->levelTime = 0; + lumv->levelIndex++; + } + + } } @@ -777,7 +788,7 @@ void baseMode(int64_t elapsedUs) if (lumv->gameType == LUMBERJACK_MODE_PANIC) { - lumberjackSpawnCheck(elapsedUs); + if (false == lumv->hasWon) lumberjackSpawnCheck(elapsedUs); } if (lumv->gameType == LUMBERJACK_MODE_ATTACK) { @@ -1019,12 +1030,18 @@ void lumberjackOnLocalPlayerDeath(void) if (lumv->ghost != NULL && lumv->ghost->active) lumv->ghost->currentFrame = 0; - ESP_LOGI(LUM_TAG, "Game over!"); lumv->gameState = LUMBERJACK_GAMESTATE_GAMEOVER; lumv->transitionTimer = 400; } + + if (lumv->lumberjackMain->networked) + { + lumberjackSendDeath(lumv->lives <= 0); + + } } + void DrawTitle(void) { drawWsgSimple(&lumv->title, (TFT_WIDTH / 2) - 51, (TFT_HEIGHT / 2) - 48); @@ -1163,7 +1180,14 @@ void DrawGame(void) if (lumv->gameState == LUMBERJACK_GAMESTATE_GAMEOVER) { - drawWsgSimple(&lumv->gameoverSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); + if (lumv->hasWon) + { + drawWsgSimple(&lumv->gamewinSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); + } + else + { + drawWsgSimple(&lumv->gameoverSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); + } } // @@ -1349,6 +1373,23 @@ void lumberjackOnReceiveAttack(uint8_t* attack) } } +void lumberjackOnReceiveDeath(bool gameover) +{ + ESP_LOGI(LUM_TAG, "Player died! Haha"); + + if (gameover) + { + lumv->hasWon = true; + + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++ ) + { + if (lumv->enemy[i] == NULL) continue; + + lumv->enemy[i]->state = LUMBERJACK_DEAD; + } + + } +} void lumberjackAttackCheck(int64_t elapseUs) { @@ -1965,6 +2006,10 @@ void lumberjackExitGameMode(void) freeWsg(&lumv->gameoverSprite); + if (lumv->lumberjackMain->networked) + freeWsg(&lumv->gamewinSprite); + + // Free the enemies for (int i = 0; i < ARRAY_SIZE(lumv->enemySprites); i++) { diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 487a07235..3f4baa67a 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -28,9 +28,12 @@ void lumberjackTitleDisplayText(char* string, int locationX, int locationY); void baseMode(int64_t elapsedUs); void lumberjackSendAttack(uint8_t* number); void lumberjackOnReceiveAttack(uint8_t* attack); +void lumberjackOnReceiveDeath(bool gameover); void lumberjackGameReady(void); void lumberjackPlayGame(void); void lumberjackSendGo(void); +void lumberjackSendDeath(bool gameover); + void lumberjackUseBlock(void); From 337deea853c0c61ebd21a9be82df1aba0d8e2841 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Mon, 30 Oct 2023 21:09:04 -0700 Subject: [PATCH 22/54] Added combos at a crude level --- main/modes/lumberjack/lumberjack.h | 3 +++ main/modes/lumberjack/lumberjackGame.c | 30 +++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index d81b036a4..c7b01901f 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -121,6 +121,9 @@ typedef struct int enemy7Count; int enemy8Count; + int comboTime; + int comboAmount; + uint8_t attackQueue[8]; uint8_t receiveQueue[8]; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index becc6dbc6..aced40f60 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -54,6 +54,7 @@ #define LUMBERJACK_WATER_INCREASE 10 #define LUMBERJACK_ITEM_RESETTIME 2500 +#define LUMBERJACK_COMBO_RESET_TIME 1500 #define LUMBERJACK_TILE_SIZE 16 @@ -445,6 +446,8 @@ void lumberjackSetupLevel(int characterIndex) { lumv->enemyKillCount = 0; lumv->totalEnemyCount = 0; + lumv->comboTime = 0; + lumv->comboAmount = 0; lumv->hasWon = false; ESP_LOGI(LUM_TAG, "LOADING LEVEL"); @@ -715,6 +718,21 @@ void baseMode(int64_t elapsedUs) { lumv->levelTime += elapsedUs / 1000; + if (lumv->comboTime > 0) + { + lumv->comboTime -= elapsedUs / 1000; + + if (lumv->comboTime < 0) + { + lumv->comboTime = 0; + ESP_LOGI(LUM_TAG, "Combo end!"); + + lumv->comboAmount = 0; + } + + ESP_LOGI(LUM_TAG, "Combo Time: %d", lumv->comboTime); + } + // Check Controls if (lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_UNSPAWNED) { @@ -900,7 +918,16 @@ void baseMode(int64_t elapsedUs) { enemy->state = LUMBERJACK_DEAD; // Enemy Death enemy->vy = -30; - lumv->score += enemy->scoreValue; + + if (lumv->comboTime > 0) + { + ESP_LOGI(LUM_TAG, "COMBO!"); + ++lumv->comboAmount; + } + + lumv->score += enemy->scoreValue * (lumv->comboAmount + 1); + + lumv->comboTime = LUMBERJACK_COMBO_RESET_TIME; if (lumv->score > lumv->highscore) { @@ -1024,6 +1051,7 @@ void lumberjackOnLocalPlayerDeath(void) lumv->localPlayer->active = false; lumv->localPlayer->jumping = false; lumv->localPlayer->jumpTimer = 0; + lumv->comboTime = 0; if (lumv->lives <= 0) { From 19ff03532a9d9fda367b12b90770e88514839eb5 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Thu, 2 Nov 2023 21:33:33 -0700 Subject: [PATCH 23/54] Spawning Update starting Attack Decreased maximum enemy count Added better enemy spawn timer for two different modes Modified spawning slightly Added two levels for single player attack mode --- assets/lumbers/lumberjacks_attack_1.bin | Bin 0 -> 398 bytes assets/lumbers/lumberjacks_attack_2.bin | Bin 0 -> 488 bytes assets/lumbers/lumberjacks_panic_vs.bin | Bin 920 -> 920 bytes main/modes/lumberjack/lumberjack.c | 39 +++-- main/modes/lumberjack/lumberjack.h | 8 +- main/modes/lumberjack/lumberjackEntity.h | 1 - main/modes/lumberjack/lumberjackGame.c | 192 ++++++++++++++--------- main/modes/lumberjack/lumberjackGame.h | 4 +- 8 files changed, 145 insertions(+), 99 deletions(-) create mode 100644 assets/lumbers/lumberjacks_attack_1.bin create mode 100644 assets/lumbers/lumberjacks_attack_2.bin diff --git a/assets/lumbers/lumberjacks_attack_1.bin b/assets/lumbers/lumberjacks_attack_1.bin new file mode 100644 index 0000000000000000000000000000000000000000..05049ec3000996ea8e378a2cbafe63e622806757 GIT binary patch literal 398 zcmWd?U|?Wm00I#PIS@q+zybjvqmY=?Fd1S73kx$d3k!@5WnkqJZzsaZFh>)wmyk+E aCInywD`sQofB{Y}phyKDBNGQF2MYifM*`W9v-lJ sAY3GQVwo^=K#l?GA=?~m_AxRc04rDl8#@OKaB=}fD)<p2p, esp_now_info->src_addr, data, len, rssi); + /*ESP_LOGI(LUM_TAG, "Getting: %d %d", len, rssi); + for (int i = 0; i < len; i++) + { + ESP_LOGI(LUM_TAG, "data %d) %d", i, data[i]); + }*/ + p2pRecvCb(&lumberjack->p2p, esp_now_info->src_addr, (const uint8_t*)data, len, rssi); } static void lumberjackEspNowSendCb(const uint8_t* mac_addr, esp_now_send_status_t status) { + //ESP_LOGI(LUM_TAG, "STATUS %d", status); p2pSendCb(&lumberjack->p2p, mac_addr, status); } @@ -256,6 +261,7 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) uint8_t payload[1 + LUMBERJACK_VLEN] = {VERSION_MSG}; memcpy(&payload[1], LUMBERJACK_VERSION, LUMBERJACK_VLEN); + /* if (GOING_FIRST == p2pGetPlayOrder(p2p)) { const uint8_t testMsg[] = {0x01, 0x02, 0x03, 0x04}; @@ -265,7 +271,7 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) { const uint8_t testMsg[] = {0x01, 0x02, 0x03, 0x04}; p2pSendMsg(&lumberjack->p2p, testMsg, ARRAY_SIZE(testMsg), lumberjackMsgTxCbFn); - } + }*/ p2pSendMsg(&lumberjack->p2p, payload, sizeof(payload), lumberjackMsgTxCbFn); lumberjackGameReady(); @@ -283,7 +289,7 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) { // Do anything - ESP_LOGI(LUM_TAG, "Ya boi got something! %d", len); + ESP_LOGI(LUM_TAG, "Ya boi got something! %d", (uint8_t)payload[0]); if (len > 0) { @@ -304,11 +310,12 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) if (payload[0] == ATTACK_MSG) { - lumberjackOnReceiveAttack(&payload); + lumberjackOnReceiveAttack(payload); } if (payload[0] == DEATH_MSG) { + ESP_LOGI(LUM_TAG, "Playher died!"); lumberjackOnReceiveDeath(payload[1] != 0x00); } @@ -339,12 +346,12 @@ void lumberjackSendAttack(uint8_t* number) { if (lumberjack->networked) { - const uint8_t testMsg[] = {ATTACK_MSG}; - - uint8_t payload[9] = {ATTACK_MSG}; memcpy(&payload[1], number, 8); - + for (int i = 0; i < ARRAY_SIZE(payload); i++) + { + ESP_LOGI(LUM_TAG, "SENDING %d) %d", i, payload[i]); + } p2pSendMsg(&lumberjack->p2p, payload, ARRAY_SIZE(payload), lumberjackMsgTxCbFn); } } @@ -368,7 +375,7 @@ void lumberjackSendDeath(bool gameover) */ static void lumberjackMsgTxCbFn(p2pInfo* p2p, messageStatus_t status, const uint8_t* data, uint8_t len) { - ESP_LOGI(LUM_TAG, "Ya boi sent something! %d", status); + } static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingVal) diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index c7b01901f..fb61d7853 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -117,10 +117,14 @@ typedef struct int enemy3Count; int enemy4Count; int enemy5Count; - int enemy6Count; + int enemy6Count; int enemy7Count; int enemy8Count; + int enemySpawnTime; + int enemyReceiveSpawnTime; + int enemySpawnAmount; + int comboTime; int comboAmount; @@ -153,7 +157,7 @@ typedef struct wsg_t alertSprite; - lumberjackEntity_t* enemy[64]; + lumberjackEntity_t* enemy[32]; lumberjackAxeBlock_t* axeBlocks[8]; lumberjackEntity_t* localPlayer; diff --git a/main/modes/lumberjack/lumberjackEntity.h b/main/modes/lumberjack/lumberjackEntity.h index 5bdbd52b9..6b8423f69 100644 --- a/main/modes/lumberjack/lumberjackEntity.h +++ b/main/modes/lumberjack/lumberjackEntity.h @@ -51,7 +51,6 @@ typedef struct int direction; int animationSpeed; int64_t timerFrameUpdate; - char name[16]; } lumberjackEntity_t; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index aced40f60..fd909b1ef 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -37,8 +37,9 @@ #define LUMBERJACK_MAP_WIDTH 18 #define LUMBERJACK_BLOCK_ANIMATION_MAX 7 #define LUMBERJACK_ROTATE_ANIMATION_MAX 4 -#define LUMBERJACK_RESPAWN_TIMER 3750 -#define LUMBERJACK_RESPAWN_MIN 1250 +#define LUMBERJACK_RESPAWN_PANIC_MIN 3750 +#define LUMBERJACK_RESPAWN_ATTACK_MIN 500 +#define LUMBERJACK_RESPAWN_VS_MIN 250 #define LUMBERJACK_UPGRADE_TIMER_OFFSET 250 #define LUMBERJACK_SUBMERGE_TIMER 300 #define LUMBERJACK_WORLD_WRAP 295 @@ -69,7 +70,7 @@ void DrawTitle(void); void DrawGame(void); lumberjackVars_t* lumv; -lumberjackTile_t lumberjackCollisionCheckTiles[32] = {}; +lumberjackTile_t lumberjackCollisionCheckTiles[64] = {}; void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) { @@ -110,6 +111,9 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_title_panic_red.wsg", &lumv->subtitle_red, true); loadWsg("lumbers_title_panic_green.wsg", &lumv->subtitle_green, true); loadWsg("lumbers_title_panic_white.wsg", &lumv->subtitle_white, true); + lumv->enemySpawnTime = LUMBERJACK_RESPAWN_PANIC_MIN; + lumv->enemyReceiveSpawnTime = LUMBERJACK_RESPAWN_VS_MIN; + lumv->enemySpawnAmount = 1; } if (main->screen == LUMBERJACK_B) @@ -118,6 +122,9 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_title_attack_red.wsg", &lumv->subtitle_red, true); loadWsg("lumbers_title_attack_green.wsg", &lumv->subtitle_green, true); loadWsg("lumbers_title_attack_white.wsg", &lumv->subtitle_white, true); + lumv->enemySpawnTime = LUMBERJACK_RESPAWN_ATTACK_MIN; + lumv->enemyReceiveSpawnTime = LUMBERJACK_RESPAWN_VS_MIN; + lumv->enemySpawnAmount = 4; } loadWsg("lumbers_game_over.wsg", &lumv->gameoverSprite, true); @@ -334,14 +341,16 @@ bool lumberjackLoadLevel() { fname = "lumberjacks_panic_vs.bin"; } - + + lumv->enemySpawnAmount = 1; } if (lumv->gameType == LUMBERJACK_MODE_ATTACK) { char* attackLevelName[] = { - "lumberjacks_attack_1.bin" + "lumberjacks_attack_1.bin", + "lumberjacks_attack_2.bin", }; fname = attackLevelName[lumv->levelIndex % ARRAY_SIZE(attackLevelName)]; @@ -357,6 +366,7 @@ bool lumberjackLoadLevel() lumv->receiveQueue[i] = 0; } + lumv->enemySpawnAmount = 4; } @@ -468,8 +478,6 @@ void lumberjackSetupLevel(int characterIndex) lumberjackSetupPlayer(lumv->localPlayer, characterIndex); lumberjackSpawnPlayer(lumv->localPlayer, lumv->playerSpawnX, lumv->playerSpawnY, 0); - strcpy(lumv->localPlayer->name, " Dennis"); // If you see this... this name means nothing - int offset = 0; //Load enemies @@ -575,7 +583,15 @@ void lumberjackTitleLoop(int64_t elapsedUs) lumv->btnState = evt.state; } - if (lumv->btnState & PB_A && lumv->gameReady) // And Game Ready! + if (lumv->lumberjackMain->networked) + { + if (lumv->btnState & PB_A && lumv->gameReady && lumv->lumberjackMain->host && lumv->lumberjackMain->conStatus == CON_ESTABLISHED) // And Game Ready! + { + lumberjackPlayGame(); + lumberjackSendGo(); + } + + } else if (lumv->btnState & PB_A && lumv->gameReady) // And Game Ready! { lumberjackPlayGame(); @@ -727,10 +743,11 @@ void baseMode(int64_t elapsedUs) lumv->comboTime = 0; ESP_LOGI(LUM_TAG, "Combo end!"); + + lumv->comboAmount = 0; } - ESP_LOGI(LUM_TAG, "Combo Time: %d", lumv->comboTime); } // Check Controls @@ -803,14 +820,26 @@ void baseMode(int64_t elapsedUs) lumberjackUpdate(elapsedUs); // Check spawn + bool spawnedEnemy = false; + if (false == lumv->hasWon) spawnedEnemy = lumberjackSpawnCheck(elapsedUs); - if (lumv->gameType == LUMBERJACK_MODE_PANIC) - { - if (false == lumv->hasWon) lumberjackSpawnCheck(elapsedUs); - } - if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + if (spawnedEnemy) { - + lumv->enemySpawnAmount --; + if (lumv->enemySpawnAmount <= 0) + { + lumv->spawnSide++; + lumv->spawnSide %= 2; + if (lumv->gameType == LUMBERJACK_MODE_PANIC) + { + lumv->enemySpawnAmount = 1; + } + if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + lumv->enemySpawnAmount = 4; + lumv->spawnTimer = LUMBERJACK_RESPAWN_PANIC_MIN; + } + } } @@ -923,6 +952,11 @@ void baseMode(int64_t elapsedUs) { ESP_LOGI(LUM_TAG, "COMBO!"); ++lumv->comboAmount; + + if (lumv->lumberjackMain->networked) + { + lumv->attackQueue[enemy->type]++; + } } lumv->score += enemy->scoreValue * (lumv->comboAmount + 1); @@ -1244,15 +1278,15 @@ void DrawGame(void) // Debug - /* + char debug[20] = {0}; snprintf(debug, sizeof(debug), "Debug: %d %d %d", lumv->localPlayer->x, lumv->localPlayer->y, lumv->localPlayer->cH); drawText(&lumv->arcade, c000, debug, 16, 16); - // drawRect(lumv->localPlayer->cX, lumv->localPlayer->cY - lumv->yOffset, lumv->localPlayer->cX + - // lumv->localPlayer->cW, lumv->localPlayer->cY - lumv->yOffset + lumv->localPlayer->cH, c050); + drawRect(lumv->localPlayer->cX, lumv->localPlayer->cY - lumv->yOffset, lumv->localPlayer->cX + + lumv->localPlayer->cW, lumv->localPlayer->cY - lumv->yOffset + lumv->localPlayer->cH, c050); if (lumv->localPlayer->jumpPressed) { @@ -1271,7 +1305,19 @@ void DrawGame(void) { drawText(&lumv->arcade, c000, "B", 48, 32); } - */ + + if (lumv->localPlayer->onGround) + { + drawText(&lumv->arcade, c555, "G", 80, 32); + } + else + { + drawText(&lumv->arcade, c000, "G", 80, 32); + } //lumv->spawnTimer + + snprintf(debug, sizeof(debug), "%d", lumv->spawnTimer); + drawText(&lumv->arcade, c555, debug, 122, 32); + } void lumberjackTitleDisplayText(char* string, int locationX, int locationY) @@ -1304,7 +1350,7 @@ void lumberjackScoreDisplay(int score, int locationX) drawText(&lumv->arcade, c555, score_display, locationX, 16); } -void lumberjackSpawnCheck(int64_t elapseUs) +bool lumberjackSpawnCheck(int64_t elapseUs) { float elapse = (elapseUs / 1000); if (lumv->ghost != NULL && lumv->ghost->active == false) @@ -1342,9 +1388,9 @@ void lumberjackSpawnCheck(int64_t elapseUs) } + bool spawnReady = false; if (lumv->spawnTimer >= 0) { - bool spawnReady = true; lumv->spawnTimer -= elapse; @@ -1357,35 +1403,52 @@ void lumberjackSpawnCheck(int64_t elapseUs) if (lumv->enemy[enemyIndex]->ready && lumv->enemy[enemyIndex]->state != LUMBERJACK_DEAD) { - lumv->spawnSide++; - lumv->spawnSide %= 2; - lumv->spawnTimer = LUMBERJACK_RESPAWN_TIMER - (lumv->upgrade * LUMBERJACK_UPGRADE_TIMER_OFFSET); + //lumv->spawnTimer = LUMBERJACK_RESPAWN_TIMER - (lumv->upgrade * LUMBERJACK_UPGRADE_TIMER_OFFSET); + lumv->spawnTimer = lumv->enemySpawnTime; - if (lumv->spawnTimer < LUMBERJACK_RESPAWN_MIN) + /* + if (lumv->spawnTimer < lumv->enemySpawnTime) { - lumv->spawnTimer = LUMBERJACK_RESPAWN_MIN; - } + + if ((lumv->lumberjackMain->networked && lumv->enemyAttackQueue > 0)) + { + lumv->spawnTimer = lumv->enemyReceiveSpawnTime; + + if (lumv->enemyAttackQueue > 0) + { + lumv->enemyAttackQueue--; + } + } + else + { + lumv->spawnTimer = LUMBERJACK_RESPAWN_PANIC_MIN; + ESP_LOGI(LUM_TAG, "Hi!"); + } + }*/ lumberjackRespawnEnemy(lumv->enemy[enemyIndex], lumv->spawnSide); - spawnReady = false; + spawnReady = true; break; } } - if (spawnReady) + if (!spawnReady) { // No one was spawned. lumv->spawnTimer = 500; } } } + + return spawnReady; } -void lumberjackOnReceiveAttack(uint8_t* attack) +void lumberjackOnReceiveAttack(const uint8_t* attack) { if (lumv->gameType == LUMBERJACK_MODE_PANIC) { + ESP_LOGI(LUM_TAG, "Being attacked %ld", sizeof(attack)); lumv->waterDirection = -1; //Even if it is draining lumv->waterSpeed -= 5; @@ -1403,7 +1466,7 @@ void lumberjackOnReceiveAttack(uint8_t* attack) void lumberjackOnReceiveDeath(bool gameover) { - ESP_LOGI(LUM_TAG, "Player died! Haha"); + ESP_LOGI(LUM_TAG, "Player died! Haha %d", (gameover)); if (gameover) { @@ -1421,46 +1484,6 @@ void lumberjackOnReceiveDeath(bool gameover) void lumberjackAttackCheck(int64_t elapseUs) { - float elapse = (elapseUs / 1000); - - if (lumv->spawnTimer >= 0) - { - bool spawnReady = true; - - lumv->spawnTimer -= elapse; - - if (lumv->spawnTimer < 0) - { - for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) - { - if (lumv->enemy[enemyIndex] == NULL) - continue; - - if (lumv->enemy[enemyIndex]->ready && lumv->enemy[enemyIndex]->state != LUMBERJACK_DEAD) - { - lumv->spawnSide++; - lumv->spawnSide %= 2; - - lumv->spawnTimer = LUMBERJACK_RESPAWN_TIMER - (lumv->upgrade * LUMBERJACK_UPGRADE_TIMER_OFFSET); - - if (lumv->spawnTimer < LUMBERJACK_RESPAWN_MIN) - { - lumv->spawnTimer = LUMBERJACK_RESPAWN_MIN; - } - - lumberjackRespawnEnemy(lumv->enemy[enemyIndex], lumv->spawnSide); - spawnReady = false; - break; - } - } - - if (spawnReady) - { - // No one was spawned. - lumv->spawnTimer = 500; - } - } - } } static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs) @@ -1589,7 +1612,16 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs lumberjackTile_t* tileA = lumberjackGetTile(destinationX, destinationY); lumberjackTile_t* tileB = lumberjackGetTile(destinationX + 16, destinationY); - if (lumberjackIsCollisionTile(tileA->type) || lumberjackIsCollisionTile(tileB->type)) + if (tileA == NULL) + { + ESP_LOGI(LUM_TAG, "ERROR GETTING TILE A at %d,%d", destinationX , destinationY); + } + if (tileB == NULL) + { + ESP_LOGI(LUM_TAG, "ERROR GETTING TILE B at %d, %d", destinationX + 16, destinationY); + } + + if ((tileA != NULL && lumberjackIsCollisionTile(tileA->type)) || (tileB != NULL && lumberjackIsCollisionTile(tileB->type))) { destinationY = ((tileA->y + 1) * LUMBERJACK_TILE_SIZE); entity->jumpTimer = 0; @@ -1902,11 +1934,11 @@ static lumberjackTile_t* lumberjackGetTile(int x, int y) if (ty < 0) ty = 0; - if (ty > lumv->currentMapHeight) - ty = lumv->currentMapHeight; + if (ty >= lumv->currentMapHeight) + ty = lumv->currentMapHeight - 1; // int test = -1; - for (int colTileIndex = 0; colTileIndex < 32; colTileIndex++) + for (int colTileIndex = 0; colTileIndex < ARRAY_SIZE(lumberjackCollisionCheckTiles); colTileIndex++) { if ((ty * LUMBERJACK_MAP_WIDTH) + tx >= lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH) { @@ -1926,10 +1958,9 @@ static lumberjackTile_t* lumberjackGetTile(int x, int y) return &lumberjackCollisionCheckTiles[colTileIndex]; } - // test = i; + } - - // ESP_LOGI(LUM_TAG,"NO TILE at %d %d!", test, ty); + return NULL; } @@ -2017,6 +2048,11 @@ void lumberjackUseBlock() { //Increase speed of opponent's water! lumberjackSendAttack(lumv->attackQueue); + + for (int i = 0; i < ARRAY_SIZE(lumv->attackQueue); i++) + { + lumv->attackQueue[i] = 0; + } } } } diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 3f4baa67a..77fe9138a 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -19,7 +19,7 @@ void restartLevel(void); void lumberjackGameDebugLoop(int64_t elapsedUs); void lumberjackDetectBump(lumberjackTile_t* tile); -void lumberjackSpawnCheck(int64_t elapseUs); +bool lumberjackSpawnCheck(int64_t elapseUs); void lumberjackAttackCheck(int64_t elapseUs); void lumberjackScoreDisplay(int score, int locationX); @@ -27,7 +27,7 @@ void lumberjackTitleDisplayText(char* string, int locationX, int locationY); void baseMode(int64_t elapsedUs); void lumberjackSendAttack(uint8_t* number); -void lumberjackOnReceiveAttack(uint8_t* attack); +void lumberjackOnReceiveAttack(const uint8_t* attack); void lumberjackOnReceiveDeath(bool gameover); void lumberjackGameReady(void); void lumberjackPlayGame(void); From 62d3bb1dd837deb8e6986ce3ba4f82c0a01389d7 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Thu, 2 Nov 2023 21:57:38 -0700 Subject: [PATCH 24/54] Refactored tiled collision detection Fixed bug I introduced with last push. Fixed clipping when 16+ enemies appear on screen. Refactored tiled collision detection. Removed double tile array. --- main/modes/lumberjack/lumberjackGame.c | 54 +++++++------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index fd909b1ef..c4a38d925 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -70,7 +70,6 @@ void DrawTitle(void); void DrawGame(void); lumberjackVars_t* lumv; -lumberjackTile_t lumberjackCollisionCheckTiles[64] = {}; void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) { @@ -428,7 +427,7 @@ bool lumberjackLoadLevel() for (int i = 0; i < lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH; i++) { - lumv->tile[i].index = -1; + lumv->tile[i].index = i; lumv->tile[i].x = i % LUMBERJACK_MAP_WIDTH; lumv->tile[i].y = i / LUMBERJACK_MAP_WIDTH; lumv->tile[i].type = (int)buffer[i+12]; @@ -842,17 +841,6 @@ void baseMode(int64_t elapsedUs) } } - - for (int colTileIndex = 0; colTileIndex < ARRAY_SIZE(lumberjackCollisionCheckTiles); colTileIndex++) - { - lumberjackCollisionCheckTiles[colTileIndex].type = -1; - lumberjackCollisionCheckTiles[colTileIndex].x = -1; - lumberjackCollisionCheckTiles[colTileIndex].y = -1; - lumberjackCollisionCheckTiles[colTileIndex].index = -1; - lumberjackCollisionCheckTiles[colTileIndex].offset = 0; - lumberjackCollisionCheckTiles[colTileIndex].offset_time = 0; - } - if (lumv->localPlayer->onGround && !lumv->localPlayer->jumpReady) { if (lumv->localPlayer->jumpPressed == false) @@ -1628,13 +1616,15 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs entity->jumping = false; entity->vy = 0; - if (lumberjackIsCollisionTile(tileA->type)) + if (tileA != NULL && lumberjackIsCollisionTile(tileA->type)) { if (tileA->type != 11 || lumv->itemBlockReady == true) { + ESP_LOGI(LUM_TAG, "BUMP A %d", tileA->index); lumv->tile[tileA->index].offset = 10; lumv->tile[tileA->index].offset_time = 100; + if (tileA->type == 12) { lumv->tile[tileA->index].type = 13; @@ -1647,13 +1637,14 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs { lumberjackUseBlock(); } + } } - if (lumberjackIsCollisionTile(tileB->type)) + if (tileB!= NULL && lumberjackIsCollisionTile(tileB->type)) { - + if (tileB->type != 11 || lumv->itemBlockReady == true) { @@ -1933,35 +1924,16 @@ static lumberjackTile_t* lumberjackGetTile(int x, int y) tx = 0; if (ty < 0) - ty = 0; + { + return NULL; + } if (ty >= lumv->currentMapHeight) - ty = lumv->currentMapHeight - 1; - - // int test = -1; - for (int colTileIndex = 0; colTileIndex < ARRAY_SIZE(lumberjackCollisionCheckTiles); colTileIndex++) { - if ((ty * LUMBERJACK_MAP_WIDTH) + tx >= lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH) - { - //Don't calculate if entity is going off screen - continue; - } - - if (lumberjackCollisionCheckTiles[colTileIndex].type == -1) - { - if (lumberjackCollisionCheckTiles[colTileIndex].index == (ty * LUMBERJACK_MAP_WIDTH) + tx) - return &lumberjackCollisionCheckTiles[colTileIndex]; + return NULL; + } - lumberjackCollisionCheckTiles[colTileIndex].index = (ty * LUMBERJACK_MAP_WIDTH) + tx; - lumberjackCollisionCheckTiles[colTileIndex].x = tx; - lumberjackCollisionCheckTiles[colTileIndex].y = ty; - lumberjackCollisionCheckTiles[colTileIndex].type = lumv->tile[(ty * LUMBERJACK_MAP_WIDTH) + tx].type; + return &lumv->tile[(ty * LUMBERJACK_MAP_WIDTH) + tx]; - return &lumberjackCollisionCheckTiles[colTileIndex]; - } - - } - - return NULL; } static bool lumberjackIsCollisionTile(int index) From 5b2b4a5da332347ffc04c044f24d69fd54b4db5e Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 4 Nov 2023 08:35:45 -0700 Subject: [PATCH 25/54] Multiplayer bug fixes Fixed missing tile in Attack level 2 Added Attack level 3 Added Attack vs Level Fixed multiplayer bug where two host or two clients could lock the game Separated multiplayer modes between Panic and Attack Hid debug information again --- assets/lumbers/lumberjacks_attack_2.bin | Bin 488 -> 488 bytes assets/lumbers/lumberjacks_attack_3.bin | Bin 0 -> 488 bytes assets/lumbers/lumberjacks_attack_vs.bin | Bin 0 -> 920 bytes main/modes/lumberjack/lumberjack.c | 12 ++++++----- main/modes/lumberjack/lumberjackGame.c | 25 ++++++++++++++--------- 5 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 assets/lumbers/lumberjacks_attack_3.bin create mode 100644 assets/lumbers/lumberjacks_attack_vs.bin diff --git a/assets/lumbers/lumberjacks_attack_2.bin b/assets/lumbers/lumberjacks_attack_2.bin index cde071371e7053d32dc3abf11def98afc8d54401..01243485165cb28425080f74ae48dd86758a70a3 100644 GIT binary patch delta 43 ucmaFC{DOIc7b`b60|Udvi4GI{*(Xl5<6;2<1_qGe!~mPgNsJyq+y(&nk_x~8 delta 53 zcmaFC{DOIc7ZU@+L?5q-(`_gAu`vRf4*V=EEDQ_`EG#@cV8+Bi%gIuV9upNrChud^ F0sv~%3>N?Z diff --git a/assets/lumbers/lumberjacks_attack_3.bin b/assets/lumbers/lumberjacks_attack_3.bin new file mode 100644 index 0000000000000000000000000000000000000000..7e1b8fc837e1f33e4d419e0dbd06b75540d5d59e GIT binary patch literal 488 zcmbV{u?~PR2t;Xv+A1*)P7Z#jpD#yk>)?X7^l0F592-#})lMfKzeJeZ6f=vo%4LkA zEC`4f)y0to(@14WO6ek$W{sf+l*jZdU9`%T8i{J>nk*uV0E-CDT>tG~yT_Dm?WGZ2p z&Y{#cnTp2p, esp_now_info->src_addr, (const uint8_t*)data, len, rssi); } static void lumberjackEspNowSendCb(const uint8_t* mac_addr, esp_now_send_status_t status) { - //ESP_LOGI(LUM_TAG, "STATUS %d", status); + ESP_LOGI(LUM_TAG, "STATUS %d", status); p2pSendCb(&lumberjack->p2p, mac_addr, status); } @@ -400,7 +400,8 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV if (label == lumberjackMenuMultiPlayerHost) { - p2pInitialize(&lumberjack->p2p, 0x13, lumberjackConCb, lumberjackMsgRxCb, -70); + p2pInitialize(&lumberjack->p2p,(lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x13 : 0x15), lumberjackConCb, lumberjackMsgRxCb, -70); + p2pSetAsymmetric(&lumberjack->p2p, (lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x14 : 0x16)); p2pStartConnection(&lumberjack->p2p); lumberjack->networked = true; lumberjack->host = true; @@ -408,7 +409,8 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV } else if (label == lumberjackMenuMultiPlayerClient) { - p2pInitialize(&lumberjack->p2p, 0x13, lumberjackConCb, lumberjackMsgRxCb, -70); + p2pInitialize(&lumberjack->p2p, (lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x14 : 0x16), lumberjackConCb, lumberjackMsgRxCb, -70); + p2pSetAsymmetric(&lumberjack->p2p, (lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x13 : 0x15)); p2pStartConnection(&lumberjack->p2p); lumberjack->networked = true; lumberjack->host = false; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index c4a38d925..2c641069c 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -346,18 +346,23 @@ bool lumberjackLoadLevel() if (lumv->gameType == LUMBERJACK_MODE_ATTACK) { - char* attackLevelName[] = + if (!lumv->lumberjackMain->networked) { - "lumberjacks_attack_1.bin", - "lumberjacks_attack_2.bin", - }; + char* attackLevelName[] = + { + "lumberjacks_attack_1.bin", + "lumberjacks_attack_2.bin", + "lumberjacks_attack_3.bin", + }; - fname = attackLevelName[lumv->levelIndex % ARRAY_SIZE(attackLevelName)]; - if (!lumv->lumberjackMain->networked) - { + fname = attackLevelName[lumv->levelIndex % ARRAY_SIZE(attackLevelName)]; lumv->upgrade = (int)(lumv->levelIndex / ARRAY_SIZE(attackLevelName)); } + else + { + fname = "lumberjacks_attack_vs.bin"; + } for (int i = 0; i < 8; i++) { @@ -1119,7 +1124,7 @@ void DrawTitle(void) if (lumv->gameReady) { //Press A To Start - lumberjackTitleDisplayText("Press A to start", (TFT_WIDTH/2) - 70, 180); + lumberjackTitleDisplayText(((lumv->lumberjackMain->host || !lumv->lumberjackMain->networked ) ? "Press A to start": "Host must start"), (TFT_WIDTH/2) - 70, 180); } else if (lumv->lumberjackMain->networked && lumv->lumberjackMain->host) { @@ -1266,7 +1271,7 @@ void DrawGame(void) // Debug - + /* char debug[20] = {0}; snprintf(debug, sizeof(debug), "Debug: %d %d %d", lumv->localPlayer->x, lumv->localPlayer->y, lumv->localPlayer->cH); @@ -1305,7 +1310,7 @@ void DrawGame(void) snprintf(debug, sizeof(debug), "%d", lumv->spawnTimer); drawText(&lumv->arcade, c555, debug, 122, 32); - + */ } void lumberjackTitleDisplayText(char* string, int locationX, int locationY) From 0e621364f011ac1c9adc38fc7fc2f4bc05e55dc4 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 4 Nov 2023 23:16:42 -0700 Subject: [PATCH 26/54] Bonus update Added in visible bonus or combo system Tweaked attack level 2, 3, 4 and vs. Changed invincible sprites so that they're less epileptic. Started enemy type 3 with graphics --- assets/lumbers/lumberjacks_attack_2.bin | Bin 488 -> 398 bytes assets/lumbers/lumberjacks_attack_3.bin | Bin 488 -> 488 bytes assets/lumbers/lumberjacks_attack_4.bin | Bin 0 -> 488 bytes assets/lumbers/lumberjacks_attack_vs.bin | Bin 920 -> 740 bytes assets/lumbers/lumbers_bonus_1.png | Bin 0 -> 144 bytes assets/lumbers/lumbers_bonus_2.png | Bin 0 -> 141 bytes assets/lumbers/lumbers_bonus_3.png | Bin 0 -> 148 bytes assets/lumbers/lumbers_bonus_4.png | Bin 0 -> 149 bytes assets/lumbers/lumbers_bonus_5.png | Bin 0 -> 139 bytes assets/lumbers/lumbers_bonus_6.png | Bin 0 -> 142 bytes assets/lumbers/lumbers_bonus_7.png | Bin 0 -> 143 bytes assets/lumbers/lumbers_bonus_8.png | Bin 0 -> 146 bytes assets/lumbers/lumbers_bonus_9.png | Bin 0 -> 144 bytes assets/lumbers/lumbers_bonus_x.png | Bin 0 -> 144 bytes assets/lumbers/lumbers_cho_18.png | Bin 576 -> 446 bytes assets/lumbers/lumbers_enemy_e1.png | Bin 0 -> 260 bytes assets/lumbers/lumbers_enemy_e2.png | Bin 0 -> 257 bytes assets/lumbers/lumbers_enemy_e3.png | Bin 0 -> 286 bytes assets/lumbers/lumbers_enemy_e4.png | Bin 0 -> 266 bytes assets/lumbers/lumbers_enemy_e5.png | Bin 0 -> 290 bytes assets/lumbers/lumbers_enemy_e6.png | Bin 0 -> 293 bytes assets/lumbers/lumbers_enemy_e7.png | Bin 0 -> 302 bytes assets/lumbers/lumbers_green_22.png | Bin 1070 -> 1136 bytes assets/lumbers/lumbers_red_22.png | Bin 1069 -> 1133 bytes assets/lumbers/secret_swadgeland_22.png | Bin 1056 -> 1102 bytes main/modes/lumberjack/lumberjack.c | 2 +- main/modes/lumberjack/lumberjack.h | 16 ++- main/modes/lumberjack/lumberjackGame.c | 118 +++++++++++++++++++++-- main/modes/lumberjack/lumberjackPlayer.c | 2 +- 29 files changed, 125 insertions(+), 13 deletions(-) create mode 100644 assets/lumbers/lumberjacks_attack_4.bin create mode 100644 assets/lumbers/lumbers_bonus_1.png create mode 100644 assets/lumbers/lumbers_bonus_2.png create mode 100644 assets/lumbers/lumbers_bonus_3.png create mode 100644 assets/lumbers/lumbers_bonus_4.png create mode 100644 assets/lumbers/lumbers_bonus_5.png create mode 100644 assets/lumbers/lumbers_bonus_6.png create mode 100644 assets/lumbers/lumbers_bonus_7.png create mode 100644 assets/lumbers/lumbers_bonus_8.png create mode 100644 assets/lumbers/lumbers_bonus_9.png create mode 100644 assets/lumbers/lumbers_bonus_x.png create mode 100644 assets/lumbers/lumbers_enemy_e1.png create mode 100644 assets/lumbers/lumbers_enemy_e2.png create mode 100644 assets/lumbers/lumbers_enemy_e3.png create mode 100644 assets/lumbers/lumbers_enemy_e4.png create mode 100644 assets/lumbers/lumbers_enemy_e5.png create mode 100644 assets/lumbers/lumbers_enemy_e6.png create mode 100644 assets/lumbers/lumbers_enemy_e7.png diff --git a/assets/lumbers/lumberjacks_attack_2.bin b/assets/lumbers/lumberjacks_attack_2.bin index 01243485165cb28425080f74ae48dd86758a70a3..5b046a9fa7ca02ef1a9cad38878e643e8fafd56f 100644 GIT binary patch delta 48 zcmaFC+{er)I+4+porQ&k0SG2eaGu!DHgUS`#2)U6Q*9>pv$BGO87BHTOy0++1pq3c B47mUR literal 488 zcmb0VU|?Wm00I#PIS@rUU;zS)?X7^l0F592-#})lMfKzeJeZ6f=vo%4LkA zEC`4f)y0to(@14WO6ek$W{sf+l*jZdU9`%p;m^e5&SO7d(3Mc>o delta 132 zcmaFDI)k0jXd7V|U}ECnQ^BZRAn5XN&U8bdsSKX3elF{r5}E)}EiXg> literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_bonus_2.png b/assets/lumbers/lumbers_bonus_2.png new file mode 100644 index 0000000000000000000000000000000000000000..09eae35c8a48f46029567863e9f6c734a59e8721 GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|+&x_!LnNk_ z_8sJ9P~c#`eWbS}D!pmu2gVGghx2kX6=j5t|L6#@BpCasuAdpD^}Xg)_9fSza~v;( ngT4#r-&iZp_?G$U$@$EuYsHq_o}ax2Xe5KDtDnm{r-UW|kDx9n literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_bonus_3.png b/assets/lumbers/lumbers_bonus_3.png new file mode 100644 index 0000000000000000000000000000000000000000..f2d662f0a952caec613ce068f81b2aa315509ece GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|{5)M8LnNm5 z_8;UtV8FxdZ)|B?dMiWi`@~5WnytT*4W2s-O|YH3{^DkJLDp?s8eZ%^>dO$cQ`Ld> vZd+pA?#|054X@o#beN~CpAbD+YX{@|2eQfG6OLK}O=j?P^>bP0l+XkKSr9V9 literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_bonus_4.png b/assets/lumbers/lumbers_bonus_4.png new file mode 100644 index 0000000000000000000000000000000000000000..14dec9b3253359d6d3fe4a23011d485ed0ee2d87 GIT binary patch literal 149 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|{5@S9LnNlQ z_8sJHFyJ{-vqHLcW`cTJRvH)oDl=W7AJe-R&zaFFb+J8m5ksPGNoVm+jq_@%cHGkT v92~1ZYBH1@?o<4|^qOL~H~UAm|Cf3Ho)^9y)il=tXf%VTtDnm{r-UW|4RA2J literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_bonus_5.png b/assets/lumbers/lumbers_bonus_5.png new file mode 100644 index 0000000000000000000000000000000000000000..68d7e9274fe360e53a2fd20b7a5b4e898dbeaeb3 GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|Ts>VJLnNlw z_8k;FpultZ$?iOnv{zdymVJ1%KsEPXmk#4iUkS+>1)fPe4qEVretM(h n#s&m#Vl5nPX*zv}mDm}+{S%$v8#`ew&`<_XS3j3^P6e4%sN1(gT&esc3ayRg5F rx#9EW{meJpeFQi5*O>qKz^)b-DKU4|ym{3?QyDy6{an^LB{Ts5pXM=U literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_cho_18.png b/assets/lumbers/lumbers_cho_18.png index 70d788b3f479da3dbd90426c98751a360d03de53..9b218d84e460ae58d3b77012d827021db534fe0d 100644 GIT binary patch delta 407 zcmV;I0ciff1ik~1F@JbTL_t(oh0T}Eal{}DMjshBk!xDOWjM#Q05w4ixuy(L6FC?; zM(dwtl8pH->%~GldXf-pD6#|qUMCB{`&Z07p@@CPY?UJc;E4v{rD^v+XpjdTc?w~7 zL-MiuZi8$4Memo-JOdpNF!B&^r;-0wnw-=^KLn;}$;nj>{C|~fsfB(B$T{Fh8Gicv zsLGGJ;V9SZK1KF+0z+%$qLk|s(8m4sSQrZl$-R)cpFnful4DowP04XkL`ap#uWO5;8nSE|Fdlamk#%*Gh5m*UdCEG6VEnm#RIgjjPCgT)V4Uw{D4iETwcm z0eudLBGzozTYtM`L(l*u{I31|1oXnu$@p-ls~e*&o=$3MmqdRAbXUyO(=E>PslznZ zE)#V(_;orgx}CsqZBi@x5dfFe)U##UHTvt1fbRd1rSI4NUvE5W+NJVd-Hdb>X!S?n zu>a*IbCG4a@rc#NPX_R+^ZFy8)%x$Z)&6z@-`?7u#t?|18%F>D002ovPDHLkV1fla B%VPil delta 538 zcmV+#0_FX_1Hc53F@O3=L_t(oh0T^RkJB(1h99F291=*C%Fr%I8BlL_2P7n>j4TZO z3(3q6LCo=ZYb6#IhE7Oq^<0FwNDN#DPP*X`3^$m;{=_+?NsAEiyCnJY+1C5mpKXQ6 zZ2-`A3c&d41c0m_15jsI(evls8vu5*?~V>VfBRSg%y##qxPK`X0C&0?{|}AiMVwo` za{z_WQKFDo=XDfs=Cvpyw9ad9JrEz9fRdN&{2YLMopsLX-^vs=`qp-;ASD8N^A*^? z2L81!rq_uPkX1R~P5}6Ldf7>$Ij54>j6XdaD}a-kucE9TM{8_w0wZxQb>8P(q*d&c zO1H*8IPCzY7k@Vj{@h1~Cva=8KghYvu`d0$b-}rb^CT{M^7#ya>)iuSLgzpN1Qc%5 z>Rg=m5h<+d{NFkzun5G4Cm?5ltO3z{J5jK|D*Bu+DqmgID}V6oPjPjmLqPU{eVTl` z2f*dSA4gTm{L9u8d~_N{TD0aTK%l8WWV!NAR!beNjekn{$+L}HgAP5Fu888@QscFO1*n zl&hlpx1rA8ynGi;wtZbV0NuD5Y4cwBcF$VJ8Js|G6-eESZq<3S?P2+;RY5O-BibI8 cpBjN*H51^$FXam$q5uE@07*qoM6N<$g0*P`l>h($ diff --git a/assets/lumbers/lumbers_enemy_e1.png b/assets/lumbers/lumbers_enemy_e1.png new file mode 100644 index 0000000000000000000000000000000000000000..afa1e26be66964f6650fd4d28c7ea408fe3babc3 GIT binary patch literal 260 zcmV+f0sH=mP)Px#zDYzuR5*>blsyi@Fbqat5E3`w1T38x93~FKmNIdl=02U8Y)IUNr3`K=C2AR} z^ji{J{&|Y6n8))4zqT_t?4glwr%+mtU(fuvZ zV)r5{IYAbKGs{N)mRVMg}q);sOOk!r%CrZ=s#wft(775Z`&2b_- z5v2~ZY%F6nE}BJuJ)-+%Gypx4{YTAN{liD?Tcc-`JTB!|Bl-cxNi^;tmq8x@0000< KMNUMnLSTXgglP)^ literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_enemy_e2.png b/assets/lumbers/lumbers_enemy_e2.png new file mode 100644 index 0000000000000000000000000000000000000000..f17ee59155cdd24aeddceda9b7a4f61c7b5936f8 GIT binary patch literal 257 zcmV+c0sj7pP)Px#yGcYrR5*>zlRF9mF%X8o$bzug*?0yUi^+ZL5-abM+{Z>Yomkm<1{DNZi>yi( zAFyP_zsfwA`Iw);ze&v(O8~Z;Ro!L4Ygc8uljbE7PR_@?f2~*_t^kb2D%to@Pyf800000NkvXX Hu0mjfzj$hD literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_enemy_e3.png b/assets/lumbers/lumbers_enemy_e3.png new file mode 100644 index 0000000000000000000000000000000000000000..69773412ae7a82028694b848815d6a0b0b07ef40 GIT binary patch literal 286 zcmV+(0pb3MP)Px#*hxe|R5*>blrav1KoCXWDv6by2e2TaG;y~ukpplGyT!`;z)7^%!U)E~hR!o+ zM@+C-FkvGWWck%jF*7fJW>##rI{@yNQ$-IgCZzxv^-2CEA*D1Vne10VPx##7RU!R5*>zlQ9ayFcgNrNTE>NT=WVq4#|Do5+|=C2_C~M=%CFePHvt-1wrbN zDzsFEl8XP5{N(Z8$NLHVo5XZB2VlQj7i}6$(whM2MI(|@29jL1>!3VQiIQ&x7W?tt zpny(@oCZMa=3N;TCfhu(_@{oiBZCQ-GS#~8Fg5J}aPKO8ZFkaFY&@cI))N2+3E54@8CJr7{)gMPq~GB_k@)1L27-G$BAA Q)&Kwi07*qoM6N<$g5KF^hX4Qo literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_enemy_e5.png b/assets/lumbers/lumbers_enemy_e5.png new file mode 100644 index 0000000000000000000000000000000000000000..47a2978f69307c0327a227db3f90738eff0781bd GIT binary patch literal 290 zcmV+-0p0$IP)Px#+(|@1R5*>blrajzFcd&vwBY3C;^rVY3MPYK571kJTeL+NGp#`adK;kN-);e6a-JemUmUVBEWo=w{`bH=>JuG@N%${!Fnzu{e00bk?HapoSKmJT^uP#oFL=lVz69A@x o4^;n8vtcd(_Ggo)kE>gw4}TOtrHB;Ch5!Hn07*qoM6N<$f^pV*SpWb4 literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_enemy_e6.png b/assets/lumbers/lumbers_enemy_e6.png new file mode 100644 index 0000000000000000000000000000000000000000..574c1a0a0d8916ba8f23454b3122e1fabfaf9d7c GIT binary patch literal 293 zcmV+=0owkFP)Px#-$_J4R5*>blrajzFcgNrsOY4V2XJ!{6jKq@T?daLibpah=>ZfR8o^O;aPt68 zicp89g~Tc->9^&*AM){diNMfq^#Pa;lk@H@VshvV#sXj;ZUH!54gi$$!v7#rlV1G> zz`5Fp0i@PeaDBf5uo%q&m^8}*AUr+&8dY2qB57Q;Ws+g~+d#(vvvx&zH4;)v+eAw{ zAvIqKlD@wgy;VLKEZG2{l<6;()h}R1hD{XZ23^n0Os)JHWixV3RzYCZ70J!%tXvA* rqhIm9N8Q>(036NR`IYp4@@Dh`zFk43+E@J&00000NkvXXu0mjfq(F7= literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_enemy_e7.png b/assets/lumbers/lumbers_enemy_e7.png new file mode 100644 index 0000000000000000000000000000000000000000..cea7e28c89da20fac3734042505fa926a2514c2f GIT binary patch literal 302 zcmV+}0nz@6P)Px#=t)FDR5*>bltD@ZF%*WsXwg->>H*x%Mo^lRLhD`^9z!yCq?wb<0jA(05nK+; zqB{@Zsv?Ywc@Z*pgi89YlDr?@M|g=s$gUOu+^_omwpASmxL$4)z)MvF(Cl6TI6D;n z4=R}4PCo!>FJ>Kp_C5+e@81Ds+D$q!Pmjqd;+vWZG+ zq_oztiPv#Ld;Y}q^>lai>tw{hQUFkvQnzJPPj6I6$04~f{lbZe)naBt;zUNFbKzVR z2>V<*+Y$2<&e5?XpQD@0PX+KMZ|7LT|CG$=8*KSMs>97BJpcdz07*qoM6N<$g6ige A?f?J) literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_green_22.png b/assets/lumbers/lumbers_green_22.png index 98f4ffe16c1aaf62d05e4f568be53f294fbb0ff9..f2e7afea9fac044730c0986fe41118b2839c7bbf 100644 GIT binary patch delta 208 zcmV;>05AWp2=EB7sRMtqNklk3%Q0!ZC9@4O2)#+TbN=1!-Um4~#KH zms>0e-j@&FYXw$Hk%2$Y+gtn*5I-9H*>iq2E@zku^1JoxCE*R+rd`x)588YH0000< KMNUMnLSTZ`hFW3( delta 142 zcmV;90CE5D2(AdQsRMs-NklYm?flPp}v}GNr4)t%quf#y#oG51zn=62sNLrXNV*ms-QVM3RQ2=7K w<@0Ztf_@AxDGuy_=YwH=8ti)&etiVoA0_iCNu3QY00000Nks-uM6N<$f@beKHvj+t diff --git a/assets/lumbers/lumbers_red_22.png b/assets/lumbers/lumbers_red_22.png index 91e8d857127be06bcfdfba6e11efa81e77e9b22e..5ab34676e05b185f1fd60fdbe9150b95f90cddc7 100644 GIT binary patch delta 205 zcmV;;05bor2<-^4sRMtnNkl&L&-=C5#R#h7Cm8*#-lm_0000)X-1&Dych$p2p, esp_now_info->src_addr, (const uint8_t*)data, len, rssi); } diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index fb61d7853..3713142f9 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -70,6 +70,15 @@ typedef struct } lumberjackAxeBlock_t; +typedef struct +{ + int x; + int y; + int time; + bool active; + int bonusAmount; +} lumberjackBonus_t; + typedef struct { bool loaded; @@ -134,7 +143,9 @@ typedef struct wsg_t floorTiles[20]; wsg_t animationTiles[20]; wsg_t minicharacters[4]; - + + lumberjackBonus_t* bonusDisplay[16]; + uint8_t activeBonusIndex; wsg_t title; wsg_t subtitle_red; @@ -150,8 +161,9 @@ typedef struct wsg_t unknownBlockSprite[7]; wsg_t unusedBlockSprite[7]; - wsg_t enemySprites[23]; + wsg_t enemySprites[37]; wsg_t playerSprites[18]; + wsg_t bonusSprites[10]; wsg_t ui[6]; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 2c641069c..6fb9f5f92 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -36,7 +36,7 @@ #define LUMBERJACK_MAP_WIDTH 18 #define LUMBERJACK_BLOCK_ANIMATION_MAX 7 -#define LUMBERJACK_ROTATE_ANIMATION_MAX 4 +#define LUMBERJACK_ROTATE_ANIMATION_MAX 4 #define LUMBERJACK_RESPAWN_PANIC_MIN 3750 #define LUMBERJACK_RESPAWN_ATTACK_MIN 500 #define LUMBERJACK_RESPAWN_VS_MIN 250 @@ -50,6 +50,8 @@ #define LUMBERJACK_GHOST_BOX 28 #define LUMBERJACK_GHOST_ANIMATION 2500 +#define LUMBERJACK_BONUS_DISPLAYDURATI 4000 + #define LUMBERJACK_WATER_FAST_DRAIN 6 #define LUMBERJACK_WATER_SLOW_DRAIN 3 #define LUMBERJACK_WATER_INCREASE 10 @@ -282,6 +284,20 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_enemy_c7.wsg", &lumv->enemySprites[20], true); loadWsg("lumbers_enemy_d1.wsg", &lumv->enemySprites[21], true); loadWsg("lumbers_enemy_d2.wsg", &lumv->enemySprites[22], true); + loadWsg("lumbers_enemy_e1.wsg", &lumv->enemySprites[23], true); + loadWsg("lumbers_enemy_e2.wsg", &lumv->enemySprites[24], true); + loadWsg("lumbers_enemy_e3.wsg", &lumv->enemySprites[25], true); + loadWsg("lumbers_enemy_e4.wsg", &lumv->enemySprites[26], true); + loadWsg("lumbers_enemy_e5.wsg", &lumv->enemySprites[27], true); + loadWsg("lumbers_enemy_e6.wsg", &lumv->enemySprites[28], true); + loadWsg("lumbers_enemy_e7.wsg", &lumv->enemySprites[29], true); + loadWsg("lumbers_enemy_f1.wsg", &lumv->enemySprites[30], true); + loadWsg("lumbers_enemy_f2.wsg", &lumv->enemySprites[31], true); + loadWsg("lumbers_enemy_f3.wsg", &lumv->enemySprites[32], true); + loadWsg("lumbers_enemy_f4.wsg", &lumv->enemySprites[33], true); + loadWsg("lumbers_enemy_f5.wsg", &lumv->enemySprites[34], true); + loadWsg("lumbers_enemy_f6.wsg", &lumv->enemySprites[35], true); + loadWsg("lumbers_enemy_f7.wsg", &lumv->enemySprites[36], true); loadWsg("lumbers_green_ax_block1.wsg", &lumv->greenBlockSprite[0], true); loadWsg("lumbers_green_ax_block2.wsg", &lumv->greenBlockSprite[1], true); @@ -307,9 +323,28 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_normal_ax_block6.wsg", &lumv->unusedBlockSprite[5], true); loadWsg("lumbers_normal_ax_block7.wsg", &lumv->unusedBlockSprite[6], true); + loadWsg("lumbers_bonus_x.wsg", &lumv->bonusSprites[0], true); + loadWsg("lumbers_bonus_1.wsg", &lumv->bonusSprites[1], true); + loadWsg("lumbers_bonus_2.wsg", &lumv->bonusSprites[2], true); + loadWsg("lumbers_bonus_3.wsg", &lumv->bonusSprites[3], true); + loadWsg("lumbers_bonus_4.wsg", &lumv->bonusSprites[4], true); + loadWsg("lumbers_bonus_5.wsg", &lumv->bonusSprites[5], true); + loadWsg("lumbers_bonus_6.wsg", &lumv->bonusSprites[6], true); + loadWsg("lumbers_bonus_7.wsg", &lumv->bonusSprites[7], true); + loadWsg("lumbers_bonus_8.wsg", &lumv->bonusSprites[8], true); + loadWsg("lumbers_bonus_9.wsg", &lumv->bonusSprites[9], true); + + + loadWsg("lumbers_item_ui.wsg", &lumv->ui[0], true); loadWsg("lumbers_alert.wsg", &lumv->alertSprite, true); + for (int i = 0; i < ARRAY_SIZE(lumv->bonusDisplay); i++) + { + lumv->bonusDisplay[i] = calloc(1, sizeof(lumberjackBonus_t)); + } + lumv->activeBonusIndex = 0; + } bool lumberjackLoadLevel() @@ -353,9 +388,9 @@ bool lumberjackLoadLevel() "lumberjacks_attack_1.bin", "lumberjacks_attack_2.bin", "lumberjacks_attack_3.bin", + "lumberjacks_attack_4.bin", }; - fname = attackLevelName[lumv->levelIndex % ARRAY_SIZE(attackLevelName)]; lumv->upgrade = (int)(lumv->levelIndex / ARRAY_SIZE(attackLevelName)); } @@ -449,7 +484,7 @@ bool lumberjackLoadLevel() lumv->playerSpawnY = (int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8); //lumv->yOffset = lumv->playerSpawnY - LUMBERJACK_SCREEN_Y_OFFSET; - ESP_LOGI(LUM_TAG, "%d %d", lumv->playerSpawnY, buffer[offset]); + ESP_LOGI(LUM_TAG, "SPAWN %d %d", lumv->playerSpawnY, buffer[offset]); free(buffer); @@ -745,9 +780,7 @@ void baseMode(int64_t elapsedUs) if (lumv->comboTime < 0) { lumv->comboTime = 0; - ESP_LOGI(LUM_TAG, "Combo end!"); - - + ESP_LOGI(LUM_TAG, "Combo end!"); lumv->comboAmount = 0; } @@ -945,6 +978,16 @@ void baseMode(int64_t elapsedUs) { ESP_LOGI(LUM_TAG, "COMBO!"); ++lumv->comboAmount; + + lumv->activeBonusIndex++; + lumv->activeBonusIndex %= ARRAY_SIZE(lumv->bonusDisplay); + lumberjackBonus_t* currentBonus = lumv->bonusDisplay[lumv->activeBonusIndex]; + + currentBonus->x = enemy->x; + currentBonus->y = enemy->y; + currentBonus->active = true; + currentBonus->time = 0; + currentBonus->bonusAmount = lumv->comboAmount + 1; if (lumv->lumberjackMain->networked) { @@ -967,8 +1010,21 @@ void baseMode(int64_t elapsedUs) if (lumv->enemyKillCount >= lumv->totalEnemyCount) { //And game mode == blah - //lumv->gameState = LUMBERJACK_GAMESTATE_WINNING; - lumv->hasWon = true; + if (lumv->lumberjackMain->networked) + { + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + { + if (lumv->enemy[i] == NULL) continue; + + lumv->enemy[i]->state = LUMBERJACK_RUN; + lumberjackResetEnemy(lumv->enemy[i]); + lumberjackUpdateEnemy(lumv->enemy[i], lumv->enemy[i]->type+1); + } + } + else + { + lumv->hasWon = true; + } } if (lumv->localPlayer->vx != 0) @@ -1069,6 +1125,20 @@ void baseMode(int64_t elapsedUs) // if (lumv->yOffset > (lumv->currentMapHeight * LUMBERJACK_TILE_SIZE) - TFT_HEIGHT) lumv->yOffset = (lumv->currentMapHeight * LUMBERJACK_TILE_SIZE) - TFT_HEIGHT; + + + for (int i = 0; i < ARRAY_SIZE(lumv->bonusDisplay); i++) + { + lumberjackBonus_t* currentBonus = lumv->bonusDisplay[i]; + if (false == currentBonus->active ) continue; + + currentBonus->time += elapsedUs / 1000; + if (currentBonus->time > LUMBERJACK_BONUS_DISPLAYDURATI) + { + currentBonus->active = false; + } + } + } void lumberjackOnLocalPlayerDeath(void) @@ -1269,6 +1339,30 @@ void DrawGame(void) drawText(&lumv->arcade, c555, level_display, (TFT_WIDTH/2) - 36, TFT_HEIGHT - 20); } + for (int i = 0; i < ARRAY_SIZE(lumv->bonusDisplay); i++) + { + lumberjackBonus_t* currentBonus = lumv->bonusDisplay[i]; + if (false == currentBonus->active ) continue; + + float offsetTime = (((float)currentBonus->time)/LUMBERJACK_BONUS_DISPLAYDURATI) + .9f; + + if (offsetTime > 1) offsetTime = 1; + + drawWsgSimple(&lumv->bonusSprites[0], currentBonus->x, currentBonus->y - lumv->yOffset - (20 - (20 * offsetTime))); + if (currentBonus->bonusAmount < 10) + { + drawWsgSimple(&lumv->bonusSprites[currentBonus->bonusAmount], currentBonus->x+8, currentBonus->y - lumv->yOffset - (20 - (20 * offsetTime))); + } + + if (i == 1) + { + ESP_LOGI(LUM_TAG, "COMBO 1 %d %f", currentBonus->time , offsetTime); + } + //currentBonus->time += ; + //currentBonus->bonusAmount = lumv->comboAmount; + } + + // Debug /* @@ -1625,7 +1719,7 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs { if (tileA->type != 11 || lumv->itemBlockReady == true) { - ESP_LOGI(LUM_TAG, "BUMP A %d", tileA->index); + //ESP_LOGI(LUM_TAG, "BUMP A %d", tileA->index); lumv->tile[tileA->index].offset = 10; lumv->tile[tileA->index].offset_time = 100; @@ -2051,6 +2145,12 @@ void lumberjackExitGameMode(void) freeWsg(&lumv->gamewinSprite); + // Free the bonus + for (int i = 0; i < ARRAY_SIZE(lumv->bonusDisplay); i++) + { + freeWsg(&lumv->bonusDisplay[i]); + } + // Free the enemies for (int i = 0; i < ARRAY_SIZE(lumv->enemySprites); i++) { diff --git a/main/modes/lumberjack/lumberjackPlayer.c b/main/modes/lumberjack/lumberjackPlayer.c index 45318200c..186c61fa4 100644 --- a/main/modes/lumberjack/lumberjackPlayer.c +++ b/main/modes/lumberjack/lumberjackPlayer.c @@ -6,7 +6,7 @@ #include #define LUMBERJACK_DEFAULT_ANIMATION_SPEED 150000 -#define LUMBERJACK_INVINCIBLE_ANIMATION_SPEED 25000 +#define LUMBERJACK_INVINCIBLE_ANIMATION_SPEED 100000 #define LUMBERJACK_HERO_WIDTH 24 #define LUMBERJACK_HERO_HEIGHT 31 #define LUMBERJACK_HERO_DUCK_HEIGHT 31 From d34261cdd06763542af82ec918ae030a3614da4f Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 5 Nov 2023 15:46:09 -0800 Subject: [PATCH 27/54] Items Added Attack mode now has 3 items to use Added item graphics Changed invincibility so you can move with it enabled Player defaults to idle Removed invincible animation --- assets/lumbers/lumberjacks_attack_1.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_attack_2.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_attack_3.bin | Bin 488 -> 488 bytes assets/lumbers/lumbers_items_grapes1.png | Bin 0 -> 221 bytes assets/lumbers/lumbers_items_grapes2.png | Bin 0 -> 228 bytes assets/lumbers/lumbers_items_grapes3.png | Bin 0 -> 211 bytes assets/lumbers/lumbers_items_grapes4.png | Bin 0 -> 155 bytes assets/lumbers/lumbers_items_grapes5.png | Bin 0 -> 186 bytes assets/lumbers/lumbers_items_grapes6.png | Bin 0 -> 211 bytes assets/lumbers/lumbers_items_orange1.png | Bin 0 -> 298 bytes assets/lumbers/lumbers_items_orange2.png | Bin 0 -> 253 bytes assets/lumbers/lumbers_items_orange3.png | Bin 0 -> 247 bytes assets/lumbers/lumbers_items_orange4.png | Bin 0 -> 231 bytes assets/lumbers/lumbers_items_orange5.png | Bin 0 -> 237 bytes assets/lumbers/lumbers_items_orange6.png | Bin 0 -> 260 bytes assets/lumbers/lumbers_items_pear1.png | Bin 0 -> 1038 bytes assets/lumbers/lumbers_items_pear2.png | Bin 0 -> 1030 bytes assets/lumbers/lumbers_items_pear3.png | Bin 0 -> 1029 bytes assets/lumbers/lumbers_items_pear4.png | Bin 0 -> 1029 bytes assets/lumbers/lumbers_items_pear5.png | Bin 0 -> 1026 bytes assets/lumbers/lumbers_items_pear6.png | Bin 0 -> 1037 bytes main/modes/lumberjack/lumberjack.h | 7 + main/modes/lumberjack/lumberjackGame.c | 303 ++++++++++++++++++++++- main/modes/lumberjack/lumberjackGame.h | 1 + main/modes/lumberjack/lumberjackPlayer.c | 11 +- main/modes/lumberjack/lumberjack_types.h | 1 - 26 files changed, 305 insertions(+), 18 deletions(-) create mode 100644 assets/lumbers/lumbers_items_grapes1.png create mode 100644 assets/lumbers/lumbers_items_grapes2.png create mode 100644 assets/lumbers/lumbers_items_grapes3.png create mode 100644 assets/lumbers/lumbers_items_grapes4.png create mode 100644 assets/lumbers/lumbers_items_grapes5.png create mode 100644 assets/lumbers/lumbers_items_grapes6.png create mode 100644 assets/lumbers/lumbers_items_orange1.png create mode 100644 assets/lumbers/lumbers_items_orange2.png create mode 100644 assets/lumbers/lumbers_items_orange3.png create mode 100644 assets/lumbers/lumbers_items_orange4.png create mode 100644 assets/lumbers/lumbers_items_orange5.png create mode 100644 assets/lumbers/lumbers_items_orange6.png create mode 100644 assets/lumbers/lumbers_items_pear1.png create mode 100644 assets/lumbers/lumbers_items_pear2.png create mode 100644 assets/lumbers/lumbers_items_pear3.png create mode 100644 assets/lumbers/lumbers_items_pear4.png create mode 100644 assets/lumbers/lumbers_items_pear5.png create mode 100644 assets/lumbers/lumbers_items_pear6.png diff --git a/assets/lumbers/lumberjacks_attack_1.bin b/assets/lumbers/lumberjacks_attack_1.bin index 05049ec3000996ea8e378a2cbafe63e622806757..190188c3f22e59334e668f4b1f0bbf52c3dfa804 100644 GIT binary patch delta 36 kcmeBU?qik^6<}asWB>vY200MLz`zYACJNeY46$Ma06qT$#{d8T delta 27 hcmeBU?qlW=6<}asWB>vY2Dyoa&Jzt-H-=a-0suKX1kwNi diff --git a/assets/lumbers/lumberjacks_attack_2.bin b/assets/lumbers/lumberjacks_attack_2.bin index 5b046a9fa7ca02ef1a9cad38878e643e8fafd56f..a504d464d4bd288beae4df1dc45da408f96848b3 100644 GIT binary patch delta 19 acmeBU?qi-H!o}jW&&VApcDx30A(gVun^+m2C+aIc)$#9 cuu^`Y3b0nFNfQGtCrdGUOjHn=ypK@}0BlDL!2kdN delta 60 wcmaFC{DOIc6F&T5#em0U`svJL##0{3Wi%?qFs06r+Uh^4aeHXz zod5f3RW4TWKHh5bA;4afiJ_sCF)Kj2mdKI;Vst00Pif>i_@% literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_grapes2.png b/assets/lumbers/lumbers_items_grapes2.png new file mode 100644 index 0000000000000000000000000000000000000000..5ce9879b07ca8a58b8ae48912d9677da72ee78e4 GIT binary patch literal 228 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|=6Sj}hFJ6_ zCrD%*=x}{wFIJh8!~+68H+*vUK0TeV$;r}i10(?{Uoi7lY zfBFKC$B(c7?GB&(541wUWLMIyR>n={3(g(qDqw%~=ROa=*qq~t^eH&LWnf~6 XlXi%?GvSU3(4`EXu6{1-oD!M7sxm@7D^m-~T9!rQ6KdA9Q#8yf&YiBEmwWrmsu_W286 z*0Xh#7gTblOBf_vYzfu%(-+__ko@rf|CRqd|Ap%eLCWu>TXddvWr->HWq!Ds^*QIR zhA9RIR>|c{{F(nt{#nhOX%G32T;BiDOPKk?vc`jq4860|9z4id_6+DS22WQ%mvv4F FO#t{H}0GAqym22WQ%mvv4FO#t#; BGSL74 literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_grapes5.png b/assets/lumbers/lumbers_items_grapes5.png new file mode 100644 index 0000000000000000000000000000000000000000..b6c931d140f0de86a25329f231e5d1897dfeafb9 GIT binary patch literal 186 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|N<3X0Lo9le z6C^SYbU6R9-}q`~!OS~Vr^Wpa-?+ix$2{TSEp7kKz&6Hz#s&s|%%jr3%xBy_y`YWp z3`0{^=O-q+hSLrI|MNS^eE9#MzU@Ef{tY`j8o1XjxM;zk`Lbb&K|)G`L!q5tgS`N! i#e9hdb6y@k1_qflrB7RyNS_AU&*16m=d#Wzp$P!a-9zR8 literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_grapes6.png b/assets/lumbers/lumbers_items_grapes6.png new file mode 100644 index 0000000000000000000000000000000000000000..d8257ee3ea8684a445f14d5bb5cd7e61e0f77fce GIT binary patch literal 211 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|dOcknLo9le z6C^SYbhy5;7pu%k;sF7j8$P*vpPoJd1OaQe{j`^och(iwTfTPhClUSm0zdM%oO@x< zeB|Yc9G(VU9*F|YW6R{0i+8Zz;Q8_Yzrqp5f~r^bZT~sPx#LlC2JcP#A_EoOln;U^8j4T8t2w!Rw$}%oeKGp&N5fB84kBCYqa$ zdw_re!Nbov!}+!I^E}^se&EkC6!UqHJpc?;3y0X@5Iap-e*wVh{$hDvY9%Uxv7cSo z&L=v5u~9Lvi)|my-4!JO!rh zV%jd52r+F}bD9o8vtyYii2{-+V7#(w>&+t+oj*`lB~hSHAd6&Zys}!|q5TSZ>RHw0 w$&uyGQ~%3$K4a=x72J$0!zuy%@R9zmH#tmF3&m1XbN~PV07*qoM6N<$f;26B3jhEB literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_orange2.png b/assets/lumbers/lumbers_items_orange2.png new file mode 100644 index 0000000000000000000000000000000000000000..f47aab1aea8c6506183e5da0674be17257ebfc57 GIT binary patch literal 253 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|wtKobhFJ6_ zCoB*!cr@|1e~*<~&9d$HKBZ>tecGKT!If|@{lG14|Bs%+tp7fX&H8uzIaAVMhUHZ; zY=8b=eR}Y~tC`#nZFipe@cR=Z+qO-z5>*>o8Dl=be>*u)Medie!HN8oAN@HT?;L81 zBoDLRU^ti2lHHJ1S69LwR%#L3aF$zTCqv$Zb<7~pyksjo2!GW3vA5QUdG$KxJK8(; wG@NDax$xr9huweNI&8XNz1nYn7uHFIs$yzra*Hxw}bIP4zPt6wW=R(V;UdkWC;44$rjF6*2UngANHTTB1| literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_orange4.png b/assets/lumbers/lumbers_items_orange4.png new file mode 100644 index 0000000000000000000000000000000000000000..08fa29841f652a8aa9be358a183d0c0b74d13cac GIT binary patch literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|7J9lkhFJ6_ zCoB*!5L)@pUeDI&NJie?r>8GeofcoM!fiO~dR(Pfi>(EZK~(ye`P(miv1eXo{-7a1 z;=vbdL$*Kv>npXH4^KYLvtM66Awm0gW2o&q2cT#*`{DO*CqHD`zsu%AY|C|qw)@lh z4`hbLvd=kpB=f-M#nuH`N~aid)+wH3@XY346w`8@^?d(3g%_fGF8;V6e{kacj#%5H coSjJw3=39ST(doS9ONYiPgg&ebxsLQ0L5utm;e9( literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_orange5.png b/assets/lumbers/lumbers_items_orange5.png new file mode 100644 index 0000000000000000000000000000000000000000..a4e20d87bfc1f6fe9f559bce9bf10142e5eff9b7 GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|mV3H5hFJ6_ zCoB*!5L)=m-tMbUi^=wTpHdB?(p!QV6`3Wj#Z{gv_-$bPlg$7KYTntOJ_UVgxIA#;iIhW5rDy*WSs zyx^1RYhe(J5i;nVbWN^;_rR;B`?uAFmr5>YJTYtH-iEW*6_*(m{~H@T=sec`Z${H6 hX~VApb0%o8G34?YG`{@tXBW`P44$rjF6*2UngF9AVq^dS literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_orange6.png b/assets/lumbers/lumbers_items_orange6.png new file mode 100644 index 0000000000000000000000000000000000000000..8f74425d881220a9961a9185998dea7a962c06a0 GIT binary patch literal 260 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|_IbKEhFJ6_ zCoB*!cr@|1e~*<~&9d$HKBXE&rMKisd}Iq?{$n1M{zZO1cfn8IdjMS3tl+$H~;^?z1-l>J-eBW4^O6orA+PZcQrQx!Nc(B>|NZE z25+WcOih@2u~ou}<$wtT?}40YTfQlrV~8;WDr8=*7;%|#^*ZJ`x|weq7YRO7nxmKS z^^9vF>n^sE22&~dU(PwlmPOVnud?eB7COqn5PrgeagFA`y+EHZc)I$ztaD0e0svB& BXLbMp literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_pear1.png b/assets/lumbers/lumbers_items_pear1.png new file mode 100644 index 0000000000000000000000000000000000000000..f0a1b9104a10608b366dec78ceec9a9333950126 GIT binary patch literal 1038 zcmds#y=&BQ494Rd>gj3epduDJI4I&2#lb->SK5ItMK~Qj15aK7lKf}P?myqPi^E~-o@Aqcft(`3qX?JHk1KzRv zZCJzqp8Z>gJgY7YW~OB2)voU%tFQIv=BKkFGCk8WHB%~!$nXry&Yfs79)%TB@cBNGXxxDVCxsBwzy#7Q=K)?Wynxi_i$EwPfz$7Ovq^EGU|X zS(t`Nk)l^U)Iv2>;K*o*hggV)uoc#TK^m6OqQ+vdfd-3VDM6JJ=C1Bi`dCY5=B92^ za$!MH%~f3m^^l_1#az?{dH4ZMrm+M4kU$}<0fRIwX@v)i!3G*EDd(z8PNb0>on!MmZZF(?)P6p>d9A;mSbjLZeCgY0-Q|g+ zvm3YX{d{NP{D=F0U+nvG>hSu--=8M0-fDNRj4gfL*57h^bm;7}(UTLqZ@fKtvi0Zb b%i+Db$LEebcyr+AU9hD)-RrDOomu(^?Fv(R literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_pear2.png b/assets/lumbers/lumbers_items_pear2.png new file mode 100644 index 0000000000000000000000000000000000000000..95cdb8b2583dba03baea0626f4ceac4bdd57c319 GIT binary patch literal 1030 zcmds#F>BOe493&yP^#5ahl)BVRB=&|=;ET5EA2_Smg~{kDTC;s)y1Jhr>Y>Rh{RRg zq~PKrLQw~i&{0HCmx3q`euMbS`!NjMy@VuBp6AK`?qYv-V*Jp!h)ne6x&z)${l<3i zfAZAcC7zL$!R)kbY#sR}GP=GvKb*;m$n;Fh)J&-?BEvH*Lo=j`9_gNL>6$LpYmw$@ zmZoV^qZ+B6YN?tkAf-f#r&x-nkbn&|SPauGwWq=(EJ7os){?o0TeyZxv7l%kW?>p8 zMT%baPz%*ifg__K9%3OH!d6%V25DGAiyDi;1{y4er36(@n7g`5>0>RKnVY&v$%O?) zHCJ^N)I*A17jsb;%7g%;@I4&Yd66~xoN25H(I5jZ2}rBu7r7LV%4sD z`@iyhxi#o7vG>1>%b)-LLE~Jndue#^$?dII`{d~E(ThKyuRMCWJvCfDy?OrXiw}<< zT)6pku=;TO?dzS_r#?=OJzGE9898ufbM^i2J#P+ozD>^GKmPs4!orDT*UsHpe)s7H On9`f+cQ>Z5to;KeeNCAF literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_pear3.png b/assets/lumbers/lumbers_items_pear3.png new file mode 100644 index 0000000000000000000000000000000000000000..d7b9ae50cc811e24937fb34f93df4d271ca9b32d GIT binary patch literal 1029 zcmds#&1#fk429#*qKpjM5kyp^>cVbxVQ^ztmMPPbGEAq%ZUhA(f-BL2peQ1UKf5X- zxdTBc2wp(l2fHikN(2`L7vc@XC+}q#n0X0FPR=>`UXDkDZs%A>M7qPp{)G2X{igQu zKYQ-r3eTQ}nhBGWT1Q!}Nqhz!rL49$=#dZc^0rE9uWuSJ@t zS(>IvjcTNNs-U@=U$)Se2Dun3KiT1)00Zs8g(#e$-Fn1yMW z6e)VuLoHN81&)k{c!-5)2wPzd7^GndEov+V8)&c?mJ(DsVeaZKrH{2_W^U>xB^MSH z)m+t8P!B13UCc#YkcS`8WEwlr4+#{)8Zb!1l2&-I7;K=yl5(!fs zz9JVE6iw6wA8{H3;6*z|qZTXi1DZ@@2b>U$LRbR^X(pis4;F(BwA6{Jn=&~eTnr=8 z$67Mwb7@~g$!!PbqIJ)9q$1UPuk$u5i(_-AuH6I|<))#I-)NPBwh3skxDw`}iB$() z^}h3bU7w6r*!y3`m7PDo(Ks0PFRvbb`)K=PS7xUA%U9QXYj(rf6z)m literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_pear4.png b/assets/lumbers/lumbers_items_pear4.png new file mode 100644 index 0000000000000000000000000000000000000000..8cfc23c1ada3073d7b93e88ab9777e1754df37c2 GIT binary patch literal 1029 zcmds#ziZTC493%nAg9Nvlc<9ZN9qGuE}` zKn20gSweC0*W@aQh=Vv8KY9NQ19vYW$&=@K^4%Pd2Hno_j)-)JSNap)!}U9`kN>6f zy(!PaoylND=6ffrD;whG*DI{P64Hm<6OYN!f2#e4NskLP8;TEppQYe@|kQEnRQ_>ER6Xq$iriz{Isnpk!4@zF0l zpYBdZQ}+IsarMK`?`Rwh`^)Rcp5ESjaYRlXT70|vZ1{3=cKi8k;p4S)y{%up+2$Yn zv2^qGu=nWR#r+#=@0U;9Iz8*08DIFSpS$m_Kl$ws?!S`x&ZX&_%YV0ll;P^AKVP}= F@E@&~O@jac literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_items_pear5.png b/assets/lumbers/lumbers_items_pear5.png new file mode 100644 index 0000000000000000000000000000000000000000..43765f4b7800fa22d258b95fc709fe41f8e613af GIT binary patch literal 1026 zcmds#y=&BQ48~LIfmRPiM5L%Vh%bXnGaVgj%N_MZj^pm!og!3R)Y-vFJ1Byp@gL|` za1rSw_<}=lEb8RqAUL?`7C-s^83yjYgd|U%=gIHkc(mSKSX>a1?(lMd!h5)W`{wyS zfAP?iXYS5qeNDDMpZF=V=fU{uY>*X^>6wO|E|nVb+VhLPxF zEt&GUw6CG$wgYp~x@S95k!rrzd7G8RvAI*%Zi0()(@@86v`RtS1Tjzsso!x zzVUpyI~h&c`(MVD-QT~^*dO*+XUCu2di<&@rw_jS`{MbVGt+aYJ}p1(TsZc1XTW>9e#gi8 zpFMwSmFLLjU~yhXpQaB)#_p^vtu16lWO}A$YNk{ck>MGZp&3#|k91GBbWNA)wMg?c zOVc!|QH@kjwNy(1q53vvpVJoZwgETCmMUBN^0}U3#Qi3Wc%w653^s$!A%uU^-LEq1i@B%^^6&$iOk)T7A%Q|z0|seW(h3h2gAFuTQqEPGoKQ0&Qzj>bi(w@C zSWBjSF3s0aa+?El(Yj}Iq$1V$UgvGBERKykb?ruQQEoKU@f%vDpxFd8SX>G7(8Q_} z_s)Ff`Ep~>UuExq8CO0Z{zT()uXA~A;_=Og&)ah0D|@tpTA4vo0Et4=PvHY(TQWXTi>=H$%oeN&hYhcYWCdj-mSAQH{M=fpPXBN S_3Oz~pryCa?~LZJ4gUe<^HXjB literal 0 HcmV?d00001 diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 3713142f9..2f025bfed 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -121,6 +121,8 @@ typedef struct int playerSpawnX; int playerSpawnY; + int invincibleTimer; + int enemy1Count; int enemy2Count; int enemy3Count; @@ -143,6 +145,7 @@ typedef struct wsg_t floorTiles[20]; wsg_t animationTiles[20]; wsg_t minicharacters[4]; + wsg_t itemIcons[18]; lumberjackBonus_t* bonusDisplay[16]; uint8_t activeBonusIndex; @@ -181,6 +184,10 @@ typedef struct //Item Block int itemBlockTime; bool itemBlockReady; + int itemBlockIndex; + int itemBlockItemAnimation; + int itemBlockAnimationTime; + int itemBlockItemFrame; lumberjackGameType_t gameType; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 6fb9f5f92..436724312 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -57,6 +57,8 @@ #define LUMBERJACK_WATER_INCREASE 10 #define LUMBERJACK_ITEM_RESETTIME 2500 +#define LUMBERJACK_INVINCIBLE_TIME 7000 +#define LUMBERJACK_INVINCIBLE_SPEED 100000 #define LUMBERJACK_COMBO_RESET_TIME 1500 #define LUMBERJACK_TILE_SIZE 16 @@ -104,6 +106,11 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->lives = 3; lumv->gameReady = !(main->networked); + lumv->itemBlockAnimationTime = 0; + lumv->itemBlockItemFrame = 0; + lumv->itemBlockIndex = -1; + lumv->itemBlockItemAnimation = 0; + //ESP_LOGI(LUM_TAG, "Load Title"); loadWsg("lumbers_title.wsg", &lumv->title, true); @@ -333,7 +340,6 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_bonus_7.wsg", &lumv->bonusSprites[7], true); loadWsg("lumbers_bonus_8.wsg", &lumv->bonusSprites[8], true); loadWsg("lumbers_bonus_9.wsg", &lumv->bonusSprites[9], true); - loadWsg("lumbers_item_ui.wsg", &lumv->ui[0], true); @@ -345,6 +351,30 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) } lumv->activeBonusIndex = 0; + + if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + loadWsg("lumbers_items_grapes1.wsg", &lumv->itemIcons[0], true); + loadWsg("lumbers_items_grapes2.wsg", &lumv->itemIcons[1], true); + loadWsg("lumbers_items_grapes3.wsg", &lumv->itemIcons[2], true); + loadWsg("lumbers_items_grapes4.wsg", &lumv->itemIcons[3], true); + loadWsg("lumbers_items_grapes5.wsg", &lumv->itemIcons[4], true); + loadWsg("lumbers_items_grapes6.wsg", &lumv->itemIcons[5], true); + loadWsg("lumbers_items_orange1.wsg", &lumv->itemIcons[6], true); + loadWsg("lumbers_items_orange2.wsg", &lumv->itemIcons[7], true); + loadWsg("lumbers_items_orange3.wsg", &lumv->itemIcons[8], true); + loadWsg("lumbers_items_orange4.wsg", &lumv->itemIcons[9], true); + loadWsg("lumbers_items_orange5.wsg", &lumv->itemIcons[10], true); + loadWsg("lumbers_items_orange6.wsg", &lumv->itemIcons[11], true); + loadWsg("lumbers_items_pear1.wsg", &lumv->itemIcons[12], true); + loadWsg("lumbers_items_pear2.wsg", &lumv->itemIcons[13], true); + loadWsg("lumbers_items_pear3.wsg", &lumv->itemIcons[14], true); + loadWsg("lumbers_items_pear4.wsg", &lumv->itemIcons[15], true); + loadWsg("lumbers_items_pear5.wsg", &lumv->itemIcons[16], true); + loadWsg("lumbers_items_pear6.wsg", &lumv->itemIcons[17], true); + + } + } bool lumberjackLoadLevel() @@ -513,6 +543,7 @@ void lumberjackSetupLevel(int characterIndex) lumv->localPlayer = calloc(1, sizeof(lumberjackEntity_t)); lumv->localPlayer->scoreValue = 0; + lumv->invincibleTimer = LUMBERJACK_INVINCIBLE_TIME; lumberjackSetupPlayer(lumv->localPlayer, characterIndex); lumberjackSpawnPlayer(lumv->localPlayer, lumv->playerSpawnX, lumv->playerSpawnY, 0); @@ -706,6 +737,21 @@ void lumberjackGameLoop(int64_t elapsedUs) } } + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING && lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + if (lumv->itemBlockTime > 0 && lumv->itemBlockIndex == -1) + { + lumv->itemBlockTime -= elapsedUs/10000; + + if (lumv->itemBlockTime <= 0) + { + lumv->itemBlockReady = true; + lumv->itemBlockTime = 0; + } + } + + } + //if panic mode do water if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING && lumv->gameType == LUMBERJACK_MODE_PANIC) { @@ -743,6 +789,26 @@ void lumberjackGameLoop(int64_t elapsedUs) } + //if attack mode animate item + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING && lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + if (lumv->itemBlockIndex != -1) + { + lumv->itemBlockAnimationTime += elapsedUs; + + if (lumv->itemBlockAnimationTime > 80000) + { + lumv->itemBlockAnimationTime -= 80000; + lumv->itemBlockItemAnimation++; + lumv->itemBlockItemAnimation %= 6; + + lumv->itemBlockItemFrame = (lumv->itemBlockIndex * 6) + lumv->itemBlockItemAnimation; + + } + } + + } + DrawGame(); } @@ -797,7 +863,56 @@ void baseMode(int64_t elapsedUs) { ESP_LOGI(LUM_TAG, "Attack this frame!"); - lumberjackSendAttack(lumv->attackQueue); + //lumberjackSendAttack(lumv->attackQueue); + + if (lumv->gameType == LUMBERJACK_MODE_ATTACK && lumv->itemBlockIndex != -1) + { + if (lumv->itemBlockIndex == 0) + { + if (lumv->enemy4Count > 0) + { + lumv->ghost->spawnTime = lumv->ghostSpawnTime ; + lumv->ghost->x = 400; + } + + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + { + lumberjackEntity_t* enemy = lumv->enemy[i]; + + if (enemy == NULL || enemy->state == LUMBERJACK_DEAD) continue; + + + enemy->vy = -20; + enemy->onGround = false; + if (enemy->state == LUMBERJACK_BUMPED || enemy->state == LUMBERJACK_BUMPED_IDLE) + { + enemy->state = LUMBERJACK_RUN; + enemy->direction = enemy->flipped ? 1 : -1; // Go opposite direction + enemy->flipped = !enemy->flipped; + } + else + { + enemy->direction = 0; + enemy->state = LUMBERJACK_BUMPED; + } + + } + } + + if (lumv->itemBlockIndex == 1) + { + ESP_LOGI(LUM_TAG, "%d", 1); //Orange + lumv->invincibleTimer = LUMBERJACK_INVINCIBLE_TIME; + } + + if (lumv->itemBlockIndex >= 2) + { + ESP_LOGI(LUM_TAG, "2" ); //Pear - Invincible + lumv->invincibleTimer = LUMBERJACK_INVINCIBLE_TIME; + } + + lumv->itemBlockIndex = -1; + } } } @@ -961,7 +1076,7 @@ void baseMode(int64_t elapsedUs) { lumberjackEntity_t* enemy = lumv->enemy[enemyIndex]; - if (enemy == NULL || lumv->localPlayer->state == LUMBERJACK_DEAD || lumv->localPlayer->state == LUMBERJACK_INVINCIBLE) + if (enemy == NULL || lumv->localPlayer->state == LUMBERJACK_DEAD) continue; if (enemy->state != LUMBERJACK_DEAD && enemy->state != LUMBERJACK_OFFSCREEN) @@ -1038,7 +1153,7 @@ void baseMode(int64_t elapsedUs) enemy->vx = enemy->direction * 10; enemy->active = false; } - else + else if (lumv->invincibleTimer <= 0) { // Kill player // ESP_LOGI(LUM_TAG, "KILL PLAYER"); @@ -1060,7 +1175,11 @@ void baseMode(int64_t elapsedUs) lumv->stageAnimationFrame++; } - + //Check invincibility timer + if (lumv->invincibleTimer > 0) + { + lumv->invincibleTimer -= elapsedUs / 1000; + } // Update animation if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) @@ -1148,6 +1267,7 @@ void lumberjackOnLocalPlayerDeath(void) lumv->localPlayer->active = false; lumv->localPlayer->jumping = false; lumv->localPlayer->jumpTimer = 0; + lumv->comboAmount = 0; lumv->comboTime = 0; if (lumv->lives <= 0) @@ -1167,6 +1287,7 @@ void lumberjackOnLocalPlayerDeath(void) } + void DrawTitle(void) { drawWsgSimple(&lumv->title, (TFT_WIDTH / 2) - 51, (TFT_HEIGHT / 2) - 48); @@ -1265,8 +1386,19 @@ void DrawGame(void) lumv->localPlayer->drawFrame = currentFrame; // This is where it breaks. When it tries to play frame 3 or 4 it crashes. + if (lumv->invincibleTimer <= 0 || (lumv->invincibleTimer % 4) == 0) + { + drawWsg(&lumv->playerSprites[lumv->localPlayer->drawFrame], lumv->localPlayer->x - 4, lumv->localPlayer->y - lumv->yOffset, lumv->localPlayer->flipped, false, 0); + } + else + { + + drawSolidWsg(&lumv->playerSprites[lumv->localPlayer->drawFrame], lumv->localPlayer->x - 4, + lumv->localPlayer->y - lumv->yOffset, lumv->localPlayer->flipped, false, c500); + } + if (lumv->localPlayer->x > LUMBERJACK_SCREEN_X_MAX) { @@ -1287,6 +1419,11 @@ void DrawGame(void) if (lumv->gameType == LUMBERJACK_MODE_ATTACK) { drawWsgSimple(&lumv->ui[0], (TFT_WIDTH / 2) - 12, 6); + + if (lumv->itemBlockIndex != -1) + { + drawWsgSimple(&lumv->itemIcons[lumv->itemBlockItemFrame], (TFT_WIDTH / 2) - 8, 10); + } } //If playing panic mode draw water @@ -1841,7 +1978,7 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs { if (lumv->localPlayer->x < lumv->ghost->x + LUMBERJACK_GHOST_BOX && lumv->localPlayer->x + lumv->localPlayer->width > lumv->ghost->x && lumv->localPlayer->y < lumv->ghost->y + LUMBERJACK_GHOST_BOX && lumv->localPlayer->y + lumv->localPlayer->height > lumv->ghost->y - && lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_DUCK && lumv->localPlayer->state != LUMBERJACK_INVINCIBLE) + && lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_DUCK && lumv->invincibleTimer > 0) { lumberjackOnLocalPlayerDeath(); } @@ -2001,8 +2138,7 @@ void lumberjackDoControls(void) if (buttonPressed == false && lumv->localPlayer->active) { - if (lumv->localPlayer->state != LUMBERJACK_INVINCIBLE) - lumv->localPlayer->state = LUMBERJACK_IDLE; // Do a ton of other checks here + lumv->localPlayer->state = LUMBERJACK_IDLE; // Do a ton of other checks here } if (lumv->localPlayer->state != previousState) @@ -2126,8 +2262,150 @@ void lumberjackUseBlock() } } } + + if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + lumv->itemBlockIndex = esp_random() % 3; + lumv->itemBlockTime = LUMBERJACK_ITEM_RESETTIME; + + if (lumv->itemBlockIndex == 0) + { + + } + else if (lumv->itemBlockIndex == 1) + { + + } + else { + + } + + } } +/// CODE ++ + +/** + * @brief Draw solid color of a WSG to the display + * + * @param wsg The WSG to draw to the display + * @param xOff The x offset to draw the WSG at + * @param yOff The y offset to draw the WSG at + * @param flipLR true to flip the image across the Y axis + * @param flipUD true to flip the image across the X axis + * @param color The color we're sending instead + */ +void drawSolidWsg(const wsg_t* wsg, int16_t xOff, int16_t yOff, bool flipLR, bool flipUD, uint8_t inColor) +{ + + if (NULL == wsg->px) + { + return; + } + + // Draw the image's pixels (no rotation or transformation) + uint32_t w = TFT_WIDTH; + paletteColor_t* px = getPxTftFramebuffer(); + + uint16_t wsgw = wsg->w; + uint16_t wsgh = wsg->h; + + int32_t xstart = 0; + int16_t xend = wsgw; + int32_t xinc = 1; + + // Reflect over Y axis? + if (flipLR) + { + xstart = wsgw - 1; + xend = -1; + xinc = -1; + } + + if (xOff < 0) + { + if (xinc > 0) + { + xstart -= xOff; + if (xstart >= xend) + { + return; + } + } + else + { + xstart += xOff; + if (xend >= xstart) + { + return; + } + } + xOff = 0; + } + + if (xOff + wsgw > w) + { + int32_t peelBack = (xOff + wsgw) - w; + if (xinc > 0) + { + xend -= peelBack; + if (xstart >= xend) + { + return; + } + } + else + { + xend += peelBack; + if (xend >= xstart) + { + return; + } + } + } + + for (int16_t srcY = 0; srcY < wsgh; srcY++) + { + int32_t usey = srcY; + + // Reflect over X axis? + if (flipUD) + { + usey = wsgh - 1 - usey; + } + + const paletteColor_t* linein = &wsg->px[usey * wsgw]; + + // Transform this pixel's draw location as necessary + uint32_t dstY = srcY + yOff; + + // It is too complicated to detect both directions and backoff correctly, so we just do this here. + // It does slow things down a "tiny" bit. People in the future could optimze out this check. + if (dstY >= TFT_HEIGHT) + { + continue; + } + + int32_t lineOffset = dstY * w; + int32_t dstx = xOff + lineOffset; + + for (int32_t srcX = xstart; srcX != xend; srcX += xinc) + { + // Draw if not transparent + uint8_t color = linein[srcX]; + if (cTransparent != color) + { + px[dstx] = inColor; + } + dstx++; + } + } + +} + + + + /// /// @@ -2194,6 +2472,15 @@ void lumberjackExitGameMode(void) free(lumv->axeBlocks[i]); } + + if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + for (int i = 0; i < ARRAY_SIZE(lumv->itemIcons); i++) + { + freeWsg(&lumv->itemIcons[i]); + } + } + freeFont(&lumv->arcade); free(lumv); } \ No newline at end of file diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 77fe9138a..a951f41ba 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -33,6 +33,7 @@ void lumberjackGameReady(void); void lumberjackPlayGame(void); void lumberjackSendGo(void); void lumberjackSendDeath(bool gameover); +void drawSolidWsg(const wsg_t* wsg, int16_t xOff, int16_t yOff, bool flipLR, bool flipUD, uint8_t inColor); void lumberjackUseBlock(void); diff --git a/main/modes/lumberjack/lumberjackPlayer.c b/main/modes/lumberjack/lumberjackPlayer.c index 186c61fa4..0997a6432 100644 --- a/main/modes/lumberjack/lumberjackPlayer.c +++ b/main/modes/lumberjack/lumberjackPlayer.c @@ -6,7 +6,6 @@ #include #define LUMBERJACK_DEFAULT_ANIMATION_SPEED 150000 -#define LUMBERJACK_INVINCIBLE_ANIMATION_SPEED 100000 #define LUMBERJACK_HERO_WIDTH 24 #define LUMBERJACK_HERO_HEIGHT 31 #define LUMBERJACK_HERO_DUCK_HEIGHT 31 @@ -35,7 +34,7 @@ void lumberjackSpawnPlayer(lumberjackEntity_t* hero, int x, int y, int facing) hero->maxVX = 15; hero->vy = 0; hero->flipped = (facing == 0); - hero->state = LUMBERJACK_INVINCIBLE; + hero->state = LUMBERJACK_IDLE; hero->timerFrameUpdate = 0; hero->active = true; hero->onGround = true; @@ -53,7 +52,7 @@ void lumberjackRespawn(lumberjackEntity_t* hero, int x, int y) hero->vx = 0; hero->vy = 0; hero->flipped = 0; - hero->state = LUMBERJACK_INVINCIBLE; + hero->state = LUMBERJACK_IDLE; hero->timerFrameUpdate = 0; hero->onGround = true; hero->maxLevel = 0; @@ -109,12 +108,6 @@ int lumberjackGetPlayerAnimation(lumberjackEntity_t* hero) hero->animationSpeed = LUMBERJACK_DEFAULT_ANIMATION_SPEED; return animationVictory[hero->currentFrame % ARRAY_SIZE(animationVictory)]; } - if (animation == LUMBERJACK_INVINCIBLE) - { - const int animationInvincible[] = {0, 17}; - hero->animationSpeed = LUMBERJACK_INVINCIBLE_ANIMATION_SPEED; - return animationInvincible[hero->currentFrame % ARRAY_SIZE(animationInvincible)]; - } return 0; } \ No newline at end of file diff --git a/main/modes/lumberjack/lumberjack_types.h b/main/modes/lumberjack/lumberjack_types.h index b231b558f..af74771dc 100644 --- a/main/modes/lumberjack/lumberjack_types.h +++ b/main/modes/lumberjack/lumberjack_types.h @@ -14,7 +14,6 @@ enum lumberjackPlayerState LUMBERJACK_OFFSCREEN = 7, // reserved for enemies only LUMBERJACK_BUMPED = 8, LUMBERJACK_BUMPED_IDLE = 9, - LUMBERJACK_INVINCIBLE = 10, }; // Animation speeds From efeeafe9cf49a82f1089d8d36a57d6390c0fc455 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 5 Nov 2023 18:09:54 -0800 Subject: [PATCH 28/54] New Fast Enemy New Enemy type added Tweaked invincibility animation Made custom invincibility colors --- assets/lumbers/lumberjacks_attack_3.bin | Bin 488 -> 416 bytes assets/lumbers/lumberjacks_attack_4.bin | Bin 488 -> 398 bytes assets/lumbers/lumberjacks_attack_5.bin | Bin 0 -> 488 bytes assets/lumbers/lumberjacks_attack_vs.bin | Bin 740 -> 740 bytes assets/lumbers/lumbers_enemy_f1.png | Bin 0 -> 267 bytes assets/lumbers/lumbers_enemy_f2.png | Bin 0 -> 257 bytes assets/lumbers/lumbers_enemy_f3.png | Bin 0 -> 295 bytes assets/lumbers/lumbers_enemy_f4.png | Bin 0 -> 265 bytes assets/lumbers/lumbers_enemy_f5.png | Bin 0 -> 312 bytes assets/lumbers/lumbers_enemy_f6.png | Bin 0 -> 305 bytes assets/lumbers/lumbers_enemy_f7.png | Bin 0 -> 307 bytes main/modes/lumberjack/lumberjack.h | 7 +++- main/modes/lumberjack/lumberjackEntity.c | 28 +++++++++++++ main/modes/lumberjack/lumberjackGame.c | 49 ++++++++++++++++++----- 14 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 assets/lumbers/lumberjacks_attack_5.bin create mode 100644 assets/lumbers/lumbers_enemy_f1.png create mode 100644 assets/lumbers/lumbers_enemy_f2.png create mode 100644 assets/lumbers/lumbers_enemy_f3.png create mode 100644 assets/lumbers/lumbers_enemy_f4.png create mode 100644 assets/lumbers/lumbers_enemy_f5.png create mode 100644 assets/lumbers/lumbers_enemy_f6.png create mode 100644 assets/lumbers/lumbers_enemy_f7.png diff --git a/assets/lumbers/lumberjacks_attack_3.bin b/assets/lumbers/lumberjacks_attack_3.bin index 5c99cf63b86a9e249b02e031bd8480be9e6cea72..7587d89de309d40fb2a1d91b70a583c6bd1d414d 100644 GIT binary patch delta 79 zcmaFCynvZeY$BsD6F2unK^=Y;5MW?n;o$+23@noi87+l)xPdGn0E&Snxp^ixGMY`6 QV)O1PEmWSs+)! j^dhqfY9vAdBNGC!g4MIJbHD&67f_^vkCBOklY<2S2n+%X literal 488 zcmbV{u?~PR2t;Xv+A1*)P7Z#jpD#yk>)?X7^l0F592-#})lMfKzeJeZ6f=vo%4LkA zEC`4f)y0to(@14WO6ek$W{sf+l*jZdU9`%aMIBjY*ddRT+Nke=wHLrO|hP=wlxrLZ=!Ub+r B0}cQH literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumberjacks_attack_vs.bin b/assets/lumbers/lumberjacks_attack_vs.bin index c98a13be3775782ad72107ae9f743be7f43344f5..8be78753fad826e20db9fbee30c6463ad1986836 100644 GIT binary patch delta 25 dcmaFD`h=B7gM)>EkpT?kCLd%p+32u@2>?Nm1yTS2 delta 25 acmaFD`h=B7gM$GEPx##Ysd#R5*>bl06OrArOT>jEOh!1U6e)j8-1Tjio=si`5w#zIC0M^FQhgiv-`W#?# z*?uq5il~qk^(?PklBgOGNdUn6M3lTzPgJ>M)KBfxN2)*l6hg?>q8>HtBR5R|cw-_# z;f)fwl;(1-Ss!VIMd|OQeE7<(GSTHQ8-Rg4y>1`($7fuhyEuj-WxZdG=nX&YIqmx{ RzkUD!002ovPDHLkV1k&LaykG2 literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_enemy_f2.png b/assets/lumbers/lumbers_enemy_f2.png new file mode 100644 index 0000000000000000000000000000000000000000..ad10f41b2321e67c44c9b189a9ebab59cead3ccc GIT binary patch literal 257 zcmV+c0sj7pP)Px#yGcYrR5*>zlQ9ayKoCXWNM8uI8-LFHM5tS(UW-!at2gr@5 zry@fUS=U)>2`v8Pkff>KWz=NSzB`7&wk8&U%-WAe8|X4rMryNO0dOf_6@bZeN2Zh` zY3@d}uh&HLdlC1qCCA$nfay$m6Wgk{lG)C_0JxSDq7uCUz}GX>v=ivl00000NkvXX Hu0mjfjj3$_ literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_enemy_f3.png b/assets/lumbers/lumbers_enemy_f3.png new file mode 100644 index 0000000000000000000000000000000000000000..0e904be101005152dd20c6d961d55ea961e1a3dd GIT binary patch literal 295 zcmV+?0oeYDP)Px#;Ymb6R5*>bl(C8eF%X8oh+ySASO}JaBO-XczJ=Ycl|E1MCfA>ZxH&9r?Ct@s z(oPU9vLnoL*DSk#lbL~JKK@MN)|)K==i~lK4UKzu2hgdr`7b#UNhCh2cS0U$l&JfT zq5zO(X$>)T^3&V`6yDTxk+z5`%0xZ0ovS3O7KkJQ5JE{*dZnJItYfr!YgMusO*vL_ zY0D$GTh0LZ`hA!Q_hKhKIG4!Ov(lU4{o3$b8x1A^tVUf!=8M9RsAB1jlALaRnkCXe t$>ysM;Q#+=F?>3J&qK;DKi|y~y#Qy`Mtj5yeD44N002ovPDHLkV1i1!ewqLP literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_enemy_f4.png b/assets/lumbers/lumbers_enemy_f4.png new file mode 100644 index 0000000000000000000000000000000000000000..cf09eac2569f1bd4e6ca668d72a9377a1080c358 GIT binary patch literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|#^NA%Cx&(BWL^R}hdo^!Lo9mF zPB!E^9x39 zXSccE-uOfQ(r4YO49gFjWnW4Vu@iAPENLzKOJNb3_x;NtIGkp1VN>NjLewW$SO2z`u-4&`;%x6=K-&+JHp9Ok{ N!PC{xWt~$(69BchXr%xE literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumbers_enemy_f5.png b/assets/lumbers/lumbers_enemy_f5.png new file mode 100644 index 0000000000000000000000000000000000000000..55fff49b576fe65168298073c5c5b75bacb60dab GIT binary patch literal 312 zcmV-80muG{P)Px#@<~KNR5*>bl(9|%K@f(&RTC;Z8#@XTDr4eUn7{*2`3iJ*RJ@M44Ua)%k0wTz zP|(ov09M$Mn6sE2%@SxXdw+8?m)qSh-`=hpPo@BDKHq8@&L zGnAgJL|1=R5CDoopFa3x#VQ1CmzDO9rS>9uiT)iGRYGJD=S~hZ5=#q?L>>63#>mXc z*|fK7$7FGrjuYa0Y0c5_=F$NyN}v4Uv%BZy!Px#>q$gGR5*>bls#$!K@@<$Nfx_UV(Px#?MXyIR5*>b)Uis$FdWD6Z_aYtIr#u?x11pNSA^=W!##yaf{)ZZNgtpG4n}Y+ zba3+loC-o6k{qN|?v&hbYxAf5kY9)*WO=>@;Qq!xZ#y+Gk=6CB0(hw#0NRf?0A^Fe z|A~r{%f%M}-TZU_5a*J?=l&Cbr*Z?p-Pwr(sN3(nqGBwe(thR2B$8didSmPW@USdY zR*@2sMB>8Uh{$1IFqW*MV*KJai54%mHnb^etNBG$XlWc1g|A+uwFFr@mtVB|b7(IL ztI(oxo)GtHoa3FNKPUG&Qjg^Y0Pp>L^8VSEct2$m{Qz(!Kt6V^$P)kn002ovPDHLk FV1fWMhbaI6 literal 0 HcmV?d00001 diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 2f025bfed..ef4efb73c 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -121,7 +121,7 @@ typedef struct int playerSpawnX; int playerSpawnY; - int invincibleTimer; + int enemy1Count; int enemy2Count; @@ -188,6 +188,11 @@ typedef struct int itemBlockItemAnimation; int itemBlockAnimationTime; int itemBlockItemFrame; + + uint8_t invincibleColor; + int invincibleTimer; + int invincibleFlicker; + bool invincibleFlickerOn; lumberjackGameType_t gameType; diff --git a/main/modes/lumberjack/lumberjackEntity.c b/main/modes/lumberjack/lumberjackEntity.c index 6d98d537b..c54e4feb4 100644 --- a/main/modes/lumberjack/lumberjackEntity.c +++ b/main/modes/lumberjack/lumberjackEntity.c @@ -112,6 +112,34 @@ void lumberjackUpdateEnemy(lumberjackEntity_t* enemy, int newIndex) enemy->type = newIndex; } + else if (newIndex == 4) + { + enemy->width = 15; + enemy->height = 15; + enemy->tileHeight = 1; + enemy->maxVX = 10; + enemy->spriteOffset = 23; + enemy->maxLevel = 6; + enemy->cW = 15; + enemy->scoreValue = 500; + enemy->cH = 15; + enemy->type = newIndex; + } + else if (newIndex == 5) + { + enemy->width = 15; + enemy->height = 15; + enemy->tileHeight = 1; + enemy->maxVX = 10; + enemy->spriteOffset = 30; + enemy->maxLevel = 6; + enemy->cW = 15; + enemy->scoreValue = 500; + enemy->cH = 15; + enemy->type = newIndex; + } + + } diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 436724312..b0ddf62be 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -38,7 +38,7 @@ #define LUMBERJACK_BLOCK_ANIMATION_MAX 7 #define LUMBERJACK_ROTATE_ANIMATION_MAX 4 #define LUMBERJACK_RESPAWN_PANIC_MIN 3750 -#define LUMBERJACK_RESPAWN_ATTACK_MIN 500 +#define LUMBERJACK_RESPAWN_ATTACK_MIN 1000 #define LUMBERJACK_RESPAWN_VS_MIN 250 #define LUMBERJACK_UPGRADE_TIMER_OFFSET 250 #define LUMBERJACK_SUBMERGE_TIMER 300 @@ -105,6 +105,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->levelIndex = 0; lumv->lives = 3; lumv->gameReady = !(main->networked); + lumv->invincibleColor = c000; lumv->itemBlockAnimationTime = 0; lumv->itemBlockItemFrame = 0; @@ -201,6 +202,8 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_red_16.wsg", &lumv->playerSprites[15], true); loadWsg("lumbers_red_17.wsg", &lumv->playerSprites[16], true); loadWsg("lumbers_red_22.wsg", &lumv->playerSprites[17], true); + lumv->invincibleColor = c500; + } else if (characterIndex == 1) { @@ -222,6 +225,8 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_green_16.wsg", &lumv->playerSprites[15], true); loadWsg("lumbers_green_17.wsg", &lumv->playerSprites[16], true); loadWsg("lumbers_green_22.wsg", &lumv->playerSprites[17], true); + lumv->invincibleColor = c050; + } else if (characterIndex == 2) { @@ -244,6 +249,8 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("secret_swadgeland_16.wsg", &lumv->playerSprites[15], true); loadWsg("secret_swadgeland_17.wsg", &lumv->playerSprites[16], true); loadWsg("secret_swadgeland_22.wsg", &lumv->playerSprites[17], true); + lumv->invincibleColor = c305; + } else if (characterIndex == 3) { @@ -265,6 +272,8 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_cho_16.wsg", &lumv->playerSprites[15], true); loadWsg("lumbers_cho_17.wsg", &lumv->playerSprites[16], true); loadWsg("lumbers_cho_18.wsg", &lumv->playerSprites[17], true); + lumv->invincibleColor = c103; + } //ESP_LOGI(LUM_TAG, "Loading Enemies"); @@ -419,6 +428,7 @@ bool lumberjackLoadLevel() "lumberjacks_attack_2.bin", "lumberjacks_attack_3.bin", "lumberjacks_attack_4.bin", + "lumberjacks_attack_5.bin", }; fname = attackLevelName[lumv->levelIndex % ARRAY_SIZE(attackLevelName)]; @@ -505,6 +515,12 @@ bool lumberjackLoadLevel() lumv->tile[i].offset_time = 0; } + + + for (int i = 0; i < ARRAY_SIZE(lumv->bonusDisplay); i++) + { + lumv->bonusDisplay[i]->active = false; + } int offset = (lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH) + 12; ESP_LOGI (LUM_TAG, "%d total enemies",lumv->totalEnemyCount); @@ -589,14 +605,14 @@ void lumberjackSetupLevel(int characterIndex) for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy5Count; eSpawnIndex++) { lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); - lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 4); } offset += lumv->enemy5Count; for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy6Count; eSpawnIndex++) { lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); - lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 0); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 5); } offset += lumv->enemy6Count; @@ -1064,6 +1080,7 @@ void baseMode(int64_t elapsedUs) // Respawn player lumv->localPlayer->respawn = 0; lumv->lives--; + lumv->invincibleTimer = LUMBERJACK_INVINCIBLE_TIME; lumberjackRespawn(lumv->localPlayer, lumv->playerSpawnX, lumv->playerSpawnY); } } @@ -1179,6 +1196,13 @@ void baseMode(int64_t elapsedUs) if (lumv->invincibleTimer > 0) { lumv->invincibleTimer -= elapsedUs / 1000; + lumv->invincibleFlicker -= elapsedUs/1000; + + if (lumv->invincibleFlicker <= 0) + { + lumv->invincibleFlicker = 250; + lumv->invincibleFlickerOn = !lumv->invincibleFlickerOn; + } } // Update animation @@ -1386,9 +1410,10 @@ void DrawGame(void) lumv->localPlayer->drawFrame = currentFrame; // This is where it breaks. When it tries to play frame 3 or 4 it crashes. - if (lumv->invincibleTimer <= 0 || (lumv->invincibleTimer % 4) == 0) + if (lumv->invincibleTimer <= 0 || !lumv->invincibleFlickerOn) { + drawWsg(&lumv->playerSprites[lumv->localPlayer->drawFrame], lumv->localPlayer->x - 4, lumv->localPlayer->y - lumv->yOffset, lumv->localPlayer->flipped, false, 0); } @@ -1396,7 +1421,7 @@ void DrawGame(void) { drawSolidWsg(&lumv->playerSprites[lumv->localPlayer->drawFrame], lumv->localPlayer->x - 4, - lumv->localPlayer->y - lumv->yOffset, lumv->localPlayer->flipped, false, c500); + lumv->localPlayer->y - lumv->yOffset, lumv->localPlayer->flipped, false, lumv->invincibleColor); } @@ -1491,10 +1516,6 @@ void DrawGame(void) drawWsgSimple(&lumv->bonusSprites[currentBonus->bonusAmount], currentBonus->x+8, currentBonus->y - lumv->yOffset - (20 - (20 * offsetTime))); } - if (i == 1) - { - ESP_LOGI(LUM_TAG, "COMBO 1 %d %f", currentBonus->time , offsetTime); - } //currentBonus->time += ; //currentBonus->bonusAmount = lumv->comboAmount; } @@ -1978,7 +1999,7 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs { if (lumv->localPlayer->x < lumv->ghost->x + LUMBERJACK_GHOST_BOX && lumv->localPlayer->x + lumv->localPlayer->width > lumv->ghost->x && lumv->localPlayer->y < lumv->ghost->y + LUMBERJACK_GHOST_BOX && lumv->localPlayer->y + lumv->localPlayer->height > lumv->ghost->y - && lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_DUCK && lumv->invincibleTimer > 0) + && lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_DUCK && lumv->invincibleTimer <= 0) { lumberjackOnLocalPlayerDeath(); } @@ -2231,6 +2252,14 @@ void lumberjackDetectBump(lumberjackTile_t* tile) { enemy->direction = 0; enemy->state = LUMBERJACK_BUMPED; + + if (enemy->type == 4) + { + lumberjackUpdateEnemy(enemy, enemy->type + 1); + enemy->state = LUMBERJACK_RUN; + enemy->direction = enemy->flipped ? 1 : -1; // Go opposite direction + enemy->flipped = !enemy->flipped; + } } } } From 1426923b0d49db91caa7b5f9baedfbf3447df931 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 5 Nov 2023 20:36:59 -0800 Subject: [PATCH 29/54] Additional levels Enemies will change directions if they walk into a wall. Added Panic level 6 and 7 Added new enemy to panic level 10 --- assets/lumbers/lumberjacks_panic_10.bin | Bin 740 -> 740 bytes assets/lumbers/lumberjacks_panic_6.bin | Bin 0 -> 398 bytes assets/lumbers/lumberjacks_panic_7.bin | Bin 0 -> 452 bytes main/modes/lumberjack/lumberjackGame.c | 34 +++++++++++------------- 4 files changed, 16 insertions(+), 18 deletions(-) create mode 100644 assets/lumbers/lumberjacks_panic_6.bin create mode 100644 assets/lumbers/lumberjacks_panic_7.bin diff --git a/assets/lumbers/lumberjacks_panic_10.bin b/assets/lumbers/lumberjacks_panic_10.bin index 6f3fd99cc3297684bb338f376a8a9b33f5f2de6f..8d7a8da0a69ccca84d78d7531bda1b8581d2d035 100644 GIT binary patch delta 31 kcmaFD`h=B7gN2cSk(mJmEXT;c(Q`Hv09(NZ2LJ#7 delta 31 jcmaFD`h=B7gN2cSkpT?kCJGu(RA8Mf$H>0Xb2bwITY?4z diff --git a/assets/lumbers/lumberjacks_panic_6.bin b/assets/lumbers/lumberjacks_panic_6.bin new file mode 100644 index 0000000000000000000000000000000000000000..3f3555873f68abbde04f44cf34b8254a992285d1 GIT binary patch literal 398 zcmWgTU|?Wi0b&sbIUq?Dzybjvvyhl*MsuU_adJV9Lj^1>%*-rMVW0)bl4x9HDO_xb leuR@@j>e^)ba6%|1YiYgXJhAp0ZuNUNCh7w69*>;3jiTN0w(|f literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumberjacks_panic_7.bin b/assets/lumbers/lumberjacks_panic_7.bin new file mode 100644 index 0000000000000000000000000000000000000000..c9ff3e20051d18136e6622ca4440f5cacece1fd7 GIT binary patch literal 452 zcma)2%MO4b3@ctWsTR@od?)gSV_Y4f1RQji}xid=+a_ literal 0 HcmV?d00001 diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index b0ddf62be..9809defc4 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -403,6 +403,8 @@ bool lumberjackLoadLevel() "lumberjacks_panic_3.bin", "lumberjacks_panic_4.bin", "lumberjacks_panic_5.bin", + "lumberjacks_panic_6.bin", + "lumberjacks_panic_7.bin", "lumberjacks_panic_10.bin", }; @@ -1057,18 +1059,23 @@ void baseMode(int64_t elapsedUs) lumberjackUpdateEntity(enemy, elapsedUs); - for (int oeIdx = 0; oeIdx < ARRAY_SIZE(lumv->enemy); oeIdx++) + + if (enemy->direction != 0) { - if (lumv->enemy[oeIdx] == NULL) - continue; - lumberjackUpdateEnemyCollision(lumv->enemy[oeIdx]); + lumberjackTile_t* facingTile = lumberjackGetTile(enemy->x + (enemy->direction > 0 ? 28 : -8) , enemy->y + 2); + + if (facingTile != NULL && facingTile->type != 0 && lumberjackIsCollisionTile(facingTile)) + { + enemy->direction = enemy->flipped ? 1 : -1; // Go opposite direction + enemy->flipped = !enemy->flipped; //Debug + enemy->vx = (enemy->direction == 1) ? enemy->maxVX : -enemy->maxVX; + } } - } - } - if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) - { + lumberjackUpdateEnemyCollision(enemy); + } + // Player if (lumv->localPlayer->ready) { @@ -1521,6 +1528,7 @@ void DrawGame(void) } + //drawRect() // Debug /* @@ -1668,7 +1676,6 @@ bool lumberjackSpawnCheck(int64_t elapseUs) else { lumv->spawnTimer = LUMBERJACK_RESPAWN_PANIC_MIN; - ESP_LOGI(LUM_TAG, "Hi!"); } }*/ @@ -1857,15 +1864,6 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs lumberjackTile_t* tileA = lumberjackGetTile(destinationX, destinationY); lumberjackTile_t* tileB = lumberjackGetTile(destinationX + 16, destinationY); - if (tileA == NULL) - { - ESP_LOGI(LUM_TAG, "ERROR GETTING TILE A at %d,%d", destinationX , destinationY); - } - if (tileB == NULL) - { - ESP_LOGI(LUM_TAG, "ERROR GETTING TILE B at %d, %d", destinationX + 16, destinationY); - } - if ((tileA != NULL && lumberjackIsCollisionTile(tileA->type)) || (tileB != NULL && lumberjackIsCollisionTile(tileB->type))) { destinationY = ((tileA->y + 1) * LUMBERJACK_TILE_SIZE); From bd9119875f53144db248c3baab87e761699f3a83 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Wed, 8 Nov 2023 20:27:00 -0800 Subject: [PATCH 30/54] Attack mode updates Fixed bug in Lumberjack Menu that wouldn't select proper mode when pressing right. Orange now upgrades enemies. Made item blocks no longer carry over. --- main/modes/lumberjack/lumberjack.c | 12 ++++++++++++ main/modes/lumberjack/lumberjackGame.c | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index 454265858..9f378aa19 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -447,6 +447,18 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV } else { + + if (label == lumberjackPanic) + { + ESP_LOGI(LUM_TAG, "Panic"); + lumberjack->gameMode = LUMBERJACK_MODE_PANIC; + } + else if (label == lumberjackAttack) + { + ESP_LOGI(LUM_TAG, "Attack"); + lumberjack->gameMode = LUMBERJACK_MODE_ATTACK; + } + if (label == lumberjackRedCharacter) { lumberjack->selected = 0; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 9809defc4..d82b390d5 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -448,6 +448,7 @@ bool lumberjackLoadLevel() } lumv->enemySpawnAmount = 4; + lumv->itemBlockIndex = -1; } @@ -919,8 +920,20 @@ void baseMode(int64_t elapsedUs) if (lumv->itemBlockIndex == 1) { - ESP_LOGI(LUM_TAG, "%d", 1); //Orange - lumv->invincibleTimer = LUMBERJACK_INVINCIBLE_TIME; + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + { + lumberjackEntity_t* enemy = lumv->enemy[i]; + + if (enemy == NULL || enemy->state == LUMBERJACK_DEAD) continue; + + if (enemy->active) + { + enemy->vy = -20; + lumberjackUpdateEnemy(enemy, enemy->type + 1); + } + + + } } if (lumv->itemBlockIndex >= 2) From 1aff05d33257c6c93e28c84be58e983c037b2512 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Thu, 9 Nov 2023 22:38:01 -0800 Subject: [PATCH 31/54] Removing showstopping bug Log statement preventing build. --- main/modes/lumberjack/lumberjack.c | 2 +- main/modes/lumberjack/lumberjackGame.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index 9f378aa19..11e4bf8ec 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -43,7 +43,7 @@ static const char lumberjackBack[] = "Back"; // static const char lumberjackNone[] = "None"; static char lumberjackRedCharacter[] = "Character: Red"; static char lumberjackGreenCharacter[] = "Character: Green"; -static char lumberjackSpecialCharacter[] = "Character: Special"; +static char lumberjackSpecialCharacter[] = "Character: Guy"; static char lumberjackChoCharacter[] = "Character: Cho"; static const char lumberjackMenuSinglePlayer[] = "Single Player"; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index d82b390d5..27a4f4054 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -1713,7 +1713,7 @@ void lumberjackOnReceiveAttack(const uint8_t* attack) { if (lumv->gameType == LUMBERJACK_MODE_PANIC) { - ESP_LOGI(LUM_TAG, "Being attacked %ld", sizeof(attack)); +// ESP_LOGI(LUM_TAG, "Being attacked %ld", sizeof(attack)); lumv->waterDirection = -1; //Even if it is draining lumv->waterSpeed -= 5; From a520a0ad441f5baf019469a15b78ccfda1ccb97f Mon Sep 17 00:00:00 2001 From: MrTroy Date: Fri, 10 Nov 2023 21:18:14 -0800 Subject: [PATCH 32/54] Multiplayer Score Sending Score is now being sent multiplayer Fixed enemy shimmying in the air --- main/modes/lumberjack/lumberjack.c | 24 ++++++++++++++++++++++-- main/modes/lumberjack/lumberjackGame.c | 26 +++++++++++++++++++++----- main/modes/lumberjack/lumberjackGame.h | 3 +++ 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index 11e4bf8ec..739ebb4a4 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -74,7 +74,8 @@ typedef enum VERSION_MSG, READY_MSG, ATTACK_MSG, - DEATH_MSG + DEATH_MSG, + SCORE_MSG } lumberjackMessageType_t; lumberjack_t* lumberjack = NULL; @@ -240,7 +241,7 @@ static void lumberjackEspNowRecvCb(const esp_now_recv_info_t* esp_now_info, cons ESP_LOGI(LUM_TAG, "Getting: %d %d", len, rssi); for (int i = 0; i < len; i++) { - //ESP_LOGI(LUM_TAG, "data %d) %d", i, data[i]); + ESP_LOGI(LUM_TAG, "data %d) %d", i, data[i]); } p2pRecvCb(&lumberjack->p2p, esp_now_info->src_addr, (const uint8_t*)data, len, rssi); } @@ -313,6 +314,11 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) lumberjackOnReceiveAttack(payload); } + if (payload[0] == SCORE_MSG) + { + lumberjackOnReceiveScore(payload); + } + if (payload[0] == DEATH_MSG) { ESP_LOGI(LUM_TAG, "Playher died!"); @@ -356,6 +362,20 @@ void lumberjackSendAttack(uint8_t* number) } } +void lumberjackSendScore(int score) +{ + if (lumberjack->networked) + { + + uint8_t payload[4] = {SCORE_MSG}; + + payload[3] = score >> 16 & 0xFF; + payload[2] = score >> 8 & 0xFF; + payload[1] = score & 0xFF; + p2pSendMsg(&lumberjack->p2p, payload, ARRAY_SIZE(payload), lumberjackMsgTxCbFn); + } +} + void lumberjackSendDeath(bool gameover) { if (lumberjack->networked) diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 27a4f4054..38cfbfbbc 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -679,6 +679,7 @@ void lumberjackTitleLoop(int64_t elapsedUs) lumberjackPlayGame(); lumberjackSendGo(); } + lumv->highscore = 0; } else if (lumv->btnState & PB_A && lumv->gameReady) // And Game Ready! { @@ -1073,7 +1074,7 @@ void baseMode(int64_t elapsedUs) lumberjackUpdateEntity(enemy, elapsedUs); - if (enemy->direction != 0) + if (enemy->direction != 0 && enemy->onGround) { lumberjackTile_t* facingTile = lumberjackGetTile(enemy->x + (enemy->direction > 0 ? 28 : -8) , enemy->y + 2); @@ -1149,13 +1150,21 @@ void baseMode(int64_t elapsedUs) lumv->score += enemy->scoreValue * (lumv->comboAmount + 1); - lumv->comboTime = LUMBERJACK_COMBO_RESET_TIME; - - if (lumv->score > lumv->highscore) + if (lumv->lumberjackMain->networked) { - lumv->highscore = lumv->score; + lumberjackSendScore(lumv->score); + } + else + { + if (lumv->score > lumv->highscore) + { + lumv->highscore = lumv->score; + } } + lumv->comboTime = LUMBERJACK_COMBO_RESET_TIME; + + //if game mode is single player decide if you're going to clear the level lumv->enemyKillCount ++; @@ -1729,6 +1738,13 @@ void lumberjackOnReceiveAttack(const uint8_t* attack) } } +void lumberjackOnReceiveScore(const uint8_t* score) +{ + int locX = (int)score[1] << 0 | (uint32_t)score[2] << 8 | (uint32_t)score[3] << 16; + ESP_LOGI(LUM_TAG, "SCORE: %d", locX); + lumv->highscore = locX; +} + void lumberjackOnReceiveDeath(bool gameover) { ESP_LOGI(LUM_TAG, "Player died! Haha %d", (gameover)); diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index a951f41ba..e601c941b 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -27,7 +27,10 @@ void lumberjackTitleDisplayText(char* string, int locationX, int locationY); void baseMode(int64_t elapsedUs); void lumberjackSendAttack(uint8_t* number); +void lumberjackSendScore(int score); + void lumberjackOnReceiveAttack(const uint8_t* attack); +void lumberjackOnReceiveScore(const uint8_t* score); void lumberjackOnReceiveDeath(bool gameover); void lumberjackGameReady(void); void lumberjackPlayGame(void); From 7a4d68d2cb4040023692dbd905896745f0fc5fdb Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 11 Nov 2023 10:44:38 -0800 Subject: [PATCH 33/54] Simple multiplayer update Made enemies able to be put in a spawn que (for multiplayer) Renamed assets so they all appear to go to the same game Enemies now travel to opposing player's screen --- assets/lumbers/lumberjacks_attack_vs.bin | Bin 740 -> 740 bytes ...m_floor1.png => lumbers_bottom_floor1.png} | Bin ...floor10.png => lumbers_bottom_floor10.png} | Bin ...m_floor2.png => lumbers_bottom_floor2.png} | Bin ...m_floor3.png => lumbers_bottom_floor3.png} | Bin ...m_floor4.png => lumbers_bottom_floor4.png} | Bin ...m_floor5.png => lumbers_bottom_floor5.png} | Bin ...m_floor6.png => lumbers_bottom_floor6.png} | Bin ...m_floor7.png => lumbers_bottom_floor7.png} | Bin ...m_floor8.png => lumbers_bottom_floor8.png} | Bin ...m_floor9.png => lumbers_bottom_floor9.png} | Bin ..._1.png => lumbers_secret_swadgeland_1.png} | Bin ...0.png => lumbers_secret_swadgeland_10.png} | Bin ...1.png => lumbers_secret_swadgeland_11.png} | Bin ...2.png => lumbers_secret_swadgeland_12.png} | Bin ...3.png => lumbers_secret_swadgeland_13.png} | Bin ...4.png => lumbers_secret_swadgeland_14.png} | Bin ...5.png => lumbers_secret_swadgeland_15.png} | Bin ...6.png => lumbers_secret_swadgeland_16.png} | Bin ...7.png => lumbers_secret_swadgeland_17.png} | Bin ..._2.png => lumbers_secret_swadgeland_2.png} | Bin ...2.png => lumbers_secret_swadgeland_22.png} | Bin ..._3.png => lumbers_secret_swadgeland_3.png} | Bin ..._4.png => lumbers_secret_swadgeland_4.png} | Bin ..._5.png => lumbers_secret_swadgeland_5.png} | Bin ..._6.png => lumbers_secret_swadgeland_6.png} | Bin ..._7.png => lumbers_secret_swadgeland_7.png} | Bin ..._8.png => lumbers_secret_swadgeland_8.png} | Bin ..._9.png => lumbers_secret_swadgeland_9.png} | Bin ...ng => lumbers_secret_swadgeland_lives.png} | Bin ...er_floor0.png => lumbers_water_floor0.png} | Bin ...er_floor1.png => lumbers_water_floor1.png} | Bin ...er_floor2.png => lumbers_water_floor2.png} | Bin ...er_floor3.png => lumbers_water_floor3.png} | Bin ...er_floor4.png => lumbers_water_floor4.png} | Bin ...loor_b1.png => lumbers_water_floor_b1.png} | Bin ...loor_b2.png => lumbers_water_floor_b2.png} | Bin ...loor_b3.png => lumbers_water_floor_b3.png} | Bin ...loor_b4.png => lumbers_water_floor_b4.png} | Bin assets/lumbers/secret_swadgeland_18.png | Bin 1091 -> 0 bytes assets/lumbers/secret_swadgeland_19.png | Bin 1097 -> 0 bytes assets/lumbers/secret_swadgeland_20.png | Bin 1094 -> 0 bytes assets/lumbers/secret_swadgeland_21.png | Bin 1087 -> 0 bytes main/modes/lumberjack/lumberjack.c | 9 +- main/modes/lumberjack/lumberjackEntity.c | 1 + main/modes/lumberjack/lumberjackEntity.h | 1 + main/modes/lumberjack/lumberjackGame.c | 256 +++++++++++++----- main/modes/lumberjack/lumberjackGame.h | 2 +- 48 files changed, 201 insertions(+), 68 deletions(-) rename assets/lumbers/{bottom_floor1.png => lumbers_bottom_floor1.png} (100%) rename assets/lumbers/{bottom_floor10.png => lumbers_bottom_floor10.png} (100%) rename assets/lumbers/{bottom_floor2.png => lumbers_bottom_floor2.png} (100%) rename assets/lumbers/{bottom_floor3.png => lumbers_bottom_floor3.png} (100%) rename assets/lumbers/{bottom_floor4.png => lumbers_bottom_floor4.png} (100%) rename assets/lumbers/{bottom_floor5.png => lumbers_bottom_floor5.png} (100%) rename assets/lumbers/{bottom_floor6.png => lumbers_bottom_floor6.png} (100%) rename assets/lumbers/{bottom_floor7.png => lumbers_bottom_floor7.png} (100%) rename assets/lumbers/{bottom_floor8.png => lumbers_bottom_floor8.png} (100%) rename assets/lumbers/{bottom_floor9.png => lumbers_bottom_floor9.png} (100%) rename assets/lumbers/{secret_swadgeland_1.png => lumbers_secret_swadgeland_1.png} (100%) rename assets/lumbers/{secret_swadgeland_10.png => lumbers_secret_swadgeland_10.png} (100%) rename assets/lumbers/{secret_swadgeland_11.png => lumbers_secret_swadgeland_11.png} (100%) rename assets/lumbers/{secret_swadgeland_12.png => lumbers_secret_swadgeland_12.png} (100%) rename assets/lumbers/{secret_swadgeland_13.png => lumbers_secret_swadgeland_13.png} (100%) rename assets/lumbers/{secret_swadgeland_14.png => lumbers_secret_swadgeland_14.png} (100%) rename assets/lumbers/{secret_swadgeland_15.png => lumbers_secret_swadgeland_15.png} (100%) rename assets/lumbers/{secret_swadgeland_16.png => lumbers_secret_swadgeland_16.png} (100%) rename assets/lumbers/{secret_swadgeland_17.png => lumbers_secret_swadgeland_17.png} (100%) rename assets/lumbers/{secret_swadgeland_2.png => lumbers_secret_swadgeland_2.png} (100%) rename assets/lumbers/{secret_swadgeland_22.png => lumbers_secret_swadgeland_22.png} (100%) rename assets/lumbers/{secret_swadgeland_3.png => lumbers_secret_swadgeland_3.png} (100%) rename assets/lumbers/{secret_swadgeland_4.png => lumbers_secret_swadgeland_4.png} (100%) rename assets/lumbers/{secret_swadgeland_5.png => lumbers_secret_swadgeland_5.png} (100%) rename assets/lumbers/{secret_swadgeland_6.png => lumbers_secret_swadgeland_6.png} (100%) rename assets/lumbers/{secret_swadgeland_7.png => lumbers_secret_swadgeland_7.png} (100%) rename assets/lumbers/{secret_swadgeland_8.png => lumbers_secret_swadgeland_8.png} (100%) rename assets/lumbers/{secret_swadgeland_9.png => lumbers_secret_swadgeland_9.png} (100%) rename assets/lumbers/{secret_swadgeland_lives.png => lumbers_secret_swadgeland_lives.png} (100%) rename assets/lumbers/{water_floor0.png => lumbers_water_floor0.png} (100%) rename assets/lumbers/{water_floor1.png => lumbers_water_floor1.png} (100%) rename assets/lumbers/{water_floor2.png => lumbers_water_floor2.png} (100%) rename assets/lumbers/{water_floor3.png => lumbers_water_floor3.png} (100%) rename assets/lumbers/{water_floor4.png => lumbers_water_floor4.png} (100%) rename assets/lumbers/{water_floor_b1.png => lumbers_water_floor_b1.png} (100%) rename assets/lumbers/{water_floor_b2.png => lumbers_water_floor_b2.png} (100%) rename assets/lumbers/{water_floor_b3.png => lumbers_water_floor_b3.png} (100%) rename assets/lumbers/{water_floor_b4.png => lumbers_water_floor_b4.png} (100%) delete mode 100644 assets/lumbers/secret_swadgeland_18.png delete mode 100644 assets/lumbers/secret_swadgeland_19.png delete mode 100644 assets/lumbers/secret_swadgeland_20.png delete mode 100644 assets/lumbers/secret_swadgeland_21.png diff --git a/assets/lumbers/lumberjacks_attack_vs.bin b/assets/lumbers/lumberjacks_attack_vs.bin index 8be78753fad826e20db9fbee30c6463ad1986836..e4dd3e74b06196f7a30fe386d00fe2a337ca52c5 100644 GIT binary patch delta 83 zcmaFD`h=B7gNccOkpT$!8RRA(WHg!R5WvO*1`{7zP0nLtV+YEC_>%*e6ecRj32-wo YumAxM4~S%7;09>|%CT-vVQgRo0A;rhTL1t6 delta 71 zcmaFD`h=B7gM)>EkpT?kCLd%pndlI}%EAK#6CYSl&SPSmypGXTfSZAV1r8V(xIqdh N2Qaa2PGM|d1OV;S4XXeE diff --git a/assets/lumbers/bottom_floor1.png b/assets/lumbers/lumbers_bottom_floor1.png similarity index 100% rename from assets/lumbers/bottom_floor1.png rename to assets/lumbers/lumbers_bottom_floor1.png diff --git a/assets/lumbers/bottom_floor10.png b/assets/lumbers/lumbers_bottom_floor10.png similarity index 100% rename from assets/lumbers/bottom_floor10.png rename to assets/lumbers/lumbers_bottom_floor10.png diff --git a/assets/lumbers/bottom_floor2.png b/assets/lumbers/lumbers_bottom_floor2.png similarity index 100% rename from assets/lumbers/bottom_floor2.png rename to assets/lumbers/lumbers_bottom_floor2.png diff --git a/assets/lumbers/bottom_floor3.png b/assets/lumbers/lumbers_bottom_floor3.png similarity index 100% rename from assets/lumbers/bottom_floor3.png rename to assets/lumbers/lumbers_bottom_floor3.png diff --git a/assets/lumbers/bottom_floor4.png b/assets/lumbers/lumbers_bottom_floor4.png similarity index 100% rename from assets/lumbers/bottom_floor4.png rename to assets/lumbers/lumbers_bottom_floor4.png diff --git a/assets/lumbers/bottom_floor5.png b/assets/lumbers/lumbers_bottom_floor5.png similarity index 100% rename from assets/lumbers/bottom_floor5.png rename to assets/lumbers/lumbers_bottom_floor5.png diff --git a/assets/lumbers/bottom_floor6.png b/assets/lumbers/lumbers_bottom_floor6.png similarity index 100% rename from assets/lumbers/bottom_floor6.png rename to assets/lumbers/lumbers_bottom_floor6.png diff --git a/assets/lumbers/bottom_floor7.png b/assets/lumbers/lumbers_bottom_floor7.png similarity index 100% rename from assets/lumbers/bottom_floor7.png rename to assets/lumbers/lumbers_bottom_floor7.png diff --git a/assets/lumbers/bottom_floor8.png b/assets/lumbers/lumbers_bottom_floor8.png similarity index 100% rename from assets/lumbers/bottom_floor8.png rename to assets/lumbers/lumbers_bottom_floor8.png diff --git a/assets/lumbers/bottom_floor9.png b/assets/lumbers/lumbers_bottom_floor9.png similarity index 100% rename from assets/lumbers/bottom_floor9.png rename to assets/lumbers/lumbers_bottom_floor9.png diff --git a/assets/lumbers/secret_swadgeland_1.png b/assets/lumbers/lumbers_secret_swadgeland_1.png similarity index 100% rename from assets/lumbers/secret_swadgeland_1.png rename to assets/lumbers/lumbers_secret_swadgeland_1.png diff --git a/assets/lumbers/secret_swadgeland_10.png b/assets/lumbers/lumbers_secret_swadgeland_10.png similarity index 100% rename from assets/lumbers/secret_swadgeland_10.png rename to assets/lumbers/lumbers_secret_swadgeland_10.png diff --git a/assets/lumbers/secret_swadgeland_11.png b/assets/lumbers/lumbers_secret_swadgeland_11.png similarity index 100% rename from assets/lumbers/secret_swadgeland_11.png rename to assets/lumbers/lumbers_secret_swadgeland_11.png diff --git a/assets/lumbers/secret_swadgeland_12.png b/assets/lumbers/lumbers_secret_swadgeland_12.png similarity index 100% rename from assets/lumbers/secret_swadgeland_12.png rename to assets/lumbers/lumbers_secret_swadgeland_12.png diff --git a/assets/lumbers/secret_swadgeland_13.png b/assets/lumbers/lumbers_secret_swadgeland_13.png similarity index 100% rename from assets/lumbers/secret_swadgeland_13.png rename to assets/lumbers/lumbers_secret_swadgeland_13.png diff --git a/assets/lumbers/secret_swadgeland_14.png b/assets/lumbers/lumbers_secret_swadgeland_14.png similarity index 100% rename from assets/lumbers/secret_swadgeland_14.png rename to assets/lumbers/lumbers_secret_swadgeland_14.png diff --git a/assets/lumbers/secret_swadgeland_15.png b/assets/lumbers/lumbers_secret_swadgeland_15.png similarity index 100% rename from assets/lumbers/secret_swadgeland_15.png rename to assets/lumbers/lumbers_secret_swadgeland_15.png diff --git a/assets/lumbers/secret_swadgeland_16.png b/assets/lumbers/lumbers_secret_swadgeland_16.png similarity index 100% rename from assets/lumbers/secret_swadgeland_16.png rename to assets/lumbers/lumbers_secret_swadgeland_16.png diff --git a/assets/lumbers/secret_swadgeland_17.png b/assets/lumbers/lumbers_secret_swadgeland_17.png similarity index 100% rename from assets/lumbers/secret_swadgeland_17.png rename to assets/lumbers/lumbers_secret_swadgeland_17.png diff --git a/assets/lumbers/secret_swadgeland_2.png b/assets/lumbers/lumbers_secret_swadgeland_2.png similarity index 100% rename from assets/lumbers/secret_swadgeland_2.png rename to assets/lumbers/lumbers_secret_swadgeland_2.png diff --git a/assets/lumbers/secret_swadgeland_22.png b/assets/lumbers/lumbers_secret_swadgeland_22.png similarity index 100% rename from assets/lumbers/secret_swadgeland_22.png rename to assets/lumbers/lumbers_secret_swadgeland_22.png diff --git a/assets/lumbers/secret_swadgeland_3.png b/assets/lumbers/lumbers_secret_swadgeland_3.png similarity index 100% rename from assets/lumbers/secret_swadgeland_3.png rename to assets/lumbers/lumbers_secret_swadgeland_3.png diff --git a/assets/lumbers/secret_swadgeland_4.png b/assets/lumbers/lumbers_secret_swadgeland_4.png similarity index 100% rename from assets/lumbers/secret_swadgeland_4.png rename to assets/lumbers/lumbers_secret_swadgeland_4.png diff --git a/assets/lumbers/secret_swadgeland_5.png b/assets/lumbers/lumbers_secret_swadgeland_5.png similarity index 100% rename from assets/lumbers/secret_swadgeland_5.png rename to assets/lumbers/lumbers_secret_swadgeland_5.png diff --git a/assets/lumbers/secret_swadgeland_6.png b/assets/lumbers/lumbers_secret_swadgeland_6.png similarity index 100% rename from assets/lumbers/secret_swadgeland_6.png rename to assets/lumbers/lumbers_secret_swadgeland_6.png diff --git a/assets/lumbers/secret_swadgeland_7.png b/assets/lumbers/lumbers_secret_swadgeland_7.png similarity index 100% rename from assets/lumbers/secret_swadgeland_7.png rename to assets/lumbers/lumbers_secret_swadgeland_7.png diff --git a/assets/lumbers/secret_swadgeland_8.png b/assets/lumbers/lumbers_secret_swadgeland_8.png similarity index 100% rename from assets/lumbers/secret_swadgeland_8.png rename to assets/lumbers/lumbers_secret_swadgeland_8.png diff --git a/assets/lumbers/secret_swadgeland_9.png b/assets/lumbers/lumbers_secret_swadgeland_9.png similarity index 100% rename from assets/lumbers/secret_swadgeland_9.png rename to assets/lumbers/lumbers_secret_swadgeland_9.png diff --git a/assets/lumbers/secret_swadgeland_lives.png b/assets/lumbers/lumbers_secret_swadgeland_lives.png similarity index 100% rename from assets/lumbers/secret_swadgeland_lives.png rename to assets/lumbers/lumbers_secret_swadgeland_lives.png diff --git a/assets/lumbers/water_floor0.png b/assets/lumbers/lumbers_water_floor0.png similarity index 100% rename from assets/lumbers/water_floor0.png rename to assets/lumbers/lumbers_water_floor0.png diff --git a/assets/lumbers/water_floor1.png b/assets/lumbers/lumbers_water_floor1.png similarity index 100% rename from assets/lumbers/water_floor1.png rename to assets/lumbers/lumbers_water_floor1.png diff --git a/assets/lumbers/water_floor2.png b/assets/lumbers/lumbers_water_floor2.png similarity index 100% rename from assets/lumbers/water_floor2.png rename to assets/lumbers/lumbers_water_floor2.png diff --git a/assets/lumbers/water_floor3.png b/assets/lumbers/lumbers_water_floor3.png similarity index 100% rename from assets/lumbers/water_floor3.png rename to assets/lumbers/lumbers_water_floor3.png diff --git a/assets/lumbers/water_floor4.png b/assets/lumbers/lumbers_water_floor4.png similarity index 100% rename from assets/lumbers/water_floor4.png rename to assets/lumbers/lumbers_water_floor4.png diff --git a/assets/lumbers/water_floor_b1.png b/assets/lumbers/lumbers_water_floor_b1.png similarity index 100% rename from assets/lumbers/water_floor_b1.png rename to assets/lumbers/lumbers_water_floor_b1.png diff --git a/assets/lumbers/water_floor_b2.png b/assets/lumbers/lumbers_water_floor_b2.png similarity index 100% rename from assets/lumbers/water_floor_b2.png rename to assets/lumbers/lumbers_water_floor_b2.png diff --git a/assets/lumbers/water_floor_b3.png b/assets/lumbers/lumbers_water_floor_b3.png similarity index 100% rename from assets/lumbers/water_floor_b3.png rename to assets/lumbers/lumbers_water_floor_b3.png diff --git a/assets/lumbers/water_floor_b4.png b/assets/lumbers/lumbers_water_floor_b4.png similarity index 100% rename from assets/lumbers/water_floor_b4.png rename to assets/lumbers/lumbers_water_floor_b4.png diff --git a/assets/lumbers/secret_swadgeland_18.png b/assets/lumbers/secret_swadgeland_18.png deleted file mode 100644 index 4446cda3a21fd9652bb7f29147d28f6a5e6ec402..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1091 zcmds#zf0Cp6vmH9W{RK%f$|OoP0qN1U)SNws<%bQI#6w$${qMV`{Ec=N=(a@P% zT!N5jXf=aeIz%Z&v_wHe7+66VEvL`@{uy0(-^=0N`<&17obRp1*kD&jUx$cv4G-0u z>|4vPy_Ns^?CnLimJ7|newlk+`zEsPW@B`GAj^tO&$LX9H#Tkv!Mj9<1OEFYxmbt6D6o0g( zGILWmDR!aYP|a0c1@}O4*Tr1a1$*QHCa;MD|3KgnYQ%tslB;mg7;U7{l9F6Gre>*` zlpyg(TPjskAy@1|!J&zokRwSG09;%rXxtJdd4S1l;(!UmID{H8pm_-v95hB7X(=Nr zw>hR}2@@ko{Lz+5`CO{6q1dek%tXsPt05JrD)%zpD$2rGrBkL|87|0`hcf&Mt2n4S zA&nMOB0N0Ns`K`yk8B?%n`1}l`(Lh+_dmYlaeBCZXngO?yQPJm=iS}w8#{(J|9$&% ze&yt`#?@C_yl1rg>Al1D>#RNOy)<(4b8Yt>c`&nZcVo}Jk&@w;gDy|K2-w zeW$EG8aaNsb7@b@v)aLxGxP1Tx^m-U>*KD4uh(`>eAzO4YVlCt{}XhYg0UuuZ4pg6gBI*1gtIJnq=5UYYN z;vq$lx>g)2MVD5g4jwLwsDnC)A}H2b==t3D&+vuh<#^xsxzF?5_gcMHF66i5iKtMm zlp5H3;+M#iR}ZLRvq=#a-UcXbzccBiP!+|*6n*p1>)%~f5+ zm0cxsrEFKjHCuwKO=o|K`Itk2|jP ztQk0x9Jn*q{iJe#>+y-rXZokVw!hukzVP|m)cp3vgAdBXNv8BNvv*?mmqQy`ZLLo) zZvD+Z{j(#NxxFy9YQ@s`j;YRb=X1qZC$>Fm-ka+hNS>cMOx=5i>C$YLHjOM_T{nOE v?D*;W;0H;@Z_KUj>-*L0%paT0?fU&}W$(Vi#!A06?*faeL$%UO@nrKK@7rh# diff --git a/assets/lumbers/secret_swadgeland_20.png b/assets/lumbers/secret_swadgeland_20.png deleted file mode 100644 index a8ca081d708a98758f6cc668b111ba2abb1af62c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1094 zcmds#ziZQB5XMg%G_(yBL68z^=%BPJKD3J#+@fvY}35MYi)DQzS zUIGgoXbf#gQ;aBX;}|s-VPXgp{?HZ`<8w*BhOnCs7!!?orb7y-H1`;98f7r1>BO{C z!-1T7h~cML;UMh z!eH_)bGG%hb7|+ZF4dbyFZ`MxyLG=XHv0R)_vNL{pN$)Pn{Sd`n)IVo{T?vogZAg_F=YkGyiw# r;m3p7tIy@kiE{Do$k3}Ft&M+k`%WzkPq%w(d%#4M$!gLm&$qS!Ley%a diff --git a/assets/lumbers/secret_swadgeland_21.png b/assets/lumbers/secret_swadgeland_21.png deleted file mode 100644 index f3243941b88bd40491b4a178d25036cf2a3a2b85..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1087 zcmds#PfOKN5QZnCGV?}65Qs>dTto;m1fc|KS4;^@a}^f0nN_thTC~yJXjT+ai&;bw zwQ=Dt6KYW*1~F6=*dN*iK?W_VFEBml_c1zf?_oISyz{*8{H`1y9;h|7G>J%U@JM}> zeNXu{ZsfoIaDJ6-!{q2dpDey<{VCEgcl_vBf0h-Qo@tqyDW!_Y@C?h)3@L{m>7H)s znl9z8MVhBsnx;v4s*&ocma3_OQc9$Filt}@1=>iX#ba(u=~I?RScFDMX-nlEZs8g( zg@Qx#FbmT#DNx*154BJY6&QIM;vp8IA#{ZrF`%IYi!&OdjWk+3mSU*XEOS?PDgJ0n zW#*=CQtU#(p_;3@3hsg8u8X;-3--tZOkNWQ{(-rXCind)rcy>RVzL*MVVp@xy3r~7Yil~c8m-eYrXJ}C0V9L`!}Z0!iJ5p2p, esp_now_info->src_addr, (const uint8_t*)data, len, rssi); } @@ -311,7 +311,8 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) if (payload[0] == ATTACK_MSG) { - lumberjackOnReceiveAttack(payload); + ESP_LOGI(LUM_TAG, "Incoming attack!"); + lumberjackOnReceiveAttack(payload, len); } if (payload[0] == SCORE_MSG) diff --git a/main/modes/lumberjack/lumberjackEntity.c b/main/modes/lumberjack/lumberjackEntity.c index c54e4feb4..29dc730e4 100644 --- a/main/modes/lumberjack/lumberjackEntity.c +++ b/main/modes/lumberjack/lumberjackEntity.c @@ -15,6 +15,7 @@ void lumberjackSetupEnemy(lumberjackEntity_t* enemy, int character) enemy->cW = 15; enemy->cH = 15; enemy->submergedTimer = 0; + enemy->queueable = true; lumberjackUpdateEnemy(enemy, character); } diff --git a/main/modes/lumberjack/lumberjackEntity.h b/main/modes/lumberjack/lumberjackEntity.h index 6b8423f69..0b3e2ca5a 100644 --- a/main/modes/lumberjack/lumberjackEntity.h +++ b/main/modes/lumberjack/lumberjackEntity.h @@ -8,6 +8,7 @@ typedef struct bool flipped; bool onGround; bool active; + bool queueable; bool flying; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 38cfbfbbc..9aa6e5943 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -140,32 +140,32 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) if (lumv->lumberjackMain->networked) loadWsg("lumbers_game_over_win.wsg", &lumv->gamewinSprite, true); //ESP_LOGI(LUM_TAG, "Loading floor Tiles"); - loadWsg("bottom_floor1.wsg", &lumv->floorTiles[0], true); - loadWsg("bottom_floor2.wsg", &lumv->floorTiles[1], true); - loadWsg("bottom_floor3.wsg", &lumv->floorTiles[2], true); - loadWsg("bottom_floor4.wsg", &lumv->floorTiles[3], true); - loadWsg("bottom_floor5.wsg", &lumv->floorTiles[4], true); - loadWsg("bottom_floor6.wsg", &lumv->floorTiles[5], true); - loadWsg("bottom_floor7.wsg", &lumv->floorTiles[6], true); - loadWsg("bottom_floor8.wsg", &lumv->floorTiles[7], true); - loadWsg("bottom_floor9.wsg", &lumv->floorTiles[8], true); - loadWsg("bottom_floor10.wsg", &lumv->floorTiles[9], true); + loadWsg("lumbers_bottom_floor1.wsg", &lumv->floorTiles[0], true); + loadWsg("lumbers_bottom_floor2.wsg", &lumv->floorTiles[1], true); + loadWsg("lumbers_bottom_floor3.wsg", &lumv->floorTiles[2], true); + loadWsg("lumbers_bottom_floor4.wsg", &lumv->floorTiles[3], true); + loadWsg("lumbers_bottom_floor5.wsg", &lumv->floorTiles[4], true); + loadWsg("lumbers_bottom_floor6.wsg", &lumv->floorTiles[5], true); + loadWsg("lumbers_bottom_floor7.wsg", &lumv->floorTiles[6], true); + loadWsg("lumbers_bottom_floor8.wsg", &lumv->floorTiles[7], true); + loadWsg("lumbers_bottom_floor9.wsg", &lumv->floorTiles[8], true); + loadWsg("lumbers_bottom_floor10.wsg", &lumv->floorTiles[9], true); loadWsg("lumbers_itemused_block.wsg", &lumv->floorTiles[10], true); loadWsg("lumbers_rtile_1.wsg", &lumv->floorTiles[11], true); //ESP_LOGI(LUM_TAG, "Loading Animation Tiles"); - loadWsg("water_floor1.wsg", &lumv->animationTiles[0], true); - loadWsg("water_floor2.wsg", &lumv->animationTiles[1], true); - loadWsg("water_floor3.wsg", &lumv->animationTiles[2], true); - loadWsg("water_floor4.wsg", &lumv->animationTiles[3], true); - loadWsg("water_floor0.wsg", &lumv->animationTiles[4], true); - loadWsg("water_floor0.wsg", &lumv->animationTiles[5], true); - loadWsg("water_floor0.wsg", &lumv->animationTiles[6], true); - loadWsg("water_floor0.wsg", &lumv->animationTiles[7], true); - loadWsg("water_floor_b1.wsg", &lumv->animationTiles[8], true); - loadWsg("water_floor_b2.wsg", &lumv->animationTiles[9], true); - loadWsg("water_floor_b3.wsg", &lumv->animationTiles[10], true); - loadWsg("water_floor_b4.wsg", &lumv->animationTiles[11], true); + loadWsg("lumbers_water_floor1.wsg", &lumv->animationTiles[0], true); + loadWsg("lumbers_water_floor2.wsg", &lumv->animationTiles[1], true); + loadWsg("lumbers_water_floor3.wsg", &lumv->animationTiles[2], true); + loadWsg("lumbers_water_floor4.wsg", &lumv->animationTiles[3], true); + loadWsg("lumbers_water_floor0.wsg", &lumv->animationTiles[4], true); + loadWsg("lumbers_water_floor0.wsg", &lumv->animationTiles[5], true); + loadWsg("lumbers_water_floor0.wsg", &lumv->animationTiles[6], true); + loadWsg("lumbers_water_floor0.wsg", &lumv->animationTiles[7], true); + loadWsg("lumbers_water_floor_b1.wsg", &lumv->animationTiles[8], true); + loadWsg("lumbers_water_floor_b2.wsg", &lumv->animationTiles[9], true); + loadWsg("lumbers_water_floor_b3.wsg", &lumv->animationTiles[10], true); + loadWsg("lumbers_water_floor_b4.wsg", &lumv->animationTiles[11], true); loadWsg("lumbers_rtile_1.wsg", &lumv->animationTiles[12], true); loadWsg("lumbers_rtile_2.wsg", &lumv->animationTiles[13], true); loadWsg("lumbers_rtile_3.wsg", &lumv->animationTiles[14], true); @@ -178,7 +178,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) //ESP_LOGI(LUM_TAG, "*Loading character icons"); loadWsg("lumbers_red_lives.wsg", &lumv->minicharacters[0], true); loadWsg("lumbers_green_lives.wsg", &lumv->minicharacters[1], true); - loadWsg("secret_swadgeland_lives.wsg", &lumv->minicharacters[2], true); + loadWsg("lumbers_secret_swadgeland_lives.wsg", &lumv->minicharacters[2], true); loadWsg("lumbers_cho_lives.wsg", &lumv->minicharacters[3], true); //ESP_LOGI(LUM_TAG, "*Loading character sprites"); @@ -231,24 +231,24 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) else if (characterIndex == 2) { - loadWsg("secret_swadgeland_1.wsg", &lumv->playerSprites[0], true); - loadWsg("secret_swadgeland_2.wsg", &lumv->playerSprites[1], true); - loadWsg("secret_swadgeland_3.wsg", &lumv->playerSprites[2], true); - loadWsg("secret_swadgeland_4.wsg", &lumv->playerSprites[3], true); - loadWsg("secret_swadgeland_5.wsg", &lumv->playerSprites[4], true); - loadWsg("secret_swadgeland_6.wsg", &lumv->playerSprites[5], true); - loadWsg("secret_swadgeland_7.wsg", &lumv->playerSprites[6], true); - loadWsg("secret_swadgeland_8.wsg", &lumv->playerSprites[7], true); - loadWsg("secret_swadgeland_9.wsg", &lumv->playerSprites[8], true); - loadWsg("secret_swadgeland_10.wsg", &lumv->playerSprites[9], true); - loadWsg("secret_swadgeland_11.wsg", &lumv->playerSprites[10], true); - loadWsg("secret_swadgeland_12.wsg", &lumv->playerSprites[11], true); - loadWsg("secret_swadgeland_13.wsg", &lumv->playerSprites[12], true); - loadWsg("secret_swadgeland_14.wsg", &lumv->playerSprites[13], true); - loadWsg("secret_swadgeland_15.wsg", &lumv->playerSprites[14], true); - loadWsg("secret_swadgeland_16.wsg", &lumv->playerSprites[15], true); - loadWsg("secret_swadgeland_17.wsg", &lumv->playerSprites[16], true); - loadWsg("secret_swadgeland_22.wsg", &lumv->playerSprites[17], true); + loadWsg("lumbers_secret_swadgeland_1.wsg", &lumv->playerSprites[0], true); + loadWsg("lumbers_secret_swadgeland_2.wsg", &lumv->playerSprites[1], true); + loadWsg("lumbers_secret_swadgeland_3.wsg", &lumv->playerSprites[2], true); + loadWsg("lumbers_secret_swadgeland_4.wsg", &lumv->playerSprites[3], true); + loadWsg("lumbers_secret_swadgeland_5.wsg", &lumv->playerSprites[4], true); + loadWsg("lumbers_secret_swadgeland_6.wsg", &lumv->playerSprites[5], true); + loadWsg("lumbers_secret_swadgeland_7.wsg", &lumv->playerSprites[6], true); + loadWsg("lumbers_secret_swadgeland_8.wsg", &lumv->playerSprites[7], true); + loadWsg("lumbers_secret_swadgeland_9.wsg", &lumv->playerSprites[8], true); + loadWsg("lumbers_secret_swadgeland_10.wsg", &lumv->playerSprites[9], true); + loadWsg("lumbers_secret_swadgeland_11.wsg", &lumv->playerSprites[10], true); + loadWsg("lumbers_secret_swadgeland_12.wsg", &lumv->playerSprites[11], true); + loadWsg("lumbers_secret_swadgeland_13.wsg", &lumv->playerSprites[12], true); + loadWsg("lumbers_secret_swadgeland_14.wsg", &lumv->playerSprites[13], true); + loadWsg("lumbers_secret_swadgeland_15.wsg", &lumv->playerSprites[14], true); + loadWsg("lumbers_secret_swadgeland_16.wsg", &lumv->playerSprites[15], true); + loadWsg("lumbers_secret_swadgeland_17.wsg", &lumv->playerSprites[16], true); + loadWsg("lumbers_secret_swadgeland_22.wsg", &lumv->playerSprites[17], true); lumv->invincibleColor = c305; } @@ -471,13 +471,13 @@ bool lumberjackLoadLevel() lumv->enemy6Count = (int) buffer[6]; lumv->enemy7Count = (int) buffer[7]; lumv->enemy8Count = (int) buffer[8]; - ESP_LOGI(LUM_TAG, "Enemy count %d", lumv->enemy4Count); + if (lumv->enemy4Count > 1) lumv->enemy4Count = 1; //Only one ghost lumv->totalEnemyCount = lumv->enemy1Count; lumv->totalEnemyCount += lumv->enemy2Count; lumv->totalEnemyCount += lumv->enemy3Count; - //lumv->totalEnemyCount += lumv->enemy4Count; //Ghost don't count + //Ghost don't count lumv->totalEnemyCount += lumv->enemy5Count; lumv->totalEnemyCount += lumv->enemy6Count; lumv->totalEnemyCount += lumv->enemy7Count; @@ -572,29 +572,91 @@ void lumberjackSetupLevel(int characterIndex) //Load enemies // START ENEMY 1 - for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy1Count; eSpawnIndex++) + if (false == lumv->lumberjackMain->networked) { - lumv->enemy[eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); - lumberjackSetupEnemy(lumv->enemy[eSpawnIndex], 0); - } + for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy1Count; eSpawnIndex++) + { + lumv->enemy[eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[eSpawnIndex], 0); + } + offset += lumv->enemy1Count; + } + else + { + for (int eSpawnIndex = 0; eSpawnIndex < 4; eSpawnIndex++) + { + lumv->enemy[eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[eSpawnIndex], 0); + + if (eSpawnIndex >= lumv->enemy1Count) + { + lumv->enemy[eSpawnIndex]->queueable = false; + } + } - offset += lumv->enemy1Count; - for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy2Count; eSpawnIndex++) + offset += 4; + } + + + if (false == lumv->lumberjackMain->networked) { - lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); - lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 1); + for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy2Count; eSpawnIndex++) + { + lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 1); + } + + offset += lumv->enemy2Count; } + else + { + for (int eSpawnIndex = 0; eSpawnIndex < 8; eSpawnIndex++) + { + lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 1); - offset += lumv->enemy2Count; - for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy3Count; eSpawnIndex++) + if (eSpawnIndex >= lumv->enemy2Count) + { + lumv->enemy[offset + eSpawnIndex]->queueable = false; + } + } + + offset += 8; + } + + + + if (false == lumv->lumberjackMain->networked) { - lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); - lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 2); - } + for (int eSpawnIndex = 0; eSpawnIndex < lumv->enemy3Count; eSpawnIndex++) + { + lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 2); + } + + offset += lumv->enemy3Count; + } + else + { + for (int eSpawnIndex = 0; eSpawnIndex < 8; eSpawnIndex++) + { + lumv->enemy[offset + eSpawnIndex] = calloc(1, sizeof(lumberjackEntity_t)); + lumberjackSetupEnemy(lumv->enemy[offset + eSpawnIndex], 2); + + if (eSpawnIndex >= lumv->enemy3Count) + { + lumv->enemy[offset + eSpawnIndex]->queueable = false; + } + } + + offset += 8; + + } + + //END ENEMY 1 - offset += lumv->enemy3Count; //GHOST if (lumv->enemy4Count > 0) @@ -866,7 +928,19 @@ void baseMode(int64_t elapsedUs) if (lumv->comboTime < 0) { lumv->comboTime = 0; - ESP_LOGI(LUM_TAG, "Combo end!"); + ESP_LOGI(LUM_TAG, "Combo end! %d", lumv->comboAmount); + + + if (lumv->lumberjackMain->networked && lumv->comboAmount > 0) + { + + lumberjackSendAttack(lumv->attackQueue); + + for (int i = 0; i < ARRAY_SIZE(lumv->attackQueue); i++) + { + lumv->attackQueue[i] = 0; + } + } lumv->comboAmount = 0; } @@ -882,6 +956,15 @@ void baseMode(int64_t elapsedUs) if (!attackThisFrame && lumv->localPlayer->attackPressed) { ESP_LOGI(LUM_TAG, "Attack this frame!"); + int x = 0; + for (int i = 0; i < 32; i ++) + { + if (lumv->enemy[i] != NULL && lumv->enemy[i]->type == 2 && lumv->enemy[i]->queueable) + { + x++; + } + } + ESP_LOGI(LUM_TAG, "%d", x); //lumberjackSendAttack(lumv->attackQueue); @@ -1142,12 +1225,18 @@ void baseMode(int64_t elapsedUs) currentBonus->time = 0; currentBonus->bonusAmount = lumv->comboAmount + 1; + if (lumv->lumberjackMain->networked) { lumv->attackQueue[enemy->type]++; } } + if (lumv->lumberjackMain->networked) + { + lumv->attackQueue[enemy->type]++; + } + lumv->score += enemy->scoreValue * (lumv->comboAmount + 1); if (lumv->lumberjackMain->networked) @@ -1175,12 +1264,26 @@ void baseMode(int64_t elapsedUs) { for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) { - if (lumv->enemy[i] == NULL) continue; + if (lumv->enemy[i] == NULL || lumv->enemy[i]->state != LUMBERJACK_DEAD || lumv->enemy[i]->queueable == false) continue; lumv->enemy[i]->state = LUMBERJACK_RUN; lumberjackResetEnemy(lumv->enemy[i]); lumberjackUpdateEnemy(lumv->enemy[i], lumv->enemy[i]->type+1); } + + lumv->enemyKillCount = 0; + + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + { + if (lumv->enemy[i] == NULL) continue; + if (lumv->enemy[i]->queueable == false) + { + lumv->enemy[i]->queueable = true; + lumv->totalEnemyCount++; + break; + } + + } } else { @@ -1673,7 +1776,7 @@ bool lumberjackSpawnCheck(int64_t elapseUs) { for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) { - if (lumv->enemy[enemyIndex] == NULL) + if (lumv->enemy[enemyIndex] == NULL || lumv->enemy[enemyIndex]->queueable == false) continue; if (lumv->enemy[enemyIndex]->ready && lumv->enemy[enemyIndex]->state != LUMBERJACK_DEAD) @@ -1718,11 +1821,11 @@ bool lumberjackSpawnCheck(int64_t elapseUs) return spawnReady; } -void lumberjackOnReceiveAttack(const uint8_t* attack) +void lumberjackOnReceiveAttack(const uint8_t* attack, int len) { + ESP_LOGI(LUM_TAG, "Being attacked %ld", sizeof(attack)); if (lumv->gameType == LUMBERJACK_MODE_PANIC) { -// ESP_LOGI(LUM_TAG, "Being attacked %ld", sizeof(attack)); lumv->waterDirection = -1; //Even if it is draining lumv->waterSpeed -= 5; @@ -1734,7 +1837,34 @@ void lumberjackOnReceiveAttack(const uint8_t* attack) if (lumv->gameType == LUMBERJACK_MODE_ATTACK) { - + for (int i = 1; i < len; i++) + { + ESP_LOGI(LUM_TAG, "Attacky! %d) %d", i, attack[i]); + int rem = attack[i]; + for (int n = 0; n < ARRAY_SIZE(lumv->enemy); n++) + { + if (rem <= 0) break; + + if (lumv->enemy[n] == NULL || lumv->enemy[n]->queueable) continue; + + if (lumv->enemy[n]->type == i - 1) + { + lumv->enemy[n]->queueable = true; + rem--; + } + } + } + + lumv->totalEnemyCount = 0; + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + { + if (lumv->enemy[i] == NULL) continue; + + if (lumv->enemy[i]->queueable) + { + lumv->totalEnemyCount++; + } + } } } diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index e601c941b..4026f9cb3 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -29,7 +29,7 @@ void baseMode(int64_t elapsedUs); void lumberjackSendAttack(uint8_t* number); void lumberjackSendScore(int score); -void lumberjackOnReceiveAttack(const uint8_t* attack); +void lumberjackOnReceiveAttack(const uint8_t* attack, int len); void lumberjackOnReceiveScore(const uint8_t* score); void lumberjackOnReceiveDeath(bool gameover); void lumberjackGameReady(void); From 9aab5812d3b0be6bf6d9fe7a1c5a75ee745e7867 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 11 Nov 2023 16:37:36 -0800 Subject: [PATCH 34/54] Additional multiplayer tweaks Fixed bonus not showing over x9 Enemy Upgrade in multiplayer bumps opponent and removes their item Added 0 character for bonus Added Connection lost for multiplayer games that lag out. --- assets/lumbers/lumbers_bonus_0.png | Bin 0 -> 144 bytes assets/lumbers/lumbers_conn_lost.png | Bin 0 -> 441 bytes main/modes/lumberjack/lumberjack.c | 31 ++++--- main/modes/lumberjack/lumberjack.h | 6 +- main/modes/lumberjack/lumberjackGame.c | 119 ++++++++++++++++++++++--- main/modes/lumberjack/lumberjackGame.h | 8 +- 6 files changed, 139 insertions(+), 25 deletions(-) create mode 100644 assets/lumbers/lumbers_bonus_0.png create mode 100644 assets/lumbers/lumbers_conn_lost.png diff --git a/assets/lumbers/lumbers_bonus_0.png b/assets/lumbers/lumbers_bonus_0.png new file mode 100644 index 0000000000000000000000000000000000000000..aa1a46a77e04a8dae0c8adc9ad7d1dc83d7b23f4 GIT binary patch literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|ygXeTLnNk_ z_B--5IB+m8KPLY%`o2p3D)yd8#oOGPJSH8JaxbfLGWMm;5L#`&`gWLj{g=&!{};1e q2o=08cOhEVaQ}%b>Px$b4f%&RA_X97pX|+74q|epGjJHL8{CsZdCySMziLv6F`TsE@zI<^A?~t7SUk5F>mInd5xmkUt zE_Y0;{E0sz4*!q%DO_V)`L#Su{VshP$NK+ptIJ^SutlD$`*}+JPs!Z*duaOf{C2G6 ziLYq>#!-Dq{aPvncxNIJ{&A`L-_p;Du=TV3M*IJC6x|HwvBK(8ZKsQUI;@`~QS*9r zZR&{u0@#hyZD7~QEYmi1r`eg=_(i#1V^{0Mz3a1ic3>$55u>TKi(;+mMxs{zjv2QJ zv-+9)?pIUdf9rog7K_vA*3|6dQsVbJ!tklh%KguzV&&w9!oEdnA-1hSaGaBEIs2t(W4;m jS&UZK9sFeLFCOn7r$X0&4p2p, testMsg, ARRAY_SIZE(testMsg), lumberjackMsgTxCbFn); - } - else - { - const uint8_t testMsg[] = {0x01, 0x02, 0x03, 0x04}; - p2pSendMsg(&lumberjack->p2p, testMsg, ARRAY_SIZE(testMsg), lumberjackMsgTxCbFn); - }*/ - p2pSendMsg(&lumberjack->p2p, payload, sizeof(payload), lumberjackMsgTxCbFn); lumberjackGameReady(); } @@ -292,6 +281,8 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) // Do anything ESP_LOGI(LUM_TAG, "Ya boi got something! %d", (uint8_t)payload[0]); + lumberjackQualityCheck(); + if (len > 0) { if (payload[0] == VERSION_MSG) @@ -320,6 +311,11 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) lumberjackOnReceiveScore(payload); } + if (payload[0] == BUMP_MSG) + { + lumberjackOnReceiveBump(); + } + if (payload[0] == DEATH_MSG) { ESP_LOGI(LUM_TAG, "Playher died!"); @@ -363,6 +359,15 @@ void lumberjackSendAttack(uint8_t* number) } } +void lumberjackSendBump(void) +{ + if (lumberjack->networked) + { + uint8_t payload[1] = {BUMP_MSG}; + p2pSendMsg(&lumberjack->p2p, payload, ARRAY_SIZE(payload), lumberjackMsgTxCbFn); + } +} + void lumberjackSendScore(int score) { if (lumberjack->networked) diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index ef4efb73c..e3ede8671 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -142,6 +142,9 @@ typedef struct uint8_t attackQueue[8]; uint8_t receiveQueue[8]; + int wakeupSignal; + int lastResponseSignal; + wsg_t floorTiles[20]; wsg_t animationTiles[20]; wsg_t minicharacters[4]; @@ -156,6 +159,7 @@ typedef struct wsg_t subtitle_white; wsg_t gameoverSprite; wsg_t gamewinSprite; + wsg_t connectLostSprite; lumberjackTile_t* tile; @@ -166,7 +170,7 @@ typedef struct wsg_t enemySprites[37]; wsg_t playerSprites[18]; - wsg_t bonusSprites[10]; + wsg_t bonusSprites[11]; wsg_t ui[6]; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 9aa6e5943..9678c5505 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -109,7 +109,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->itemBlockAnimationTime = 0; lumv->itemBlockItemFrame = 0; - lumv->itemBlockIndex = -1; + lumv->itemBlockIndex = -1; lumv->itemBlockItemAnimation = 0; //ESP_LOGI(LUM_TAG, "Load Title"); @@ -137,7 +137,11 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) } loadWsg("lumbers_game_over.wsg", &lumv->gameoverSprite, true); - if (lumv->lumberjackMain->networked) loadWsg("lumbers_game_over_win.wsg", &lumv->gamewinSprite, true); + if (lumv->lumberjackMain->networked) + { + loadWsg("lumbers_game_over_win.wsg", &lumv->gamewinSprite, true); + loadWsg("lumbers_conn_lost.wsg", &lumv->connectLostSprite, true); + } //ESP_LOGI(LUM_TAG, "Loading floor Tiles"); loadWsg("lumbers_bottom_floor1.wsg", &lumv->floorTiles[0], true); @@ -339,7 +343,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_normal_ax_block6.wsg", &lumv->unusedBlockSprite[5], true); loadWsg("lumbers_normal_ax_block7.wsg", &lumv->unusedBlockSprite[6], true); - loadWsg("lumbers_bonus_x.wsg", &lumv->bonusSprites[0], true); + loadWsg("lumbers_bonus_0.wsg", &lumv->bonusSprites[0], true); loadWsg("lumbers_bonus_1.wsg", &lumv->bonusSprites[1], true); loadWsg("lumbers_bonus_2.wsg", &lumv->bonusSprites[2], true); loadWsg("lumbers_bonus_3.wsg", &lumv->bonusSprites[3], true); @@ -349,6 +353,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_bonus_7.wsg", &lumv->bonusSprites[7], true); loadWsg("lumbers_bonus_8.wsg", &lumv->bonusSprites[8], true); loadWsg("lumbers_bonus_9.wsg", &lumv->bonusSprites[9], true); + loadWsg("lumbers_bonus_x.wsg", &lumv->bonusSprites[10], true); loadWsg("lumbers_item_ui.wsg", &lumv->ui[0], true); @@ -547,6 +552,8 @@ void lumberjackSetupLevel(int characterIndex) lumv->comboTime = 0; lumv->comboAmount = 0; lumv->hasWon = false; + lumv->wakeupSignal = 0; + lumv->lastResponseSignal = 1000; ESP_LOGI(LUM_TAG, "LOADING LEVEL"); lumberjackLoadLevel(); @@ -808,6 +815,28 @@ void lumberjackGameLoop(int64_t elapsedUs) baseMode(elapsedUs); + if (lumv->lumberjackMain->networked && lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) + { + //Check for connection lost + lumv->wakeupSignal -= elapsedUs/10000; + lumv->lastResponseSignal -= elapsedUs/10000; + + if (lumv->wakeupSignal < 0) + { + lumv->wakeupSignal = 100; + lumberjackSendScore(lumv->score); //Send score just to ping + + } + + if (lumv->lastResponseSignal <= 0) + { + ESP_LOGI(LUM_TAG, "Connection lost!"); + lumv->gameState = LUMBERJACK_GAMESTATE_GAMEOVER; + lumv->transitionTimer = 500; + lumv->localPlayer->state = LUMBERJACK_DEAD; + } + } + if (lumv->gameState == LUMBERJACK_GAMESTATE_GAMEOVER) { lumv->transitionTimer -= elapsedUs/10000; @@ -1015,8 +1044,11 @@ void baseMode(int64_t elapsedUs) enemy->vy = -20; lumberjackUpdateEnemy(enemy, enemy->type + 1); } + } - + if (lumv->lumberjackMain->networked) + { + lumberjackSendBump(); } } @@ -1088,7 +1120,12 @@ void baseMode(int64_t elapsedUs) // Check spawn bool spawnedEnemy = false; - if (false == lumv->hasWon) spawnedEnemy = lumberjackSpawnCheck(elapsedUs); + //if (false == lumv->hasWon) spawnedEnemy = lumberjackSpawnCheck(elapsedUs); + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING && !lumv->hasWon) + { + spawnedEnemy = lumberjackSpawnCheck(elapsedUs); + } + if (spawnedEnemy) { @@ -1267,8 +1304,11 @@ void baseMode(int64_t elapsedUs) if (lumv->enemy[i] == NULL || lumv->enemy[i]->state != LUMBERJACK_DEAD || lumv->enemy[i]->queueable == false) continue; lumv->enemy[i]->state = LUMBERJACK_RUN; - lumberjackResetEnemy(lumv->enemy[i]); - lumberjackUpdateEnemy(lumv->enemy[i], lumv->enemy[i]->type+1); + if (lumv->enemy[i]->active == false && lumv->enemy[i]->state == LUMBERJACK_OFFSCREEN) + { + lumberjackResetEnemy(lumv->enemy[i]); + lumberjackUpdateEnemy(lumv->enemy[i], lumv->enemy[i]->type+1); + } } lumv->enemyKillCount = 0; @@ -1599,8 +1639,14 @@ void DrawGame(void) if (lumv->gameState == LUMBERJACK_GAMESTATE_GAMEOVER) { - if (lumv->hasWon) + if (lumv->lumberjackMain->networked && lumv->lastResponseSignal <= 0) { + + drawWsgSimple(&lumv->connectLostSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); + + } else if (lumv->hasWon) + { + ESP_LOGI(LUM_TAG, "%d lrs", lumv->lastResponseSignal); drawWsgSimple(&lumv->gamewinSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); } else @@ -1642,10 +1688,22 @@ void DrawGame(void) if (offsetTime > 1) offsetTime = 1; - drawWsgSimple(&lumv->bonusSprites[0], currentBonus->x, currentBonus->y - lumv->yOffset - (20 - (20 * offsetTime))); + drawWsgSimple(&lumv->bonusSprites[10], currentBonus->x, currentBonus->y - lumv->yOffset - (20 - (20 * offsetTime))); if (currentBonus->bonusAmount < 10) { drawWsgSimple(&lumv->bonusSprites[currentBonus->bonusAmount], currentBonus->x+8, currentBonus->y - lumv->yOffset - (20 - (20 * offsetTime))); + } + else + { + int tenDigit = (int)(currentBonus->bonusAmount / 10); + if (tenDigit > 9) tenDigit = 9; + int oneDigit = currentBonus->bonusAmount % 10; + + drawWsgSimple(&lumv->bonusSprites[tenDigit], currentBonus->x+8, currentBonus->y - lumv->yOffset - (20 - (20 * offsetTime))); + drawWsgSimple(&lumv->bonusSprites[oneDigit], currentBonus->x+16, currentBonus->y - lumv->yOffset - (20 - (20 * offsetTime))); + + + } //currentBonus->time += ; @@ -1821,6 +1879,12 @@ bool lumberjackSpawnCheck(int64_t elapseUs) return spawnReady; } +void lumberjackQualityCheck() +{ + lumv->wakeupSignal = 100; + lumv->lastResponseSignal = 1000; +} + void lumberjackOnReceiveAttack(const uint8_t* attack, int len) { ESP_LOGI(LUM_TAG, "Being attacked %ld", sizeof(attack)); @@ -1875,6 +1939,37 @@ void lumberjackOnReceiveScore(const uint8_t* score) lumv->highscore = locX; } +void lumberjackOnReceiveBump(void) +{ + ESP_LOGI(LUM_TAG, "BUMP!"); + if (lumv->localPlayer->onGround) + { + lumv->localPlayer->vy = -20; //HERE + + if (lumv->localPlayer->state == LUMBERJACK_DUCK) + { + lumv->localPlayer->vy = -40; + lumv->localPlayer->state = LUMBERJACK_BUMPED; + lumv->invincibleTimer = 0; + + if (lumv->ghost != NULL && lumv->ghost->active) + { + if (lumv->localPlayer->x < lumv->ghost->x + LUMBERJACK_GHOST_BOX && lumv->localPlayer->x + lumv->localPlayer->width > lumv->ghost->x + && lumv->localPlayer->y < lumv->ghost->y + LUMBERJACK_GHOST_BOX && lumv->localPlayer->y + lumv->localPlayer->height > lumv->ghost->y + ) + { + lumberjackOnLocalPlayerDeath(); + } + + } + } + + + } + + lumv->itemBlockIndex = -1; +} + void lumberjackOnReceiveDeath(bool gameover) { ESP_LOGI(LUM_TAG, "Player died! Haha %d", (gameover)); @@ -2606,7 +2701,11 @@ void lumberjackExitGameMode(void) freeWsg(&lumv->gameoverSprite); if (lumv->lumberjackMain->networked) - freeWsg(&lumv->gamewinSprite); + { + freeWsg(&lumv->gamewinSprite); + freeWsg(&lumv->connectLostSprite); + + } // Free the bonus diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 4026f9cb3..42534ba2e 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -26,16 +26,22 @@ void lumberjackScoreDisplay(int score, int locationX); void lumberjackTitleDisplayText(char* string, int locationX, int locationY); void baseMode(int64_t elapsedUs); + +void lumberjackQualityCheck(void); + void lumberjackSendAttack(uint8_t* number); void lumberjackSendScore(int score); +void lumberjackSendDeath(bool gameover); +void lumberjackSendBump(void); void lumberjackOnReceiveAttack(const uint8_t* attack, int len); void lumberjackOnReceiveScore(const uint8_t* score); void lumberjackOnReceiveDeath(bool gameover); +void lumberjackOnReceiveBump(void); + void lumberjackGameReady(void); void lumberjackPlayGame(void); void lumberjackSendGo(void); -void lumberjackSendDeath(bool gameover); void drawSolidWsg(const wsg_t* wsg, int16_t xOff, int16_t yOff, bool flipLR, bool flipUD, uint8_t inColor); From 049c1bd43964eb405343fc711f38a4a277a2b2e0 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 12 Nov 2023 00:49:38 -0800 Subject: [PATCH 35/54] Multiplayer bug fixes Shortened the swadgeland guys name Made swadgeland guy unlockable if you play swadgeland Made cho playable if you play magtroid Added high score table for each sub game Fixed the enemies being sent to work a bit better Stopped enemy respawning and auto killing player --- ...dgeland_1.png => lumbers_swadgeland_1.png} | Bin ...eland_10.png => lumbers_swadgeland_10.png} | Bin ...eland_11.png => lumbers_swadgeland_11.png} | Bin ...eland_12.png => lumbers_swadgeland_12.png} | Bin ...eland_13.png => lumbers_swadgeland_13.png} | Bin ...eland_14.png => lumbers_swadgeland_14.png} | Bin ...eland_15.png => lumbers_swadgeland_15.png} | Bin ...eland_16.png => lumbers_swadgeland_16.png} | Bin ...eland_17.png => lumbers_swadgeland_17.png} | Bin ...dgeland_2.png => lumbers_swadgeland_2.png} | Bin ...eland_22.png => lumbers_swadgeland_22.png} | Bin ...dgeland_3.png => lumbers_swadgeland_3.png} | Bin ...dgeland_4.png => lumbers_swadgeland_4.png} | Bin ...dgeland_5.png => lumbers_swadgeland_5.png} | Bin ...dgeland_6.png => lumbers_swadgeland_6.png} | Bin ...dgeland_7.png => lumbers_swadgeland_7.png} | Bin ...dgeland_8.png => lumbers_swadgeland_8.png} | Bin ...dgeland_9.png => lumbers_swadgeland_9.png} | Bin ...lives.png => lumbers_swadgeland_lives.png} | Bin main/modes/lumberjack/lumberjack.c | 79 ++++++-- main/modes/lumberjack/lumberjack.h | 13 +- main/modes/lumberjack/lumberjackGame.c | 188 ++++++++++-------- main/modes/lumberjack/lumberjackGame.h | 3 + 23 files changed, 185 insertions(+), 98 deletions(-) rename assets/lumbers/{lumbers_secret_swadgeland_1.png => lumbers_swadgeland_1.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_10.png => lumbers_swadgeland_10.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_11.png => lumbers_swadgeland_11.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_12.png => lumbers_swadgeland_12.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_13.png => lumbers_swadgeland_13.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_14.png => lumbers_swadgeland_14.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_15.png => lumbers_swadgeland_15.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_16.png => lumbers_swadgeland_16.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_17.png => lumbers_swadgeland_17.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_2.png => lumbers_swadgeland_2.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_22.png => lumbers_swadgeland_22.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_3.png => lumbers_swadgeland_3.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_4.png => lumbers_swadgeland_4.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_5.png => lumbers_swadgeland_5.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_6.png => lumbers_swadgeland_6.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_7.png => lumbers_swadgeland_7.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_8.png => lumbers_swadgeland_8.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_9.png => lumbers_swadgeland_9.png} (100%) rename assets/lumbers/{lumbers_secret_swadgeland_lives.png => lumbers_swadgeland_lives.png} (100%) diff --git a/assets/lumbers/lumbers_secret_swadgeland_1.png b/assets/lumbers/lumbers_swadgeland_1.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_1.png rename to assets/lumbers/lumbers_swadgeland_1.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_10.png b/assets/lumbers/lumbers_swadgeland_10.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_10.png rename to assets/lumbers/lumbers_swadgeland_10.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_11.png b/assets/lumbers/lumbers_swadgeland_11.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_11.png rename to assets/lumbers/lumbers_swadgeland_11.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_12.png b/assets/lumbers/lumbers_swadgeland_12.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_12.png rename to assets/lumbers/lumbers_swadgeland_12.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_13.png b/assets/lumbers/lumbers_swadgeland_13.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_13.png rename to assets/lumbers/lumbers_swadgeland_13.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_14.png b/assets/lumbers/lumbers_swadgeland_14.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_14.png rename to assets/lumbers/lumbers_swadgeland_14.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_15.png b/assets/lumbers/lumbers_swadgeland_15.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_15.png rename to assets/lumbers/lumbers_swadgeland_15.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_16.png b/assets/lumbers/lumbers_swadgeland_16.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_16.png rename to assets/lumbers/lumbers_swadgeland_16.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_17.png b/assets/lumbers/lumbers_swadgeland_17.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_17.png rename to assets/lumbers/lumbers_swadgeland_17.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_2.png b/assets/lumbers/lumbers_swadgeland_2.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_2.png rename to assets/lumbers/lumbers_swadgeland_2.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_22.png b/assets/lumbers/lumbers_swadgeland_22.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_22.png rename to assets/lumbers/lumbers_swadgeland_22.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_3.png b/assets/lumbers/lumbers_swadgeland_3.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_3.png rename to assets/lumbers/lumbers_swadgeland_3.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_4.png b/assets/lumbers/lumbers_swadgeland_4.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_4.png rename to assets/lumbers/lumbers_swadgeland_4.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_5.png b/assets/lumbers/lumbers_swadgeland_5.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_5.png rename to assets/lumbers/lumbers_swadgeland_5.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_6.png b/assets/lumbers/lumbers_swadgeland_6.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_6.png rename to assets/lumbers/lumbers_swadgeland_6.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_7.png b/assets/lumbers/lumbers_swadgeland_7.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_7.png rename to assets/lumbers/lumbers_swadgeland_7.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_8.png b/assets/lumbers/lumbers_swadgeland_8.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_8.png rename to assets/lumbers/lumbers_swadgeland_8.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_9.png b/assets/lumbers/lumbers_swadgeland_9.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_9.png rename to assets/lumbers/lumbers_swadgeland_9.png diff --git a/assets/lumbers/lumbers_secret_swadgeland_lives.png b/assets/lumbers/lumbers_swadgeland_lives.png similarity index 100% rename from assets/lumbers/lumbers_secret_swadgeland_lives.png rename to assets/lumbers/lumbers_swadgeland_lives.png diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index 36b57867e..cfcf97e12 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -31,16 +31,16 @@ static void lumberjackMsgTxCbFn(p2pInfo* p2p, messageStatus_t status, const uint static void lumberjackMenuCb(const char*, bool selected, uint32_t settingVal); +static void lumberjackLoadSave(void); static void lumberjackJoinGame(void); static bool lumberjackChoUnlocked(void); -static bool lumberjackSpecialUnlocked(void); +static bool lumberjackSwadgeGuyUnlocked(void); static const char lumberjackName[] = "Lumber Jack"; static const char lumberjackPanic[] = "Panic"; static const char lumberjackAttack[] = "Attack"; static const char lumberjackBack[] = "Back"; -// static const char lumberjackNone[] = "None"; static char lumberjackRedCharacter[] = "Character: Red"; static char lumberjackGreenCharacter[] = "Character: Green"; static char lumberjackSpecialCharacter[] = "Character: Guy"; @@ -50,7 +50,10 @@ static const char lumberjackMenuSinglePlayer[] = "Single Player"; static const char lumberjackMenuMultiPlayerHost[] = "Multi-Player"; static const char lumberjackMenuMultiPlayerClient[] = "Multi-Player Join"; +static const char lumberjackPlatformerUnlock[] = "pf_unlocks"; +static const char lumberjackChoUnlock[] = "ray"; const char* LUM_TAG = "LUM"; +const char LUMBERJACK_SAVE[] = "lumberjackdata"; swadgeMode_t lumberjackMode = { .modeName = lumberjackName, @@ -86,6 +89,8 @@ static void lumberjackEnterMode(void) // Allocate and clear all memory for the menu mode. lumberjack = calloc(1, sizeof(lumberjack_t)); + lumberjackLoadSave(); + loadFont("logbook.font", &lumberjack->logbook, false); lumberjack->menu = initMenu(lumberjackName, lumberjackMenuCb); @@ -109,12 +114,12 @@ static void lumberjackEnterMode(void) int characters = 2; - if (lumberjackChoUnlocked()) + if (lumberjack->save.choUnlocked) { characters++; } - if (lumberjackSpecialUnlocked()) + if (lumberjack->save.swadgeGuyUnlocked) { characters++; } @@ -126,12 +131,12 @@ static void lumberjackEnterMode(void) int index = 2; - if (lumberjackChoUnlocked()) + if (lumberjack->save.choUnlocked) { charactersArray[index++] = lumberjackChoCharacter; } - if (lumberjackSpecialUnlocked()) + if (lumberjack->save.swadgeGuyUnlocked) { charactersArray[index++] = lumberjackSpecialCharacter; } @@ -149,11 +154,53 @@ static void lumberjackEnterMode(void) // Unlockables ? Save data? } +static void lumberjackLoadSave(void) +{ + size_t len = sizeof(lumberjack->save); + readNvsBlob(LUMBERJACK_SAVE, &lumberjack->save, &len); + if (lumberjack->save.choUnlocked == false) + { + lumberjack->save.choUnlocked = lumberjackChoUnlocked(); + } + + if (lumberjack->save.swadgeGuyUnlocked == false) + { + lumberjack->save.swadgeGuyUnlocked = lumberjackSwadgeGuyUnlocked(); + } + //writeNvsBlob(breakoutNvsKey_scores, &(self->highScores), size); + + int highscore = lumberjack->save.highScore; + + if (highscore < 5000) + { + lumberjack->save.highScore = 5000; + } + + if (lumberjack->save.attackHighScore < 5000) + { + lumberjack->save.attackHighScore = 5000; + } + + if (lumberjack->save.panicHighScore < 5000) + { + lumberjack->save.panicHighScore = 5000; + } + + writeNvsBlob(LUMBERJACK_SAVE, &lumberjack->save, len); +} + +void lumberjackSaveSave(void) +{ + size_t len = sizeof(lumberjack->save); + writeNvsBlob(LUMBERJACK_SAVE, &lumberjack->save, len); +} + static void lumberjackJoinGame(void) { if (lumberjack->gameMode == LUMBERJACK_MODE_PANIC) { lumberjack->screen = LUMBERJACK_A; + lumberjack->save.highScore = lumberjack->save.panicHighScore; lumberjackStartGameMode(lumberjack, lumberjack->selected); return; } @@ -161,6 +208,7 @@ static void lumberjackJoinGame(void) if (lumberjack->gameMode == LUMBERJACK_MODE_ATTACK) { lumberjack->screen = LUMBERJACK_B; + lumberjack->save.highScore = lumberjack->save.attackHighScore; lumberjackStartGameMode(lumberjack, lumberjack->selected); return; } @@ -225,12 +273,14 @@ static void lumberjackBackgroundDrawCallback(int16_t x, int16_t y, int16_t w, in static bool lumberjackChoUnlocked() { - return true; + int32_t kei; + return readNvs32(lumberjackChoUnlock, &kei); } -static bool lumberjackSpecialUnlocked() +static bool lumberjackSwadgeGuyUnlocked() { - return true; + int32_t kei; + return readNvs32(lumberjackPlatformerUnlock, &kei); } //============================================================================== @@ -249,7 +299,7 @@ static void lumberjackEspNowRecvCb(const esp_now_recv_info_t* esp_now_info, cons static void lumberjackEspNowSendCb(const uint8_t* mac_addr, esp_now_send_status_t status) { - ESP_LOGI(LUM_TAG, "STATUS %d", status); + //ESP_LOGI(LUM_TAG, "STATUS %d", status); p2pSendCb(&lumberjack->p2p, mac_addr, status); } @@ -351,10 +401,7 @@ void lumberjackSendAttack(uint8_t* number) { uint8_t payload[9] = {ATTACK_MSG}; memcpy(&payload[1], number, 8); - for (int i = 0; i < ARRAY_SIZE(payload); i++) - { - ESP_LOGI(LUM_TAG, "SENDING %d) %d", i, payload[i]); - } + p2pSendMsg(&lumberjack->p2p, payload, ARRAY_SIZE(payload), lumberjackMsgTxCbFn); } } @@ -415,12 +462,10 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV if (label == lumberjackPanic) { - ESP_LOGI(LUM_TAG, "Panic"); lumberjack->gameMode = LUMBERJACK_MODE_PANIC; } else if (label == lumberjackAttack) { - ESP_LOGI(LUM_TAG, "Attack"); lumberjack->gameMode = LUMBERJACK_MODE_ATTACK; } @@ -476,12 +521,10 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV if (label == lumberjackPanic) { - ESP_LOGI(LUM_TAG, "Panic"); lumberjack->gameMode = LUMBERJACK_MODE_PANIC; } else if (label == lumberjackAttack) { - ESP_LOGI(LUM_TAG, "Attack"); lumberjack->gameMode = LUMBERJACK_MODE_ATTACK; } diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index e3ede8671..4e9ef1459 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -31,6 +31,15 @@ typedef enum LUMBERJACK_GAMESTATE_GAMEOVER } lumberjackGameState_t; +typedef struct +{ + int highScore; + int attackHighScore; + int panicHighScore; + bool swadgeGuyUnlocked; + bool choUnlocked; +}lumberjackUnlock_t; + typedef struct { menu_t* menu; @@ -46,6 +55,7 @@ typedef struct connectionEvt_t conStatus; lumberjackScreen_t screen; lumberjackGameType_t gameMode; + lumberjackUnlock_t save; } lumberjack_t; @@ -70,6 +80,8 @@ typedef struct } lumberjackAxeBlock_t; + + typedef struct { int x; @@ -140,7 +152,6 @@ typedef struct int comboAmount; uint8_t attackQueue[8]; - uint8_t receiveQueue[8]; int wakeupSignal; int lastResponseSignal; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 9678c5505..e0e194280 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -81,7 +81,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->lumberjackMain = main; lumv->localPlayerType = characterIndex; lumv->score = 0; - lumv->highscore = 5000; + lumv->highscore = lumv->lumberjackMain->save.highScore; loadFont("eightbit_atari_grube2.font", &lumv->arcade, false); @@ -182,7 +182,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) //ESP_LOGI(LUM_TAG, "*Loading character icons"); loadWsg("lumbers_red_lives.wsg", &lumv->minicharacters[0], true); loadWsg("lumbers_green_lives.wsg", &lumv->minicharacters[1], true); - loadWsg("lumbers_secret_swadgeland_lives.wsg", &lumv->minicharacters[2], true); + loadWsg("lumbers_swadgeland_lives.wsg", &lumv->minicharacters[2], true); loadWsg("lumbers_cho_lives.wsg", &lumv->minicharacters[3], true); //ESP_LOGI(LUM_TAG, "*Loading character sprites"); @@ -235,24 +235,24 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) else if (characterIndex == 2) { - loadWsg("lumbers_secret_swadgeland_1.wsg", &lumv->playerSprites[0], true); - loadWsg("lumbers_secret_swadgeland_2.wsg", &lumv->playerSprites[1], true); - loadWsg("lumbers_secret_swadgeland_3.wsg", &lumv->playerSprites[2], true); - loadWsg("lumbers_secret_swadgeland_4.wsg", &lumv->playerSprites[3], true); - loadWsg("lumbers_secret_swadgeland_5.wsg", &lumv->playerSprites[4], true); - loadWsg("lumbers_secret_swadgeland_6.wsg", &lumv->playerSprites[5], true); - loadWsg("lumbers_secret_swadgeland_7.wsg", &lumv->playerSprites[6], true); - loadWsg("lumbers_secret_swadgeland_8.wsg", &lumv->playerSprites[7], true); - loadWsg("lumbers_secret_swadgeland_9.wsg", &lumv->playerSprites[8], true); - loadWsg("lumbers_secret_swadgeland_10.wsg", &lumv->playerSprites[9], true); - loadWsg("lumbers_secret_swadgeland_11.wsg", &lumv->playerSprites[10], true); - loadWsg("lumbers_secret_swadgeland_12.wsg", &lumv->playerSprites[11], true); - loadWsg("lumbers_secret_swadgeland_13.wsg", &lumv->playerSprites[12], true); - loadWsg("lumbers_secret_swadgeland_14.wsg", &lumv->playerSprites[13], true); - loadWsg("lumbers_secret_swadgeland_15.wsg", &lumv->playerSprites[14], true); - loadWsg("lumbers_secret_swadgeland_16.wsg", &lumv->playerSprites[15], true); - loadWsg("lumbers_secret_swadgeland_17.wsg", &lumv->playerSprites[16], true); - loadWsg("lumbers_secret_swadgeland_22.wsg", &lumv->playerSprites[17], true); + loadWsg("lumbers_swadgeland_1.wsg", &lumv->playerSprites[0], true); + loadWsg("lumbers_swadgeland_2.wsg", &lumv->playerSprites[1], true); + loadWsg("lumbers_swadgeland_3.wsg", &lumv->playerSprites[2], true); + loadWsg("lumbers_swadgeland_4.wsg", &lumv->playerSprites[3], true); + loadWsg("lumbers_swadgeland_5.wsg", &lumv->playerSprites[4], true); + loadWsg("lumbers_swadgeland_6.wsg", &lumv->playerSprites[5], true); + loadWsg("lumbers_swadgeland_7.wsg", &lumv->playerSprites[6], true); + loadWsg("lumbers_swadgeland_8.wsg", &lumv->playerSprites[7], true); + loadWsg("lumbers_swadgeland_9.wsg", &lumv->playerSprites[8], true); + loadWsg("lumbers_swadgeland_10.wsg", &lumv->playerSprites[9], true); + loadWsg("lumbers_swadgeland_11.wsg", &lumv->playerSprites[10], true); + loadWsg("lumbers_swadgeland_12.wsg", &lumv->playerSprites[11], true); + loadWsg("lumbers_swadgeland_13.wsg", &lumv->playerSprites[12], true); + loadWsg("lumbers_swadgeland_14.wsg", &lumv->playerSprites[13], true); + loadWsg("lumbers_swadgeland_15.wsg", &lumv->playerSprites[14], true); + loadWsg("lumbers_swadgeland_16.wsg", &lumv->playerSprites[15], true); + loadWsg("lumbers_swadgeland_17.wsg", &lumv->playerSprites[16], true); + loadWsg("lumbers_swadgeland_22.wsg", &lumv->playerSprites[17], true); lumv->invincibleColor = c305; } @@ -449,7 +449,6 @@ bool lumberjackLoadLevel() for (int i = 0; i < 8; i++) { lumv->attackQueue[i] = 0; - lumv->receiveQueue[i] = 0; } lumv->enemySpawnAmount = 4; @@ -824,8 +823,7 @@ void lumberjackGameLoop(int64_t elapsedUs) if (lumv->wakeupSignal < 0) { lumv->wakeupSignal = 100; - lumberjackSendScore(lumv->score); //Send score just to ping - + lumberjackSendScore(lumv->score); //Send score just to ping } if (lumv->lastResponseSignal <= 0) @@ -1118,6 +1116,62 @@ void baseMode(int64_t elapsedUs) // Clear cruft lumberjackUpdate(elapsedUs); + + if (lumv->lumberjackMain->networked) + { + + lumv->totalEnemyCount = 0; + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + { + if (lumv->enemy[i] == NULL) continue; + + if (lumv->enemy[i]->queueable) + { + lumv->totalEnemyCount++; + } + } + + int enemyKilled = 0; + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + { + if (lumv->enemy[i] == NULL) continue; + if (lumv->enemy[i]->state == LUMBERJACK_DEAD) + { + if (lumv->enemy[i]->y == 640) + { + enemyKilled++; + } + } + } + + if (enemyKilled >= lumv->totalEnemyCount) + { + ESP_LOGI("LUM","UPGRADE"); + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + { + if (lumv->enemy[i] == NULL || lumv->enemy[i]->queueable == false) continue; + + lumberjackResetEnemy(lumv->enemy[i]); + lumberjackUpdateEnemy(lumv->enemy[i], lumv->enemy[i]->type+1); + lumv->enemy[i]->state = LUMBERJACK_RUN; + } + + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + { + if (lumv->enemy[i] == NULL) continue; + + if (lumv->enemy[i]->queueable == false) + { + lumv->enemy[i]->queueable = true; + break; + } + } + + + } + + } + // Check spawn bool spawnedEnemy = false; //if (false == lumv->hasWon) spawnedEnemy = lumberjackSpawnCheck(elapsedUs); @@ -1199,7 +1253,7 @@ void baseMode(int64_t elapsedUs) lumberjackTile_t* facingTile = lumberjackGetTile(enemy->x + (enemy->direction > 0 ? 28 : -8) , enemy->y + 2); - if (facingTile != NULL && facingTile->type != 0 && lumberjackIsCollisionTile(facingTile)) + if (facingTile != NULL && facingTile->type != 0 && lumberjackIsCollisionTile(facingTile->type)) { enemy->direction = enemy->flipped ? 1 : -1; // Go opposite direction enemy->flipped = !enemy->flipped; //Debug @@ -1297,35 +1351,7 @@ void baseMode(int64_t elapsedUs) if (lumv->enemyKillCount >= lumv->totalEnemyCount) { //And game mode == blah - if (lumv->lumberjackMain->networked) - { - for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) - { - if (lumv->enemy[i] == NULL || lumv->enemy[i]->state != LUMBERJACK_DEAD || lumv->enemy[i]->queueable == false) continue; - - lumv->enemy[i]->state = LUMBERJACK_RUN; - if (lumv->enemy[i]->active == false && lumv->enemy[i]->state == LUMBERJACK_OFFSCREEN) - { - lumberjackResetEnemy(lumv->enemy[i]); - lumberjackUpdateEnemy(lumv->enemy[i], lumv->enemy[i]->type+1); - } - } - - lumv->enemyKillCount = 0; - - for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) - { - if (lumv->enemy[i] == NULL) continue; - if (lumv->enemy[i]->queueable == false) - { - lumv->enemy[i]->queueable = true; - lumv->totalEnemyCount++; - break; - } - - } - } - else + if (!lumv->lumberjackMain->networked) { lumv->hasWon = true; } @@ -1716,11 +1742,11 @@ void DrawGame(void) /* char debug[20] = {0}; - snprintf(debug, sizeof(debug), "Debug: %d %d %d", lumv->localPlayer->x, lumv->localPlayer->y, - lumv->localPlayer->cH); - + snprintf(debug, sizeof(debug), "Enemy: %d ", + lumv->totalEnemyCount); drawText(&lumv->arcade, c000, debug, 16, 16); + drawRect(lumv->localPlayer->cX, lumv->localPlayer->cY - lumv->yOffset, lumv->localPlayer->cX + lumv->localPlayer->cW, lumv->localPlayer->cY - lumv->yOffset + lumv->localPlayer->cH, c050); @@ -1843,25 +1869,6 @@ bool lumberjackSpawnCheck(int64_t elapseUs) //lumv->spawnTimer = LUMBERJACK_RESPAWN_TIMER - (lumv->upgrade * LUMBERJACK_UPGRADE_TIMER_OFFSET); lumv->spawnTimer = lumv->enemySpawnTime; - /* - if (lumv->spawnTimer < lumv->enemySpawnTime) - { - - if ((lumv->lumberjackMain->networked && lumv->enemyAttackQueue > 0)) - { - lumv->spawnTimer = lumv->enemyReceiveSpawnTime; - - if (lumv->enemyAttackQueue > 0) - { - lumv->enemyAttackQueue--; - } - } - else - { - lumv->spawnTimer = LUMBERJACK_RESPAWN_PANIC_MIN; - } - }*/ - lumberjackRespawnEnemy(lumv->enemy[enemyIndex], lumv->spawnSide); spawnReady = true; break; @@ -1882,12 +1889,11 @@ bool lumberjackSpawnCheck(int64_t elapseUs) void lumberjackQualityCheck() { lumv->wakeupSignal = 100; - lumv->lastResponseSignal = 1000; + lumv->lastResponseSignal = 2000; } void lumberjackOnReceiveAttack(const uint8_t* attack, int len) { - ESP_LOGI(LUM_TAG, "Being attacked %ld", sizeof(attack)); if (lumv->gameType == LUMBERJACK_MODE_PANIC) { @@ -1928,7 +1934,8 @@ void lumberjackOnReceiveAttack(const uint8_t* attack, int len) { lumv->totalEnemyCount++; } - } + } + } } @@ -2217,6 +2224,10 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs entity->ready = true; return; } + } else if (entity->upgrading) + { + lumberjackResetEnemy(entity); + lumberjackUpdateEnemy(entity, entity->type + 1); } } @@ -2236,8 +2247,12 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs } } if (entity->state != LUMBERJACK_DEAD && !lumv->hasWon) + { entity->state = LUMBERJACK_OFFSCREEN; + + } + if (entity->state != LUMBERJACK_DEAD && entity->state != LUMBERJACK_OFFSCREEN && lumv->hasWon) { lumv->gameState = LUMBERJACK_GAMESTATE_WINNING; @@ -2692,6 +2707,21 @@ void drawSolidWsg(const wsg_t* wsg, int16_t xOff, int16_t yOff, bool flipLR, boo void lumberjackExitGameMode(void) { + if (lumv->lumberjackMain->networked == false) + { + + if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + lumv->lumberjackMain->save.attackHighScore = lumv->highscore; + } + + if (lumv->gameType == LUMBERJACK_MODE_PANIC) + { + lumv->lumberjackMain->save.panicHighScore = lumv->highscore; + } + lumberjackSaveSave(); + } + // Everything crashes if you don't load it first if (lumv == NULL) return; @@ -2711,7 +2741,7 @@ void lumberjackExitGameMode(void) // Free the bonus for (int i = 0; i < ARRAY_SIZE(lumv->bonusDisplay); i++) { - freeWsg(&lumv->bonusDisplay[i]); + free(lumv->bonusDisplay[i]); } // Free the enemies diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 42534ba2e..5c3ee2edb 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -11,6 +11,7 @@ void lumberjackTileMap(void); void lumberjackDrawWaterLevel(void); void lumberjackUpdate(int64_t elapseUs); + void lumberjackTitleLoop(int64_t elapsedUs); void lumberjackGameLoop(int64_t elapsedUs); @@ -46,5 +47,7 @@ void drawSolidWsg(const wsg_t* wsg, int16_t xOff, int16_t yOff, bool flipLR, boo void lumberjackUseBlock(void); +void lumberjackSaveSave(void); + #endif \ No newline at end of file From 000e66c4c1f10a3d803f56cfcc0021381c47a263 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 12 Nov 2023 18:29:06 -0800 Subject: [PATCH 36/54] Started SFX Tweaked panic level 10 Added panic level 8 Added panic level 9 Added attack level 10 Added SFX for bumping over enemy Added SFX for bumping empty block Added SFX for jumping Added SFX for kicking enemy Added SFX for dying --- assets/lumbers/l_sfx_being_attacked.mid | Bin 0 -> 200 bytes assets/lumbers/l_sfx_brick.mid | Bin 0 -> 100 bytes assets/lumbers/l_sfx_enemy_death.mid | Bin 0 -> 116 bytes assets/lumbers/l_sfx_enemy_flip.mid | Bin 0 -> 146 bytes assets/lumbers/l_sfx_jump.mid | Bin 0 -> 105 bytes assets/lumbers/l_sfx_pear.mid | Bin 0 -> 171 bytes assets/lumbers/l_sfx_upgrade.mid | Bin 0 -> 175 bytes assets/lumbers/l_sfx_water.mid | Bin 0 -> 192 bytes assets/lumbers/lumberjacks.tsx | 20 +++--- assets/lumbers/lumberjacks_attack_10.bin | Bin 0 -> 740 bytes assets/lumbers/lumberjacks_panic_10.bin | Bin 740 -> 740 bytes assets/lumbers/lumberjacks_panic_3.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_panic_8.bin | Bin 0 -> 452 bytes assets/lumbers/lumberjacks_panic_9.bin | Bin 0 -> 488 bytes main/modes/lumberjack/lumberjack.c | 1 - main/modes/lumberjack/lumberjack.h | 9 +++ main/modes/lumberjack/lumberjackGame.c | 85 +++++++++++++++++++++-- main/modes/lumberjack/lumberjackGame.h | 2 +- 18 files changed, 98 insertions(+), 19 deletions(-) create mode 100644 assets/lumbers/l_sfx_being_attacked.mid create mode 100644 assets/lumbers/l_sfx_brick.mid create mode 100644 assets/lumbers/l_sfx_enemy_death.mid create mode 100644 assets/lumbers/l_sfx_enemy_flip.mid create mode 100644 assets/lumbers/l_sfx_jump.mid create mode 100644 assets/lumbers/l_sfx_pear.mid create mode 100644 assets/lumbers/l_sfx_upgrade.mid create mode 100644 assets/lumbers/l_sfx_water.mid create mode 100644 assets/lumbers/lumberjacks_attack_10.bin create mode 100644 assets/lumbers/lumberjacks_panic_8.bin create mode 100644 assets/lumbers/lumberjacks_panic_9.bin diff --git a/assets/lumbers/l_sfx_being_attacked.mid b/assets/lumbers/l_sfx_being_attacked.mid new file mode 100644 index 0000000000000000000000000000000000000000..7828a963b4d5c0f48f318fb817724b8bd410a264 GIT binary patch literal 200 zcmeYb$w*;fU|?flWMF1!@C_--2J*@o{xb`N6lE6Vr1}>pXXfN2mgE;P{10SilWJg? zpp(bjpp(Zu!3jt^0qMXzh!~KjK%C*fJ_FQxF`)JAAw`MF*$M_QTM@FNKv_2L%;fA; IxRZdA0C`+Fy8r+H literal 0 HcmV?d00001 diff --git a/assets/lumbers/l_sfx_brick.mid b/assets/lumbers/l_sfx_brick.mid new file mode 100644 index 0000000000000000000000000000000000000000..299e0a651c1f20ed492bdd98c9163b63b37a0cc8 GIT binary patch literal 100 zcmeYb$w*;fU|?flWME=w@C_--2J#FU{xfqqWtMp6l_jR67BTz}WM;lFfnkD;gF=Ii j1H%L(AZ-Ms4S=+P1H*rP2B=0+phhn8Rum}9=AD_G Jjj#eJ2>>>7DMtVR literal 0 HcmV?d00001 diff --git a/assets/lumbers/l_sfx_jump.mid b/assets/lumbers/l_sfx_jump.mid new file mode 100644 index 0000000000000000000000000000000000000000..9da6b893f83da0174429ff6d41c40f8803883f75 GIT binary patch literal 105 zcmeYb$w*;fU|?flWME=w@C_--2J*}p{xh@t=I0fc6y-Dg4`gP(Fo9u$hl4_chXcce nARrwCq{D!87?6$t(h&{}|MeN5xMZ73XBX4|CzaS63Y@5QWA3$(^DD#vv4|RB_6bh;7C<&bU_L{G TlLJVIA&_KIOQ2SU|N0C7GcPWG literal 0 HcmV?d00001 diff --git a/assets/lumbers/l_sfx_upgrade.mid b/assets/lumbers/l_sfx_upgrade.mid new file mode 100644 index 0000000000000000000000000000000000000000..35cb055accd5eaf3f895dfa7d2d0f8bebc7ba7d1 GIT binary patch literal 175 zcmeYb$w*;fU|?flWMF1!@C_--2J%7~{xkC>B^DPK=Oh*w80zJxr!)KyWM(ZEW0(-^ zpwJNPz%U^YNCyJxP#_%&r2T-jACL|Q(&0eb6G(dk=|~_Q>A>(`p8;yPJkW4~kfO|j foK*kfq5U literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumberjacks.tsx b/assets/lumbers/lumberjacks.tsx index de65a31e2..4be864001 100644 --- a/assets/lumbers/lumberjacks.tsx +++ b/assets/lumbers/lumberjacks.tsx @@ -2,34 +2,34 @@ - + - + - + - + - + - + - + - + - + - + diff --git a/assets/lumbers/lumberjacks_attack_10.bin b/assets/lumbers/lumberjacks_attack_10.bin new file mode 100644 index 0000000000000000000000000000000000000000..dbb02d90ca4ec09e9143c02e863a6651cd428150 GIT binary patch literal 740 zcmbVIK@NZ*3>#!B>f*_>XP@Zv9U~J)Btd(SwX_}aBm{>5u*1RMA3#A0mUCYf#@&h( z|6ZbbIm>uC8&faQ7xnsqBGhe&ip`VKvL{^`<878K%eqXouC12JDb#jF#^4)7;y1}q hY<_EKX`DAb`PZ}({kroRgT%%uDCUKgYjZx#0dKYD1PA~C literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumberjacks_panic_10.bin b/assets/lumbers/lumberjacks_panic_10.bin index 8d7a8da0a69ccca84d78d7531bda1b8581d2d035..e7a03a4a96714912895b1ed19e385a487a7b20d2 100644 GIT binary patch delta 82 zcmaFD`h=B7gN22Gk(mJmEXT;c(UXgDatNakD-RD)Vq$>d@By4o?68 delta 69 zcmaFD`h=B7gN2cSk(mJmEXT;c(UXgDauB2NLv#2DyoWDjN;r7y&5$1GoSH delta 24 bcmeBU?qlW=Wo2MsWB>!XiGeB`4dNI9D4GMV diff --git a/assets/lumbers/lumberjacks_panic_8.bin b/assets/lumbers/lumberjacks_panic_8.bin new file mode 100644 index 0000000000000000000000000000000000000000..20f89112ac2fdd1934eca9c8b3fc6594c86bdadc GIT binary patch literal 452 zcmb79I}U)JKQMHn5N96XWtKaB;YB%}kpfwu3LaDw3oz=2EN4n$c}bf@yhl2Q^k z$uPu0Di;8WVkBw#uED5jYo94wF3b>bQ_SE5sg|Wu^;du208&V C9s|Ds literal 0 HcmV?d00001 diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index cfcf97e12..6aa121489 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -368,7 +368,6 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) if (payload[0] == DEATH_MSG) { - ESP_LOGI(LUM_TAG, "Playher died!"); lumberjackOnReceiveDeath(payload[1] != 0x00); } diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 4e9ef1459..a7ea7984d 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -211,6 +211,15 @@ typedef struct lumberjackGameType_t gameType; + //sounds + song_t sfx_item_get; + song_t sfx_item_use; + song_t sfx_jump; + song_t sfx_bump; + song_t sfx_flip; + song_t sfx_player_death; + song_t sfx_enemy_death; + } lumberjackVars_t; #endif \ No newline at end of file diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index e0e194280..de15f8a11 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -389,6 +389,25 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) } + //Sounds? + loadSong("r_p_shoot.sng", &lumv->sfx_item_get, false); + + if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + { + loadSong("l_sfx_upgrade.sng", &lumv->sfx_item_use, false); + } + else + { + loadSong("l_sfx_water.sng", &lumv->sfx_item_use, false); + } + + loadSong("l_sfx_jump.sng", &lumv->sfx_jump, false); + loadSong("l_sfx_brick.sng", &lumv->sfx_bump, false); + loadSong("l_sfx_enemy_flip.sng", &lumv->sfx_flip, false); + loadSong("r_e_dead.sng", &lumv->sfx_player_death, false); + loadSong("l_sfx_enemy_death.sng", &lumv->sfx_enemy_death, false); + + } bool lumberjackLoadLevel() @@ -410,6 +429,8 @@ bool lumberjackLoadLevel() "lumberjacks_panic_5.bin", "lumberjacks_panic_6.bin", "lumberjacks_panic_7.bin", + "lumberjacks_panic_8.bin", + "lumberjacks_panic_9.bin", "lumberjacks_panic_10.bin", }; @@ -436,6 +457,7 @@ bool lumberjackLoadLevel() "lumberjacks_attack_3.bin", "lumberjacks_attack_4.bin", "lumberjacks_attack_5.bin", + "lumberjacks_attack_10.bin", }; fname = attackLevelName[lumv->levelIndex % ARRAY_SIZE(attackLevelName)]; @@ -994,6 +1016,7 @@ void baseMode(int64_t elapsedUs) ESP_LOGI(LUM_TAG, "%d", x); //lumberjackSendAttack(lumv->attackQueue); + if (lumv->gameType == LUMBERJACK_MODE_ATTACK && lumv->itemBlockIndex != -1) { @@ -1343,6 +1366,7 @@ void baseMode(int64_t elapsedUs) } lumv->comboTime = LUMBERJACK_COMBO_RESET_TIME; + bzrPlaySfx(&lumv->sfx_enemy_death, BZR_RIGHT); //if game mode is single player decide if you're going to clear the level @@ -1354,6 +1378,12 @@ void baseMode(int64_t elapsedUs) if (!lumv->lumberjackMain->networked) { lumv->hasWon = true; + lumv->invincibleTimer = 0; + + if (NULL != lumv->ghost && lumv->ghost->active) + { + lumv->ghost->x = 1000; + } } } @@ -1373,6 +1403,7 @@ void baseMode(int64_t elapsedUs) // Kill player // ESP_LOGI(LUM_TAG, "KILL PLAYER"); lumberjackOnLocalPlayerDeath(); + } } } @@ -1501,6 +1532,8 @@ void lumberjackOnLocalPlayerDeath(void) lumv->transitionTimer = 400; } + bzrPlaySfx(&lumv->sfx_player_death, BZR_RIGHT); + if (lumv->lumberjackMain->networked) { lumberjackSendDeath(lumv->lives <= 0); @@ -1952,9 +1985,12 @@ void lumberjackOnReceiveBump(void) if (lumv->localPlayer->onGround) { lumv->localPlayer->vy = -20; //HERE + bzrPlaySfx(&lumv->sfx_bump, BZR_RIGHT); if (lumv->localPlayer->state == LUMBERJACK_DUCK) { + bzrPlaySfx(&lumv->sfx_flip, BZR_RIGHT); + lumv->localPlayer->vy = -40; lumv->localPlayer->state = LUMBERJACK_BUMPED; lumv->invincibleTimer = 0; @@ -2039,6 +2075,9 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs entity->vy = -15; entity->jumpTimer = 225000; entity->onGround = false; + + bzrPlaySfx(&lumv->sfx_jump, BZR_RIGHT); + } else if (entity->jumping) { @@ -2124,7 +2163,8 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs { lumberjackTile_t* tileA = lumberjackGetTile(destinationX, destinationY); lumberjackTile_t* tileB = lumberjackGetTile(destinationX + 16, destinationY); - + bool flipOpponent = false; + bool bump = false; if ((tileA != NULL && lumberjackIsCollisionTile(tileA->type)) || (tileB != NULL && lumberjackIsCollisionTile(tileB->type))) { destinationY = ((tileA->y + 1) * LUMBERJACK_TILE_SIZE); @@ -2134,9 +2174,10 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs if (tileA != NULL && lumberjackIsCollisionTile(tileA->type)) { + bump = true; if (tileA->type != 11 || lumv->itemBlockReady == true) { - //ESP_LOGI(LUM_TAG, "BUMP A %d", tileA->index); + lumv->tile[tileA->index].offset = 10; lumv->tile[tileA->index].offset_time = 100; @@ -2148,10 +2189,18 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs lumv->tile[tileA->index].offset_time *= 10; } - if (lumv->tile[tileA->index].type != 13) lumberjackDetectBump(tileA); + if (lumv->tile[tileA->index].type != 13) + { + if(lumberjackDetectBump(tileA)) + { + flipOpponent = true; + } + + } if (tileA->type == 11) { lumberjackUseBlock(); + bump = false; } } @@ -2160,7 +2209,7 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs if (tileB!= NULL && lumberjackIsCollisionTile(tileB->type)) { - + bump = true; if (tileB->type != 11 || lumv->itemBlockReady == true) { @@ -2174,14 +2223,31 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs lumv->tile[tileB->index].offset_time *= 10; } - if (lumv->tile[tileB->index].type != 13) lumberjackDetectBump(tileB); + if (lumv->tile[tileB->index].type != 13) + { + if (lumberjackDetectBump(tileB)) + { + flipOpponent = true; + } + } if (tileB->type == 11) { lumberjackUseBlock(); + bump = false; } } + } + + if (flipOpponent) + { + bzrPlaySfx(&lumv->sfx_flip, BZR_RIGHT); + } + else if (bump) + { + bzrPlaySfx(&lumv->sfx_bump, BZR_RIGHT); } + } } else if (entity->vy > 0 && entity->active) @@ -2469,8 +2535,9 @@ static bool lumberjackIsCollisionTile(int index) return true; } -void lumberjackDetectBump(lumberjackTile_t* tile) +bool lumberjackDetectBump(lumberjackTile_t* tile) { + bool bump = false; if (lumv->localPlayer->state != LUMBERJACK_BUMPED && lumv->localPlayer->state != LUMBERJACK_DEAD) { // TODO put in bump the player @@ -2508,7 +2575,7 @@ void lumberjackDetectBump(lumberjackTile_t* tile) { enemy->vy = -20; enemy->onGround = false; - + bump = true; if (enemy->state == LUMBERJACK_BUMPED_IDLE) { enemy->state = LUMBERJACK_RUN; @@ -2531,6 +2598,8 @@ void lumberjackDetectBump(lumberjackTile_t* tile) } } } + + return bump; } void lumberjackUseBlock() @@ -2540,6 +2609,8 @@ void lumberjackUseBlock() if (lumv->gameType == LUMBERJACK_MODE_PANIC) { + bzrPlaySfx(&lumv->sfx_item_use, BZR_RIGHT); + lumv->waterDirection = LUMBERJACK_WATER_FAST_DRAIN; lumv->waterTimer = lumv->waterSpeed; diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 5c3ee2edb..01044556b 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -19,7 +19,7 @@ void restartLevel(void); void lumberjackGameDebugLoop(int64_t elapsedUs); -void lumberjackDetectBump(lumberjackTile_t* tile); +bool lumberjackDetectBump(lumberjackTile_t* tile); bool lumberjackSpawnCheck(int64_t elapseUs); void lumberjackAttackCheck(int64_t elapseUs); From 0fba5b842f6e95c3e855cf99ac78a844fc00745a Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sun, 12 Nov 2023 22:49:02 -0800 Subject: [PATCH 37/54] Added Panic Theme Panic Music added Death taunt added Gameover music added --- assets/lumbers/l_song_gameover.mid | Bin 0 -> 525 bytes assets/lumbers/l_song_panic.mid | Bin 0 -> 4692 bytes assets/lumbers/l_song_respawn.mid | Bin 0 -> 262 bytes main/modes/lumberjack/lumberjack.h | 6 +++ main/modes/lumberjack/lumberjackGame.c | 50 ++++++++++++++++++++++++- 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 assets/lumbers/l_song_gameover.mid create mode 100644 assets/lumbers/l_song_panic.mid create mode 100644 assets/lumbers/l_song_respawn.mid diff --git a/assets/lumbers/l_song_gameover.mid b/assets/lumbers/l_song_gameover.mid new file mode 100644 index 0000000000000000000000000000000000000000..9468fe605573561221351fc7d288a6ffd37ba324 GIT binary patch literal 525 zcmaKn!AiqW5Jg8*OaDOKWg)bSHfcg=q3y;dAyAS+NWm^&)IzW*QWUa$)qcSHB-eh4 zJ3k@46XX$4+}+$W=Vc~Y757BcrV}!Zk7Tvm;>)7SIL~gbgD5oP*T>tyj#)eynd;ZNJE$Oo!A`?4RY5NF^K+gnychXEMyB9MV6BV@5I1 zg2MtK;t(~5b)#prrPt7np80KsV(-b2W-8ziAov`7gt<7Z<(wL4f9kVcQkHltq(!Cj zcsUQtP1u~kw8i_Cv=K&(MnF?WQ#5_H`mkI^ZWHy`>eV`s4FuhTK2rm>2F-ts8I6JT bI}SGvnjwc_{Z5HzN^FWlEEHWP-TI;<7vH1T literal 0 HcmV?d00001 diff --git a/assets/lumbers/l_song_panic.mid b/assets/lumbers/l_song_panic.mid new file mode 100644 index 0000000000000000000000000000000000000000..7dc7e03c44460a3c1524d693943fcc45edfeb0d3 GIT binary patch literal 4692 zcmeH~O-~zF6ozjLjnaJ=T|_DiBm^1o2V*`G3x8m+u`w7GsVtqgk*r3IMv)@TA`3&H zD7*P7{R#a`{RQ-S?~LyqhzU@!%ok%TC0oO@(Rj*j?K?K zGDOMl@H8CnnzMjId>wN!Aj9PJbNnI6;(Rib3(qG5Vn+}gs@b?!^Yg6NSmCB+rLLPP z8x{}9>OyAOXwg!OmSANBEAcI){MDg$JRvp~njszobKGm%dz0jcs&@#|uK4W=d|&nY zvJR+sz`a9x4#g5tBcg0&4NHbiWuxOP+NLzuQj*-J%u+D~H!_E+q2xl|P|k+2LAX?= zrLz{sj+)uAbG2+={D6yaE0QjNyPWmZRnKP^KT^{dmuxarSXOKQQh| z-xFA2E;_5y7N|C$Ix;#Kd#byq9=d|k<^I0v?yD|i4w;EJUR3G=!wP%xd1YbTAv+=^@} zq)CYLWU=u?5n5#rQUu)w>C_KY_5dLaWDKY>KnDZrA1UTY%E-9Uy8(&56mB~ILlI;} z5&FE@hV2^mA2Y4(2Ph)WBx@C+Jp#Z7D8lp57n(jiWb#LXez|jW$kC%Jfrnu~t9fx~ zDbYNOB(RIbZ)@H_&-mXH-~a7?Pn1nk6!szj*L87S+>241`Y^mCqF_SIAB8 z%8@atxTdJJYfjEaFEhEh%-67|%Hv$}FJ0gu}k zSoR_M(NR6~O^bv7>>>EXo=EtJL}`=*;Nh+6F7pg?ll71{)Y*n5f-tK)TmddFyj0?s zO1vQpUtWve=Q!uzgpg0qjYkynh;S9fruG%TXF^nmtDx#qg|Fl|_ZXR9pw}0o1}sZ8 z@*e?L0-3m`h57e#OI)fICqOTnKm`H{&}K;Md0pgYN^wh?U)8>q{7ik^WX?`ygk{2; zQq$4lkxe1ZQR`v&{osA>Uk2}*7UtDsfx_item_get, false); if (lumv->gameType == LUMBERJACK_MODE_ATTACK) { loadSong("l_sfx_upgrade.sng", &lumv->sfx_item_use, false); + loadSong("l_song_panic.sng", &lumv->song_theme, false); } else { + loadSong("l_song_panic.sng", &lumv->song_theme, false); loadSong("l_sfx_water.sng", &lumv->sfx_item_use, false); } + loadSong("r_p_shoot.sng", &lumv->sfx_item_get, false); loadSong("l_sfx_jump.sng", &lumv->sfx_jump, false); loadSong("l_sfx_brick.sng", &lumv->sfx_bump, false); loadSong("l_sfx_enemy_flip.sng", &lumv->sfx_flip, false); loadSong("r_e_dead.sng", &lumv->sfx_player_death, false); loadSong("l_sfx_enemy_death.sng", &lumv->sfx_enemy_death, false); + loadSong("l_song_respawn.sng", &lumv->song_respawn, false); + loadSong("l_song_gameover.sng", &lumv->song_gameover, false); + lumv->song_theme.shouldLoop = true; } @@ -725,6 +730,12 @@ void lumberjackSetupLevel(int characterIndex) //Ghost is separate for reasons ESP_LOGI(LUM_TAG, "LOADED"); + if (!lumv->levelMusic) + { + bzrPlayBgm(&lumv->song_theme, BZR_STEREO); + lumv->levelMusic = true; + } + } void lumberjackUnloadLevel(void) @@ -850,6 +861,7 @@ void lumberjackGameLoop(int64_t elapsedUs) if (lumv->lastResponseSignal <= 0) { + bzrStop(true); ESP_LOGI(LUM_TAG, "Connection lost!"); lumv->gameState = LUMBERJACK_GAMESTATE_GAMEOVER; lumv->transitionTimer = 500; @@ -970,6 +982,16 @@ void baseMode(int64_t elapsedUs) { lumv->levelTime += elapsedUs / 1000; + if (lumv->resume > 0) + { + lumv->resume -= elapsedUs / 1000; + + if (lumv->resume <= 0) + { + bzrPlayBgm(&lumv->song_theme, BZR_STEREO); + } + } + if (lumv->comboTime > 0) { lumv->comboTime -= elapsedUs / 1000; @@ -1294,9 +1316,14 @@ void baseMode(int64_t elapsedUs) if (lumv->localPlayer->respawn <= 0 && lumv->lives > 0) { + ESP_LOGI(LUM_TAG, "RESPAWN PLAYER!"); + bzrStop(true); + bzrPlaySfx(&lumv->song_respawn, BZR_RIGHT); + // Respawn player lumv->localPlayer->respawn = 0; + lumv->resume = 2000; lumv->lives--; lumv->invincibleTimer = LUMBERJACK_INVINCIBLE_TIME; lumberjackRespawn(lumv->localPlayer, lumv->playerSpawnX, lumv->playerSpawnY); @@ -1530,6 +1557,9 @@ void lumberjackOnLocalPlayerDeath(void) lumv->gameState = LUMBERJACK_GAMESTATE_GAMEOVER; lumv->transitionTimer = 400; + bzrStop(true); + + bzrPlayBgm(&lumv->song_gameover, BZR_STEREO); } bzrPlaySfx(&lumv->sfx_player_death, BZR_RIGHT); @@ -2288,6 +2318,7 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs // ESP_LOGI(LUM_TAG, "DEAD & hit the ground %d", entity->respawn); entity->respawn = LUMBERJACK_UPGRADE_TIMER_OFFSET; entity->ready = true; + return; } } else if (entity->upgrading) @@ -2778,6 +2809,8 @@ void drawSolidWsg(const wsg_t* wsg, int16_t xOff, int16_t yOff, bool flipLR, boo void lumberjackExitGameMode(void) { + bzrStop(true); + if (lumv->lumberjackMain->networked == false) { @@ -2807,6 +2840,21 @@ void lumberjackExitGameMode(void) freeWsg(&lumv->connectLostSprite); } + + freeSong(&lumv->sfx_item_use); + freeSong(&lumv->sfx_item_get); + freeSong(&lumv->sfx_jump); + freeSong(&lumv->sfx_bump); + freeSong(&lumv->sfx_flip); + freeSong(&lumv->sfx_player_death); + freeSong(&lumv->sfx_enemy_death); + + freeSong(&lumv->song_theme); + freeSong(&lumv->song_respawn); + freeSong(&lumv->song_gameover); + + + // Free the bonus From 087f4642321364285bbf1d2d01f000d6e63cc3df Mon Sep 17 00:00:00 2001 From: MrTroy Date: Mon, 13 Nov 2023 21:35:50 -0800 Subject: [PATCH 38/54] Adding final levels Added attack levels 7, 8, 9 Modified attack levels 2,3, 4, 5 and 10 Added attack song --- assets/lumbers/l_song_attack.mid | Bin 0 -> 5066 bytes assets/lumbers/lumberjacks_attack_10.bin | Bin 740 -> 740 bytes assets/lumbers/lumberjacks_attack_2.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_attack_3.bin | Bin 416 -> 398 bytes assets/lumbers/lumberjacks_attack_4.bin | Bin 398 -> 398 bytes assets/lumbers/lumberjacks_attack_5.bin | Bin 488 -> 416 bytes assets/lumbers/lumberjacks_attack_6.bin | Bin 0 -> 488 bytes assets/lumbers/lumberjacks_attack_7.bin | Bin 0 -> 596 bytes assets/lumbers/lumberjacks_attack_8.bin | Bin 0 -> 596 bytes assets/lumbers/lumberjacks_attack_9.bin | Bin 0 -> 740 bytes main/modes/lumberjack/lumberjackGame.c | 8 ++++++-- 11 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 assets/lumbers/l_song_attack.mid create mode 100644 assets/lumbers/lumberjacks_attack_6.bin create mode 100644 assets/lumbers/lumberjacks_attack_7.bin create mode 100644 assets/lumbers/lumberjacks_attack_8.bin create mode 100644 assets/lumbers/lumberjacks_attack_9.bin diff --git a/assets/lumbers/l_song_attack.mid b/assets/lumbers/l_song_attack.mid new file mode 100644 index 0000000000000000000000000000000000000000..a1694fbae2f1710853074212673b7b1f4e4e3110 GIT binary patch literal 5066 zcmeH}>r+!#6vYpqwwAV2U$t1qp$`?|5+DSE8W0E}5C~5}rY+;u>NM5SGAeBx+nL-X zbo_Y#r2c30x9&3$q}tZ{rJr)L?mqjhz4ki$-r|kYU1Q8K(_-4%{wUsf{D6N0X0NSd z?dIfkKG(Id^YG5S$M!*|Ty=8+?r87BCh;P>tRhdUf5;LsgbSl@K#>`Y~jvkP|Z z>q^0|0)9Dap0%q#S7wcKhlfA~v%5@&;Nd=vGNdXurYgt5jhRrPfC^cimu)(4U&?0L z*(lkkv@wv|;{vNGv69>~R5L?0$X-HrzvO=|yOV;dj`ljOM%8SPGQ9+u=DXf2i9Vr*sRJy(XM_0nLHb-$Jkh1 zb=OdF4S^T=UF7%m{+Cf7Hh!}>(Cg@`$giT%DsrrPxk4^;iuNy3Sj4=d=P7kTj2FZh z2hCvAFKGyitf`)iyA@j~aFyp?Qsm5wQC-H8E~757hpAsI3Wh;4W!E=J>#e}1I5W6k z_0I4B?s~A3uvxU2^-NbLy?ICfUp$Qtp0j`d5c$fKf*Yq)af3lA-Mh>{7UuCBs#}8^ z^MdA^AUsgQ1L`%^CU;9ayk;mu2@<1HH0$%fd;zK$|ohUiW`61JIR27CG)*c&R-N zBBeq*9xUE@#4G3ml@L$&Ae=$~E3gUl^{?p?1Uqz!ZY~wa!bUH=S(T1;Qw?F*`6Spz z1HVbT`UA?g@Nyy^)lOrKkkV*r)o@Hd5VLmt;42X?}K|#oxtQhFp_{NPKai9gU8Q&theC$QBk5s52WC2@Ou2YppIuublXENzeyMDBi zHf!#vT^*^6nk4({XW={P_DPRE?*4#c28bE7tE-hk^QnrvP9CSj9af^@S0!p8(apmX zv7JQQO|;*UOlj4UrWV9}PUTxv4l)3elmtm67?Mmw$dr;yDP-!FOx?)TtC(J5EXiac z6M3$yDII^2sD(r~4@=Z**EUG)v|=LMbPYFU>FsjGGXY5X8!2Wx^7GP{j&V3G8%P;g<<&)L^7yp%WHAOUg+aj80b$w9}AX ze-BYtM7*8qw%mTZK2_;QLM&Ipat7h+pA$3Y_9#yec?Rv;RUSF#dB(T-kj6*1U0bIa zP8%7(`i1of>uJUibX|fr##zFwW~|TNJ?%@=uMy?ti%cviqQ^?o``lkw2SIU3EGC>dZ%~wqG65OrscNN zvAG+9C{1=}2&|I`t0BM+kWK?i2#St_(g`T#V@lY29d{8lW>*I*V6{q- z@1(cvq>|+JUj~ui_dAK0PE3-C=iP|hHi9FWfF&lNJ~5b_Y5(5in*_e$l0L`nTN>|a JOs|4D*$M3eCvO%y^&2=VK?iLqZ6o;vo;Wag+4k4T}M|;zs)u2Lc#!1CUcr z7!kqFL?-i%sp`0s5@Hl>C#v72DtIv&xtqD?Tkm&2=OdeqL*pcb9wl2Ys0qVz&sOL{ za6&{~xYr`M04Yt$AO`}}QjRyN6Z_RqYU6+OqxDLl8k(I;Q!K4;+-5rU!bQwuZLOcX FJpshm1bYAg literal 740 zcmbVIK@NZ*3>#!B>f*_>XP@Zv9U~J)Btd(SwX_}aBm{>5u*1RMA3#A0mUCYf#@&h( z|6ZbbIm>uC8&faQ7xnsqBGhe&ip`VKvL{^`<878K%eqXouC12JDb#jF#^4)7;y1}q hY<_EKX`DAb`PZ}({kroRgT%%uDCUKgYjZx#0dKYD1PA~C diff --git a/assets/lumbers/lumberjacks_attack_2.bin b/assets/lumbers/lumberjacks_attack_2.bin index a504d464d4bd288beae4df1dc45da408f96848b3..846ea0c3359babf65ee687c5a674ae054afac86f 100644 GIT binary patch delta 28 icmeBU?qi*$--yiyS>$YMMgkG|9A+ifwzZHYZ}l&xi)J5eIwpi7IQHLo!)3ZfzcCKoa1 zI3;*h-N*s3g^c~EGBc7i2OgJEb2sN(DBJgpyY{bR${!|6niqaiSKQoN%3QfT)V>0| diff --git a/assets/lumbers/lumberjacks_attack_4.bin b/assets/lumbers/lumberjacks_attack_4.bin index f9607c589762bff8b89c8842dfd29e8d095840fc..a91cdb1e31116245d6e92bc51378405705338ae2 100644 GIT binary patch delta 59 zcmeBU?qlW=<=|joWMW`o5Mhv;D5%B84P-KKPZX4x7_xoh3?3d978V8uFu}kuaiac2 K1)<3)j9LKnx(QYQ delta 54 zcmeBU?qlW=<=|joWMN=n5Mhv;Y{+OlQ9*QK$aa1f7LXVa02x34miZt)IfYRR0MvB| A$^ZZW diff --git a/assets/lumbers/lumberjacks_attack_5.bin b/assets/lumbers/lumberjacks_attack_5.bin index 5e3f72d6c9cc43dfbe5334125d25bdb800a84acc..4472a1a7d1fb5e677e5d11da7a08a7c01a1a1abb 100644 GIT binary patch literal 416 zcmbtPK@NZ*3@c>nkj0bn=sSJB+XyjmT4E1{lD2FY6A}S9aVtA&?YGED27pAYrin;y z_K5y!Y3)$}Rc1#_dsv&SM-xrPqJyhVVeIQU4~8EiaMIBjY*ddRT+Nke=wHLrO|hP=wlxrLZ=!Ub+r B0}cQH diff --git a/assets/lumbers/lumberjacks_attack_6.bin b/assets/lumbers/lumberjacks_attack_6.bin new file mode 100644 index 0000000000000000000000000000000000000000..5e3f72d6c9cc43dfbe5334125d25bdb800a84acc GIT binary patch literal 488 zcmbtP!4`lZ2t(g0OaMIBjY*ddRT+Nke=wHLrO|hP=wlxrLZ=!Ub+r B0}cQH literal 0 HcmV?d00001 diff --git a/assets/lumbers/lumberjacks_attack_7.bin b/assets/lumbers/lumberjacks_attack_7.bin new file mode 100644 index 0000000000000000000000000000000000000000..b45d2015d76ac3e648da76973771e56d665af40f GIT binary patch literal 596 zcmbVIK@NZ*3@cDXjvNm`9KCA`8QG8m6*Y6P(!Rgihag+S9=0f^Y@6y}6# z&u0c}r#!B2=V0EvrqK-ju9LqlAt|cSK5wvB7#8x*x{h_2au72H6N>@^@1G# zULp;|>UhnSX>=$r8udd=C~h?rvHOjA*^_RJ=~g5?iOwvB&}(U&JnF7A5$Fan(wmr6 ho8KCG8s$}w{F+{3TsKxQaco{(fnQ0vHe;Q4cmtl!1ONa4 literal 0 HcmV?d00001 diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 46f1344c8..ac71e00c1 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -394,7 +394,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) if (lumv->gameType == LUMBERJACK_MODE_ATTACK) { loadSong("l_sfx_upgrade.sng", &lumv->sfx_item_use, false); - loadSong("l_song_panic.sng", &lumv->song_theme, false); + loadSong("l_song_attack.sng", &lumv->song_theme, false); } else { @@ -462,7 +462,11 @@ bool lumberjackLoadLevel() "lumberjacks_attack_3.bin", "lumberjacks_attack_4.bin", "lumberjacks_attack_5.bin", - "lumberjacks_attack_10.bin", + "lumberjacks_attack_6.bin", + "lumberjacks_attack_7.bin", + "lumberjacks_attack_8.bin", + "lumberjacks_attack_9.bin", + "lumberjacks_attack_10.bin", }; fname = attackLevelName[lumv->levelIndex % ARRAY_SIZE(attackLevelName)]; From 9ce8bc47f69f4ed4988f3b55dd1a809b42418886 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Wed, 15 Nov 2023 08:08:27 -0800 Subject: [PATCH 39/54] Music Add Added Exit to Lumber Jack menu Added Title screen music to Panic and Attack titles --- assets/lumbers/l_song_attack_title.mid | Bin 0 -> 9888 bytes assets/lumbers/l_song_panic_title.mid | Bin 0 -> 7008 bytes main/modes/lumberjack/lumberjack.c | 21 +++++++++++++-------- main/modes/lumberjack/lumberjack.h | 1 + main/modes/lumberjack/lumberjackGame.c | 16 +++++++++++----- main/modes/mainMenu/mainMenu.c | 2 +- 6 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 assets/lumbers/l_song_attack_title.mid create mode 100644 assets/lumbers/l_song_panic_title.mid diff --git a/assets/lumbers/l_song_attack_title.mid b/assets/lumbers/l_song_attack_title.mid new file mode 100644 index 0000000000000000000000000000000000000000..fe3b03c691c249059d083dd3250bc86b49858552 GIT binary patch literal 9888 zcmeI2TW?fH635R5gz~x)(yo*j9wH@xxfmY;gcDWwJ>mwAqbDks{4w zz{^J3m!0SRH2YEVO~~)x-PLt^Jj{3!Cc9Dc)ZNup)phSW)3dez?2D?Z&QyP>PM!Mi z*8VqNvASHnI`yZ$$9GrOSI=#J`}e>3<$U$(@bu}o{`_|Js&neh zzuu`{U8y3~AO8l`nS0MZ`}*8`HCXCC?|rvaRf7kbJgA=c+MpND0QCoVw08%jjD1&- zyFfNH*$`O^1la~;$FY}%y$snyO&*G@1%m7$WSLRkx+m;=kZo$RDY6!*4@4aMP)ndb zhfAM6vR8xqjQ1JW8P^%t7}pqA8CMzacAKCGht)x}RZUi_7jrJ!YWL{f2wIl_VpCv= z5d1}cf$;!qjJ0wS)VDFI^;GINiEoUUWj#q?c81m)ifqr&bU zqf&gCak(Yh5^L3`JB%tpi?V6R2jkR^r>T<682nsOcD+&@uU*F>SS&g?yE6r`{MxsG ztqE8hVr7aD4v-o{^{o~vSICBCATn9X3Lr~BVo?tj{HUv>i{X`!R7+#w+||x5=pnQ2z4E}w$%DK&l=-T~gJnpU}p*V!I$+0#`WDfBSH@EWCB)o;f2j0>X|uE(4JW9uW{ zT$9zUGFZB95K6k~|2OcXcku;xfqIGY6$tt5nopH^)O8n1G-+kpW#*~CVgRe!+qz1( z35Jo?-})1^H%*HMF+xRgE&;-kW7&WtKB+wnEm*puTOcLgi)VJvBI*vl*}*ao7}bT@ zmHbP=O-Zw+$?;3Wt?Zc`aZUc4AlqFk^fn2f?tsRscw;5Iu~tjhL%g;}^fRe0SK0Er z;Hs*3bbu-cMKBahm9G$z>X~EPWm4{FV<%R)i72UHhMOSvO_q@6WUDB%hTC~|pAVn+ zX5cuj(|x&X9iD1rBgokRNiI=NlF6GmbfZhRx>0?98b<U9OqCt>$+u`LdR&LC);TjAzolkG#)rJ4aHWUorDzZSXedRo z-`J5tszh5-b*nT7Te>^<754kGBFQo*jSg4qAO?-OTH$^nEJFwLv{Vj>YVNSU5lzyM#KdWs~vnf9ujKZ?AIw za(4oP|K@V`hy0t%weOb(muT89A;2xhTa44K|4$eYkJ90a0`m%!c}?bJ`D>b8)9eEb z_(4##35u3$5H1Pz(uq)Kz_l7&)%jOljUau4@YUc3vfp65#^`GhE{f)&WG=Txpw2+% zaO|(dzQ{T!W6jA}H?iYQ?0K8rr z;(9?`ZOgtF$~6cnl$lwanjqzRI#drAizwq-uHiZb>TDv*EwF%H7qIIsMwO^?Ju?e< zxR{Yn5Ceu{jvZcKRtQ{130H3zrCg)l`=WVYVKapw6H(o3vE=uOw9nWu z0+?4vHxI;#EDX&lo-KSc1oRO@joJk{1jH?XUMHG(yoT@ftw2Db&fE!cu!3!3pr zU-Lr7%yqL%!os&)BdizJa?9_NNLn~)BI*=eb4YrGWY9crn8)bm#PMsjPIyV5qWP;X z**ITpsDbHv;rnAeH+|2xPgkb~p{~4i2Uo3jy(|mc z$m(2O>i4ATds5ZNK7`GOEjDotg4dmis0-q{Ag-pO{eWJsL2v=eE&ug8k`@A3F?#LI z?g~ysb+zobnCn>JIurXvJWFIdEJ z$Vej=y_zKw|A7U|`5B{;WeP9w?TVG)(Xe4vpWpMH_k8zLUG5L}KMo3#FXho5})>E1`5%?!W!@{^g%;oj)cNB?mC ziE!`QnX`ZW^TFRFJpSX%4<)drE$G-pipGhU$yBMl7 zpZqUpo?YDE`*P+|n9LUkbGPQh?b%wod+sFZyUodsqI2s;2$Q~c_QS73IImxf*?xO} zvWc)MVTdr4FhCegAzL6@Rvu3_05-zdn=7EX`8q1sr&tEX?R|*9KR>DX#*=M1u`Tzv zByELG4c&QqvLk2*Xjj6nv__Ifl8l*Ss8u|e#RDW<$h=6`gk2N1DG8TnaRX^XQcqG( z(i(QJ$?heDB?(=Gu7p*D)hT2JWW~yNyH>82#^$>Z0Pk8sVAjH&5xX&ivt}pnN_w|4 zZ7j?7owBQ(dR0h{`ZW-I+fR|jj=Yq-?T}v>%kZ>7+YpclRl#9_Rv?BQLKtA|keERH zIvf#*UWecX4(JfNgSq5!?dZ5+`MOSAue=${8M&IGn}eD|xXjXWXohedgzfuKp0J(R zttfVxXidkG!dViAv`PszqY2bAM4`24C5UcpBcK*h1#pum>;#}OEkcEzgVRXU*>imH*$5>oE4RmmggQA$w_7Re)$ zFk#9BY`y2NL<4TptAP|(n>z1I^Gbp!NwE;HfDod?a508gHkCcTm!-!Rr`Y=57rTZ z`skGIba{5+UgEjL^DUllDPhhI4`vPIhRbCD7F`63W<3vHT>5MB$Y)kVcL)@)0d}#L;W2Hw=r+f|4x44}=>LH;_^# z9Tu{zHUptlYe0}4g^p-J)|IfK8dN;h<1G>*&p{2tHu`1=E%AMmXIuGee*dVkGV^VjE910~zkEU#po zpp^awLNS&F*MM@3=;hE6uPvw}S-lwsE}b!Vjx$kv@ILta;5T^cRkzlw_g61FVNy*q zHJ4r!oav)@?P;yob_cax+rG(~13Nj{Q%HJrg!{~`Wb8yW({f=)E;stu*fz6L39qk$ z`o(K|FX24P!se;M{$Jw*cy-_QkDT-W!iRgrWLOT7J#LF(;BD+aSb85Qq*v&27)UCA z02pKMF}*fycaI6QtBYkMX(VZ9k8JPgyoy$x~KU4=-$W4~PtUQ|9_R6gF8^tPnaV9w>N_-4iTjHG8IJv{cT_CBk< zFGzYp(rK{g#PZxU-)S&=?N{F<1}*M@no_3Y7`VtI4gOJ~&{8S`Fa z4_a$)=(IOAwPCivd~Nl|tc%P#UTBDJWd0$+7n!kB7_}C;2f<*8RB@=) zLSrY@7ny!&Q8$sfg+x>$a}WuOBOQZ;b&=jiqHZF!gp^JQ#|~i4Y;9KBHd{{pM7qf* zlvlZ2$cD3KHfkX<$H2@%KScTlEcuK?9YtyjDOn!WUQ!FnTx7zqW;T0opKY%(>M7E# z>`j(8?6sEJsEx>6L*J*`XP-b_Md}K@bV4|G0BdHm_lYCeQ93NrvFMwh595(v_h305 z*#YaD)xM-^XytdMq+e<9r=2;>xlmZMzAbY!Y=<%1&3i=TJt9n!S`HArt^n7mGxd&k zz9Zk66_HtiWP8&IK`$y(2cTs(TVyM3o3Zq5!zYyglThfh;jEd>b!v_U8L}WNlSxSF zGe?s*sp&fy`g{m$R=vHq&$icC`Ut|_{8c6g#9C%^o%&S!>=V+L4tVotmZJx-W;T1D zkIz5+(=TH5&EJ>LefgZ#GQaiBYF|<{G(Id?-<7f<{tfY`ojJ_8P*}4*U(X7Xd{|5t uBrQl #include +#include "mainMenu.h" #include "menu.h" // For lumberjack @@ -12,7 +13,7 @@ #include "lumberjackGame.h" #define LUMBERJACK_VLEN 7 -#define LUMBERJACK_VERSION "231111a" +#define LUMBERJACK_VERSION "231114a" static void lumberjackEnterMode(void); @@ -39,7 +40,9 @@ static bool lumberjackSwadgeGuyUnlocked(void); static const char lumberjackName[] = "Lumber Jack"; static const char lumberjackPanic[] = "Panic"; static const char lumberjackAttack[] = "Attack"; +// static const char lumberjackSmack[] = "Smack"; static const char lumberjackBack[] = "Back"; +static const char lumberjackExit[] = "Exit"; static char lumberjackRedCharacter[] = "Character: Red"; static char lumberjackGreenCharacter[] = "Character: Green"; @@ -112,6 +115,8 @@ static void lumberjackEnterMode(void) addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerClient); lumberjack->menu = endSubMenu(lumberjack->menu); + //addSingleItemToMenu(lumberjack->menu, lumberjackSmack); + int characters = 2; if (lumberjack->save.choUnlocked) @@ -142,16 +147,12 @@ static void lumberjackEnterMode(void) } addMultiItemToMenu(lumberjack->menu, charactersArray, characters, 0); + addSingleItemToMenu(lumberjack->menu, lumberjackExit); lumberjack->screen = LUMBERJACK_MENU; - // Lumberjack. Game 19 - // Init menu :( - bzrStop(true); // Stop the buzzer? - // High score stuff? - // Unlockables ? Save data? } static void lumberjackLoadSave(void) @@ -289,10 +290,10 @@ static bool lumberjackSwadgeGuyUnlocked() static void lumberjackEspNowRecvCb(const esp_now_recv_info_t* esp_now_info, const uint8_t* data, uint8_t len, int8_t rssi) { - //ESP_LOGI(LUM_TAG, "Getting: %d %d", len, rssi); + ESP_LOGI(LUM_TAG, "Getting: %d %d", len, rssi); for (int i = 0; i < len; i++) { - //ESP_LOGI(LUM_TAG, "data %d) %d", i, data[i]); + ESP_LOGI(LUM_TAG, "data %d) %d", i, data[i]); } p2pRecvCb(&lumberjack->p2p, esp_now_info->src_addr, (const uint8_t*)data, len, rssi); } @@ -492,6 +493,10 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV lumberjack->host = false; lumberjackJoinGame(); } + else if (label == lumberjackExit) + { + switchToSwadgeMode(&mainMenuMode); + } if (label == lumberjackRedCharacter) { diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index cc276082b..7738b19a5 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -225,6 +225,7 @@ typedef struct song_t song_theme; song_t song_respawn; song_t song_gameover; + song_t song_title; } lumberjackVars_t; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index ac71e00c1..eeda5dca5 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -394,11 +394,13 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) if (lumv->gameType == LUMBERJACK_MODE_ATTACK) { loadSong("l_sfx_upgrade.sng", &lumv->sfx_item_use, false); + loadSong("l_song_attack_title.sng", &lumv->song_title, false); loadSong("l_song_attack.sng", &lumv->song_theme, false); } else { loadSong("l_song_panic.sng", &lumv->song_theme, false); + loadSong("l_song_panic_title.sng", &lumv->song_title, false); loadSong("l_sfx_water.sng", &lumv->sfx_item_use, false); } @@ -412,7 +414,10 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadSong("l_song_respawn.sng", &lumv->song_respawn, false); loadSong("l_song_gameover.sng", &lumv->song_gameover, false); lumv->song_theme.shouldLoop = true; + lumv->song_title.shouldLoop = true; + bzrPlayBgm(&lumv->song_title, BZR_STEREO); + } bool lumberjackLoadLevel() @@ -2815,6 +2820,11 @@ void lumberjackExitGameMode(void) { bzrStop(true); + // Everything crashes if you don't load it first + if (lumv == NULL) + return; + + if (lumv->lumberjackMain->networked == false) { @@ -2829,11 +2839,6 @@ void lumberjackExitGameMode(void) } lumberjackSaveSave(); } - - // Everything crashes if you don't load it first - if (lumv == NULL) - return; - //** FREE THE SPRITES **// freeWsg(&lumv->gameoverSprite); @@ -2854,6 +2859,7 @@ void lumberjackExitGameMode(void) freeSong(&lumv->sfx_enemy_death); freeSong(&lumv->song_theme); + freeSong(&lumv->song_title); freeSong(&lumv->song_respawn); freeSong(&lumv->song_gameover); diff --git a/main/modes/mainMenu/mainMenu.c b/main/modes/mainMenu/mainMenu.c index 3a6c786b5..91ef3cc75 100644 --- a/main/modes/mainMenu/mainMenu.c +++ b/main/modes/mainMenu/mainMenu.c @@ -330,7 +330,7 @@ static void mainMenuCb(const char* label, bool selected, uint32_t settingVal) } else if (label == sokoMode.modeName) { - switchToSwadgeMode(&sokoMode); + switchToSwadgeMode(&demoMode); } else if (label == touchTestMode.modeName) { From bf1ce7283e512b15f82200744f3372a6da909f05 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Wed, 15 Nov 2023 09:20:49 -0800 Subject: [PATCH 40/54] Applying memory leak fixes from Adam Removed spammy ESP_LOGI Removed some unnecessary variables --- main/modes/lumberjack/lumberjack.c | 6 +- main/modes/lumberjack/lumberjack.h | 1 + main/modes/lumberjack/lumberjackGame.c | 97 +++++++++++--------------- 3 files changed, 47 insertions(+), 57 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index d8584114b..d41cdda5e 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -37,7 +37,7 @@ static void lumberjackJoinGame(void); static bool lumberjackChoUnlocked(void); static bool lumberjackSwadgeGuyUnlocked(void); -static const char lumberjackName[] = "Lumber Jack"; +static const char lumberjackName[] = "Lumber Jacks"; static const char lumberjackPanic[] = "Panic"; static const char lumberjackAttack[] = "Attack"; // static const char lumberjackSmack[] = "Smack"; @@ -219,11 +219,13 @@ static void lumberjackJoinGame(void) static void lumberjackExitMode(void) { + lumberjackUnloadLevel(); lumberjackExitGameMode(); - + free(lumberjack->charactersArray); p2pDeinit(&lumberjack->p2p); freeFont(&lumberjack->logbook); deinitMenu(lumberjack->menu); + deinitMenuLogbookRenderer(lumberjack->menuLogbookRenderer); free(lumberjack); } diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index 7738b19a5..b5a451f1c 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -57,6 +57,7 @@ typedef struct lumberjackGameType_t gameMode; lumberjackUnlock_t save; + const char** charactersArray; } lumberjack_t; typedef struct diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index eeda5dca5..a6c0856ff 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -58,7 +58,6 @@ #define LUMBERJACK_ITEM_RESETTIME 2500 #define LUMBERJACK_INVINCIBLE_TIME 7000 -#define LUMBERJACK_INVINCIBLE_SPEED 100000 #define LUMBERJACK_COMBO_RESET_TIME 1500 #define LUMBERJACK_TILE_SIZE 16 @@ -112,7 +111,6 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->itemBlockIndex = -1; lumv->itemBlockItemAnimation = 0; - //ESP_LOGI(LUM_TAG, "Load Title"); loadWsg("lumbers_title.wsg", &lumv->title, true); if (main->screen == LUMBERJACK_A) @@ -143,7 +141,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_conn_lost.wsg", &lumv->connectLostSprite, true); } - //ESP_LOGI(LUM_TAG, "Loading floor Tiles"); + // Loading floor Tiles loadWsg("lumbers_bottom_floor1.wsg", &lumv->floorTiles[0], true); loadWsg("lumbers_bottom_floor2.wsg", &lumv->floorTiles[1], true); loadWsg("lumbers_bottom_floor3.wsg", &lumv->floorTiles[2], true); @@ -156,8 +154,8 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_bottom_floor10.wsg", &lumv->floorTiles[9], true); loadWsg("lumbers_itemused_block.wsg", &lumv->floorTiles[10], true); loadWsg("lumbers_rtile_1.wsg", &lumv->floorTiles[11], true); - //ESP_LOGI(LUM_TAG, "Loading Animation Tiles"); + //Loading Animation Tiles loadWsg("lumbers_water_floor1.wsg", &lumv->animationTiles[0], true); loadWsg("lumbers_water_floor2.wsg", &lumv->animationTiles[1], true); loadWsg("lumbers_water_floor3.wsg", &lumv->animationTiles[2], true); @@ -177,15 +175,15 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) - //ESP_LOGI(LUM_TAG, "Loading Characters"); - //ESP_LOGI(LUM_TAG, "*Loading character icons"); + //Loading Characters + //*Loading character icons loadWsg("lumbers_red_lives.wsg", &lumv->minicharacters[0], true); loadWsg("lumbers_green_lives.wsg", &lumv->minicharacters[1], true); loadWsg("lumbers_swadgeland_lives.wsg", &lumv->minicharacters[2], true); loadWsg("lumbers_cho_lives.wsg", &lumv->minicharacters[3], true); - //ESP_LOGI(LUM_TAG, "*Loading character sprites"); + //*Loading character sprites if (characterIndex == 0) { loadWsg("lumbers_red_1.wsg", &lumv->playerSprites[0], true); @@ -280,7 +278,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) } - //ESP_LOGI(LUM_TAG, "Loading Enemies"); + //Loading Enemies loadWsg("lumbers_enemy_a1.wsg", &lumv->enemySprites[0], true); loadWsg("lumbers_enemy_a2.wsg", &lumv->enemySprites[1], true); loadWsg("lumbers_enemy_a3.wsg", &lumv->enemySprites[2], true); @@ -495,7 +493,6 @@ bool lumberjackLoadLevel() size_t ms; uint8_t *buffer = spiffsReadFile(fname, &ms, false); - ESP_LOGI(LUM_TAG, "Level = %s", fname); // Buffer 0 = map height lumv->tile = (lumberjackTile_t*)malloc((int)buffer[0] * LUMBERJACK_MAP_WIDTH * sizeof(lumberjackTile_t)); lumv->currentMapHeight = (int)buffer[0]; @@ -566,15 +563,11 @@ bool lumberjackLoadLevel() } int offset = (lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH) + 12; - ESP_LOGI (LUM_TAG, "%d total enemies",lumv->totalEnemyCount); - ESP_LOGI (LUM_TAG, "%d ", lumv->currentMapHeight* LUMBERJACK_TILE_SIZE); - + lumv->playerSpawnX = (int)buffer[offset]; lumv->playerSpawnY = (int)buffer[offset + 1] + ((int)buffer[offset + 2] << 8); //lumv->yOffset = lumv->playerSpawnY - LUMBERJACK_SCREEN_Y_OFFSET; - ESP_LOGI(LUM_TAG, "SPAWN %d %d", lumv->playerSpawnY, buffer[offset]); - free(buffer); return true; @@ -590,7 +583,7 @@ void lumberjackSetupLevel(int characterIndex) lumv->wakeupSignal = 0; lumv->lastResponseSignal = 1000; - ESP_LOGI(LUM_TAG, "LOADING LEVEL"); + //LOADING LEVEL lumberjackLoadLevel(); // This all to be loaded externally @@ -738,7 +731,7 @@ void lumberjackSetupLevel(int characterIndex) //Ghost is separate for reasons - ESP_LOGI(LUM_TAG, "LOADED"); + //ESP_LOGI(LUM_TAG, "LOADED"); if (!lumv->levelMusic) { bzrPlayBgm(&lumv->song_theme, BZR_STEREO); @@ -750,6 +743,7 @@ void lumberjackSetupLevel(int characterIndex) void lumberjackUnloadLevel(void) { free(lumv->tile); + free(lumv->localPlayer); //Unload previous enemies for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) @@ -844,7 +838,6 @@ void lumberjackGameLoop(int64_t elapsedUs) if (lumv->levelTime > 3000) { - ESP_LOGI(LUM_TAG, "Next level"); lumberjackUnloadLevel(); lumberjackSetupLevel(lumv->localPlayerType); @@ -871,7 +864,7 @@ void lumberjackGameLoop(int64_t elapsedUs) if (lumv->lastResponseSignal <= 0) { bzrStop(true); - ESP_LOGI(LUM_TAG, "Connection lost!"); + //ESP_LOGI(LUM_TAG, "Connection lost!"); lumv->gameState = LUMBERJACK_GAMESTATE_GAMEOVER; lumv->transitionTimer = 500; lumv->localPlayer->state = LUMBERJACK_DEAD; @@ -1008,9 +1001,7 @@ void baseMode(int64_t elapsedUs) if (lumv->comboTime < 0) { lumv->comboTime = 0; - ESP_LOGI(LUM_TAG, "Combo end! %d", lumv->comboAmount); - - + if (lumv->lumberjackMain->networked && lumv->comboAmount > 0) { @@ -1035,7 +1026,7 @@ void baseMode(int64_t elapsedUs) if (!attackThisFrame && lumv->localPlayer->attackPressed) { - ESP_LOGI(LUM_TAG, "Attack this frame!"); + // ESP_LOGI(LUM_TAG, "Attack this frame!"); int x = 0; for (int i = 0; i < 32; i ++) { @@ -1043,11 +1034,7 @@ void baseMode(int64_t elapsedUs) { x++; } - } - ESP_LOGI(LUM_TAG, "%d", x); - - //lumberjackSendAttack(lumv->attackQueue); - + } if (lumv->gameType == LUMBERJACK_MODE_ATTACK && lumv->itemBlockIndex != -1) { @@ -1106,7 +1093,6 @@ void baseMode(int64_t elapsedUs) if (lumv->itemBlockIndex >= 2) { - ESP_LOGI(LUM_TAG, "2" ); //Pear - Invincible lumv->invincibleTimer = LUMBERJACK_INVINCIBLE_TIME; } @@ -1200,7 +1186,6 @@ void baseMode(int64_t elapsedUs) if (enemyKilled >= lumv->totalEnemyCount) { - ESP_LOGI("LUM","UPGRADE"); for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) { if (lumv->enemy[i] == NULL || lumv->enemy[i]->queueable == false) continue; @@ -1326,7 +1311,7 @@ void baseMode(int64_t elapsedUs) if (lumv->localPlayer->respawn <= 0 && lumv->lives > 0) { - ESP_LOGI(LUM_TAG, "RESPAWN PLAYER!"); + //ESP_LOGI(LUM_TAG, "RESPAWN PLAYER!"); bzrStop(true); bzrPlaySfx(&lumv->song_respawn, BZR_RIGHT); @@ -1362,7 +1347,6 @@ void baseMode(int64_t elapsedUs) if (lumv->comboTime > 0) { - ESP_LOGI(LUM_TAG, "COMBO!"); ++lumv->comboAmount; lumv->activeBonusIndex++; @@ -1437,7 +1421,6 @@ void baseMode(int64_t elapsedUs) else if (lumv->invincibleTimer <= 0) { // Kill player - // ESP_LOGI(LUM_TAG, "KILL PLAYER"); lumberjackOnLocalPlayerDeath(); } @@ -1660,7 +1643,6 @@ void DrawGame(void) if (lumv->localPlayer->state == LUMBERJACK_DEAD) { - // ESP_LOGI(LUM_TAG, "DEAD %d", currentFrame); // If panic mode if (lumv->gameType == LUMBERJACK_MODE_PANIC) @@ -1744,7 +1726,6 @@ void DrawGame(void) } else if (lumv->hasWon) { - ESP_LOGI(LUM_TAG, "%d lrs", lumv->lastResponseSignal); drawWsgSimple(&lumv->gamewinSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); } else @@ -1981,7 +1962,6 @@ void lumberjackOnReceiveAttack(const uint8_t* attack, int len) { for (int i = 1; i < len; i++) { - ESP_LOGI(LUM_TAG, "Attacky! %d) %d", i, attack[i]); int rem = attack[i]; for (int n = 0; n < ARRAY_SIZE(lumv->enemy); n++) { @@ -2014,13 +1994,11 @@ void lumberjackOnReceiveAttack(const uint8_t* attack, int len) void lumberjackOnReceiveScore(const uint8_t* score) { int locX = (int)score[1] << 0 | (uint32_t)score[2] << 8 | (uint32_t)score[3] << 16; - ESP_LOGI(LUM_TAG, "SCORE: %d", locX); lumv->highscore = locX; } void lumberjackOnReceiveBump(void) { - ESP_LOGI(LUM_TAG, "BUMP!"); if (lumv->localPlayer->onGround) { lumv->localPlayer->vy = -20; //HERE @@ -2054,7 +2032,6 @@ void lumberjackOnReceiveBump(void) void lumberjackOnReceiveDeath(bool gameover) { - ESP_LOGI(LUM_TAG, "Player died! Haha %d", (gameover)); if (gameover) { @@ -2305,11 +2282,6 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs entity->onGround = onGround; - if (entity->vx > entity->maxVX) - { - // ESP_LOGI(LUM_TAG, "ERROR"); - } - entity->x = destinationX; entity->y = destinationY; @@ -2324,7 +2296,6 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs { if (entity->respawn == 0) { - // ESP_LOGI(LUM_TAG, "DEAD & hit the ground %d", entity->respawn); entity->respawn = LUMBERJACK_UPGRADE_TIMER_OFFSET; entity->ready = true; @@ -2404,7 +2375,6 @@ void lumberjackUpdate(int64_t elapseUs) { if ((lumv->ghost->x < -28 && lumv->ghost->startSide > 0) || (lumv->ghost->x > 290 && lumv->ghost->startSide < 0 )) { - ESP_LOGI(LUM_TAG, "Remove ghost!"); lumv->ghost->active = false; } } @@ -2645,7 +2615,6 @@ bool lumberjackDetectBump(lumberjackTile_t* tile) void lumberjackUseBlock() { lumv->itemBlockReady = false; - ESP_LOGI(LUM_TAG, "JACKED"); if (lumv->gameType == LUMBERJACK_MODE_PANIC) { @@ -2862,10 +2831,7 @@ void lumberjackExitGameMode(void) freeSong(&lumv->song_title); freeSong(&lumv->song_respawn); freeSong(&lumv->song_gameover); - - - - + // Free the bonus for (int i = 0; i < ARRAY_SIZE(lumv->bonusDisplay); i++) @@ -2916,15 +2882,36 @@ void lumberjackExitGameMode(void) free(lumv->axeBlocks[i]); } + for (int i = 0; i < ARRAY_SIZE(lumv->itemIcons); i++) + { + freeWsg(&lumv->itemIcons[i]); + } - if (lumv->gameType == LUMBERJACK_MODE_ATTACK) + for (int i = 0; i < ARRAY_SIZE(lumv->floorTiles); i++) { - for (int i = 0; i < ARRAY_SIZE(lumv->itemIcons); i++) - { - freeWsg(&lumv->itemIcons[i]); - } + freeWsg(&lumv->floorTiles[i]); + } + + for (int i = 0; i < ARRAY_SIZE(lumv->bonusSprites); i++) + { + freeWsg(&lumv->bonusSprites[i]); + } + + for (int i = 0; i < ARRAY_SIZE(lumv->minicharacters); i++) + { + freeWsg(&lumv->minicharacters[i]); } + for (int i = 0; i < ARRAY_SIZE(lumv->ui); i++) + { + freeWsg(&lumv->ui[i]); + } + + freeWsg(&lumv->title); + freeWsg(&lumv->subtitle_red); + freeWsg(&lumv->subtitle_green); + freeWsg(&lumv->subtitle_white); + freeFont(&lumv->arcade); free(lumv); } \ No newline at end of file From 7253951ce9d9faa383ef330c6dd43e346d764c39 Mon Sep 17 00:00:00 2001 From: gelakinetic Date: Wed, 15 Nov 2023 18:52:20 -0500 Subject: [PATCH 41/54] Use charactersArray in lumberjack_t Don't use lumv after free --- main/modes/lumberjack/lumberjack.c | 12 ++++++------ main/modes/lumberjack/lumberjackGame.c | 24 ++++++++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index d41cdda5e..aa14676cb 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -129,24 +129,24 @@ static void lumberjackEnterMode(void) characters++; } - const char** charactersArray = calloc(characters, sizeof(char*)); + lumberjack->charactersArray = calloc(characters, sizeof(char*)); - charactersArray[0] = lumberjackRedCharacter; - charactersArray[1] = lumberjackGreenCharacter; + lumberjack->charactersArray[0] = lumberjackRedCharacter; + lumberjack->charactersArray[1] = lumberjackGreenCharacter; int index = 2; if (lumberjack->save.choUnlocked) { - charactersArray[index++] = lumberjackChoCharacter; + lumberjack->charactersArray[index++] = lumberjackChoCharacter; } if (lumberjack->save.swadgeGuyUnlocked) { - charactersArray[index++] = lumberjackSpecialCharacter; + lumberjack->charactersArray[index++] = lumberjackSpecialCharacter; } - addMultiItemToMenu(lumberjack->menu, charactersArray, characters, 0); + addMultiItemToMenu(lumberjack->menu, lumberjack->charactersArray, characters, 0); addSingleItemToMenu(lumberjack->menu, lumberjackExit); lumberjack->screen = LUMBERJACK_MENU; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index a6c0856ff..26316ce5d 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -742,18 +742,21 @@ void lumberjackSetupLevel(int characterIndex) void lumberjackUnloadLevel(void) { - free(lumv->tile); - free(lumv->localPlayer); - - //Unload previous enemies - for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + if(NULL != lumv) { - free(lumv->enemy[i]); - lumv->enemy[i] = NULL; - } + free(lumv->tile); + free(lumv->localPlayer); - free(lumv->ghost); - lumv->ghost = NULL; + //Unload previous enemies + for (int i = 0; i < ARRAY_SIZE(lumv->enemy); i++) + { + free(lumv->enemy[i]); + lumv->enemy[i] = NULL; + } + + free(lumv->ghost); + lumv->ghost = NULL; + } } /** @@ -2914,4 +2917,5 @@ void lumberjackExitGameMode(void) freeFont(&lumv->arcade); free(lumv); + lumv = NULL; } \ No newline at end of file From 39a2ab8f05c9b20a3c0ccff69b6cf46fa1688dd3 Mon Sep 17 00:00:00 2001 From: gelakinetic Date: Wed, 15 Nov 2023 21:32:28 -0500 Subject: [PATCH 42/54] Fix networking in emulator --- main/swadge2024.c | 81 +++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/main/swadge2024.c b/main/swadge2024.c index 3e427cc82..5f8001413 100644 --- a/main/swadge2024.c +++ b/main/swadge2024.c @@ -191,6 +191,7 @@ static void swadgeModeEspNowRecvCb(const esp_now_recv_info_t* esp_now_info, cons int8_t rssi); static void swadgeModeEspNowSendCb(const uint8_t* mac_addr, esp_now_send_status_t status); static void setSwadgeMode(void* swadgeMode); +static void initOptionalPeripherals(void); //============================================================================== // Functions @@ -268,17 +269,6 @@ void app_main(void) initBuzzer(GPIO_NUM_40, LEDC_TIMER_0, LEDC_CHANNEL_0, // GPIO_NUM_42, LEDC_TIMER_1, LEDC_CHANNEL_1, getBgmVolumeSetting(), getSfxVolumeSetting()); - // Init mic if it is used by the mode - if (NULL != cSwadgeMode->fnAudioCallback) - { - initMic(GPIO_NUM_7); - startMic(); - } - else - { - initBattmon(GPIO_NUM_6); - } - // Init TFT, use a different LEDC channel than buzzer initTFT(SPI2_HOST, GPIO_NUM_36, // sclk @@ -295,27 +285,8 @@ void app_main(void) // Initialize the RGB LEDs initLeds(GPIO_NUM_39, GPIO_NUM_18, getLedBrightnessSetting()); - // Init esp-now if requested by the mode - if ((ESP_NOW == cSwadgeMode->wifiMode) || (ESP_NOW_IMMEDIATE == cSwadgeMode->wifiMode)) - { - initEspNow(&swadgeModeEspNowRecvCb, &swadgeModeEspNowSendCb, GPIO_NUM_NC, GPIO_NUM_NC, UART_NUM_MAX, - cSwadgeMode->wifiMode); - } - - // Init accelerometer - if (cSwadgeMode->usesAccelerometer) - { - initAccelerometer(GPIO_NUM_3, // SDA - GPIO_NUM_41, // SCL - GPIO_PULLUP_ENABLE); - accelIntegrate(); - } - - // Init the temperature sensor - if (cSwadgeMode->usesThermometer) - { - initTemperatureSensor(); - } + // Initialize optional peripherals, depending on the mode's requests + initOptionalPeripherals(); // Initialize the loop timer static int64_t tLastLoopUs = 0; @@ -473,6 +444,45 @@ void app_main(void) deinitSystem(); } +/** + * @brief Initialize optional hardware peripherals for this Swadge mode + */ +static void initOptionalPeripherals(void) +{ + // Init mic if it is used by the mode + if (NULL != cSwadgeMode->fnAudioCallback) + { + initMic(GPIO_NUM_7); + startMic(); + } + else + { + initBattmon(GPIO_NUM_6); + } + + // Init esp-now if requested by the mode + if ((ESP_NOW == cSwadgeMode->wifiMode) || (ESP_NOW_IMMEDIATE == cSwadgeMode->wifiMode)) + { + initEspNow(&swadgeModeEspNowRecvCb, &swadgeModeEspNowSendCb, GPIO_NUM_NC, GPIO_NUM_NC, UART_NUM_MAX, + cSwadgeMode->wifiMode); + } + + // Init accelerometer + if (cSwadgeMode->usesAccelerometer) + { + initAccelerometer(GPIO_NUM_3, // SDA + GPIO_NUM_41, // SCL + GPIO_PULLUP_ENABLE); + accelIntegrate(); + } + + // Init the temperature sensor + if (cSwadgeMode->usesThermometer) + { + initTemperatureSensor(); + } +} + /** * @brief Deinitialize all components in the system */ @@ -591,11 +601,8 @@ void softSwitchToPendingSwadge(void) cSwadgeMode = pendingSwadgeMode; pendingSwadgeMode = NULL; - // Start mic if requested - if (NULL != cSwadgeMode->fnAudioCallback) - { - startMic(); - } + // Initialize optional peripherals for this mode + initOptionalPeripherals(); // Enter the next mode if (NULL != cSwadgeMode->fnEnterMode) From 89cadbde73a4e9b4c01f460c7fdecfefaa7908b9 Mon Sep 17 00:00:00 2001 From: gelakinetic Date: Thu, 16 Nov 2023 00:53:04 -0500 Subject: [PATCH 43/54] Make P2P easier to debug --- main/utils/p2pConnection.c | 150 ++++++++++++++++++++----------------- 1 file changed, 83 insertions(+), 67 deletions(-) diff --git a/main/utils/p2pConnection.c b/main/utils/p2pConnection.c index a797f482b..53e2d1c4d 100644 --- a/main/utils/p2pConnection.c +++ b/main/utils/p2pConnection.c @@ -26,6 +26,14 @@ // (240 steps of rotation + (252/4) steps of decay) * 12ms #define FAILURE_RESTART_US 8000000 +// #define P2P_DEBUG +#ifdef P2P_DEBUG + static const char* P2P_TAG = "P2P"; + #define P2P_LOG(...) ESP_LOGI(P2P_TAG, ##__VA_ARGS__) +#else + #define P2P_LOG(...) +#endif + //============================================================================== // Function Prototypes //============================================================================== @@ -63,7 +71,7 @@ static void p2pModeMsgFailure(p2pInfo* p2p); */ void p2pInitialize(p2pInfo* p2p, uint8_t modeId, p2pConCbFn conCbFn, p2pMsgRxCbFn msgRxCbFn, int8_t connectionRssi) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); // Make sure everything is zero! memset(p2p, 0, sizeof(p2pInfo)); @@ -166,7 +174,7 @@ void p2pSetAsymmetric(p2pInfo* p2p, uint8_t incomingModeId) */ void p2pStartConnection(p2pInfo* p2p) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); p2p->cnc.isActive = true; esp_timer_start_once(p2p->tmr.Connection, 1000); @@ -184,7 +192,7 @@ void p2pStartConnection(p2pInfo* p2p) */ void p2pDeinit(p2pInfo* p2p) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); if (NULL != p2p->tmr.Connection) { @@ -206,7 +214,7 @@ void p2pDeinit(p2pInfo* p2p) */ static void p2pConnectionTimeout(void* arg) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); p2pInfo* p2p = (p2pInfo*)arg; // Send a connection broadcast @@ -216,7 +224,7 @@ static void p2pConnectionTimeout(void* arg) uint32_t timeoutUs = 1000 * (100 * (5 + (esp_random() % 11))); // Start the timer again - // ESP_LOGD("P2P", "retry broadcast in %dus", timeoutUs); + P2P_LOG("retry broadcast in %"PRIu32"us", timeoutUs); esp_timer_start_once(p2p->tmr.Connection, timeoutUs); } @@ -230,13 +238,13 @@ static void p2pConnectionTimeout(void* arg) */ static void p2pTxRetryTimeout(void* arg) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); p2pInfo* p2p = (p2pInfo*)arg; if (p2p->ack.msgToAckLen > 0) { - // ESP_LOGD("P2P", "Retrying message"); + P2P_LOG("Retrying message"); p2pSendMsgEx(p2p, (uint8_t*)&p2p->ack.msgToAck, p2p->ack.msgToAckLen, true, p2p->ack.SuccessFn, p2p->ack.FailureFn); } @@ -253,7 +261,7 @@ static void p2pTxRetryTimeout(void* arg) */ static void p2pTxAllRetriesTimeout(void* arg) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); p2pInfo* p2p = (p2pInfo*)arg; @@ -262,7 +270,7 @@ static void p2pTxAllRetriesTimeout(void* arg) esp_timer_stop(p2p->tmr.TxAllRetries); // Call the failure function - // ESP_LOGD("P2P", "Message totally failed"); + P2P_LOG("Message totally failed"); if (NULL != p2p->ack.FailureFn) { p2p->ack.FailureFn(p2p); @@ -284,7 +292,7 @@ static void p2pTxAllRetriesTimeout(void* arg) */ void p2pSendMsg(p2pInfo* p2p, const uint8_t* payload, uint16_t len, p2pMsgTxCbFn msgTxCbFn) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); p2pDataMsg_t builtMsg = {0}; uint8_t builtMsgLen = sizeof(p2pCommonHeader_t); @@ -318,7 +326,7 @@ void p2pSendMsg(p2pInfo* p2p, const uint8_t* payload, uint16_t len, p2pMsgTxCbFn */ static void p2pModeMsgSuccess(p2pInfo* p2p, const uint8_t* data, uint8_t dataLen) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); if (NULL != p2p->msgTxCbFn) { @@ -334,7 +342,7 @@ static void p2pModeMsgSuccess(p2pInfo* p2p, const uint8_t* data, uint8_t dataLen */ static void p2pModeMsgFailure(p2pInfo* p2p) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); if (NULL != p2p->msgTxCbFn) { @@ -356,15 +364,17 @@ static void p2pModeMsgFailure(p2pInfo* p2p) static void p2pSendMsgEx(p2pInfo* p2p, uint8_t* msg, uint16_t len, bool shouldAck, p2pAckSuccessFn success, p2pAckFailureFn failure) { - // char dbgStr[12 + 2 + 2 + (len*3)]; - // sprintf(dbgStr, "%12s: ", __func__); - // for(int i = 0; i < len; i++) - // { - // char tmp[8]; - // sprintf(tmp, "%02X ", msg[i]); - // strcat(dbgStr, tmp); - // } - // ESP_LOGD("P2P", "%s", dbgStr); +#ifdef P2P_DEBUG + char dbgStr[12 + 2 + 2 + (len*3)]; + sprintf(dbgStr, "%12s: ", __func__); + for(int i = 0; i < len; i++) + { + char tmp[8]; + sprintf(tmp, "%02X ", msg[i]); + strcat(dbgStr, tmp); + } + P2P_LOG("%s", dbgStr); +#endif // If this is a first time message and longer than a connection message if (((void*)&(p2p->ack.msgToAck) != (void*)msg) && sizeof(p2pConMsg_t) < len) @@ -384,7 +394,7 @@ static void p2pSendMsgEx(p2pInfo* p2p, uint8_t* msg, uint16_t len, bool shouldAc // If this is not a retry if ((void*)&(p2p->ack.msgToAck) != (void*)msg) { - // ESP_LOGD("P2P", "sending for the first time"); + P2P_LOG("sending for the first time"); // Store the message for potential retries memcpy(&(p2p->ack.msgToAck), msg, len); @@ -398,7 +408,7 @@ static void p2pSendMsgEx(p2pInfo* p2p, uint8_t* msg, uint16_t len, bool shouldAc } else { - // ESP_LOGD("P2P", "this is a retry"); + P2P_LOG("this is a retry"); } // Mark the time this transmission started, the retry timer gets @@ -425,28 +435,30 @@ void p2pRecvCb(p2pInfo* p2p, const uint8_t* mac_addr, const uint8_t* data, uint8 return; } - // char dbgStr[12 + 3 + 5 + 17 + (len*3)]; - // sprintf(dbgStr, "%12s - From %02X:%02X:%02X:%02X:%02X:%02X - ", __func__, - // mac_addr[0], - // mac_addr[1], - // mac_addr[2], - // mac_addr[3], - // mac_addr[4], - // mac_addr[5]); - // for(int i = 0; i < len; i++) - // { - // char tmp[8]; - // sprintf(tmp, "%02X ", data[i]); - // strcat(dbgStr, tmp); - // } - // ESP_LOGD("P2P", "%s", dbgStr); +#ifdef P2P_DEBUG + char dbgStr[64 + (len*3)]; + sprintf(dbgStr, "%12s - From %02X:%02X:%02X:%02X:%02X:%02X - ", __func__, + mac_addr[0], + mac_addr[1], + mac_addr[2], + mac_addr[3], + mac_addr[4], + mac_addr[5]); + for(int i = 0; i < len; i++) + { + char tmp[8]; + sprintf(tmp, "%02X ", data[i]); + strcat(dbgStr, tmp); + } + P2P_LOG("%s", dbgStr); +#endif // Check if this message matches our message ID if (len < sizeof(p2pConMsg_t) || ((const p2pConMsg_t*)data)->startByte != P2P_START_BYTE || ((const p2pConMsg_t*)data)->modeId != p2p->incomingModeId) { // This message is too short, or does not match our message ID - // ESP_LOGD("P2P", "DISCARD: Not a message for '%c'", p2p->modeId); + P2P_LOG("DISCARD: Not a message for '%c'", p2p->modeId); return; } @@ -456,17 +468,19 @@ void p2pRecvCb(p2pInfo* p2p, const uint8_t* mac_addr, const uint8_t* data, uint8 // If this message has a MAC, check it if (len >= sizeof(p2pCommonHeader_t) && 0 != memcmp(p2pHdr->macAddr, p2p->cnc.myMac, sizeof(p2p->cnc.myMac))) { +#ifdef P2P_DEBUG // This MAC isn't for us - // ESP_LOGD("P2P", "DISCARD: Not for our MAC."); - // ESP_LOGD("P2P", " Our MAC: %02X:%02X:%02X:%02X:%02X:%02X", - // p2p->cnc.myMac[0], p2p->cnc.myMac[1], - // p2p->cnc.myMac[2], p2p->cnc.myMac[3], - // p2p->cnc.myMac[4], p2p->cnc.myMac[5]); - // const p2pCommonHeader_t* hdr = (const p2pCommonHeader_t*)data; - // ESP_LOGD("P2P", " rx MAC: %02X:%02X:%02X:%02X:%02X:%02X", - // hdr->macAddr[0], hdr->macAddr[1], - // hdr->macAddr[2], hdr->macAddr[3], - // hdr->macAddr[4], hdr->macAddr[5]); + P2P_LOG("DISCARD: Not for our MAC."); + P2P_LOG(" Our MAC: %02X:%02X:%02X:%02X:%02X:%02X", + p2p->cnc.myMac[0], p2p->cnc.myMac[1], + p2p->cnc.myMac[2], p2p->cnc.myMac[3], + p2p->cnc.myMac[4], p2p->cnc.myMac[5]); + const p2pCommonHeader_t* hdr = (const p2pCommonHeader_t*)data; + P2P_LOG(" rx MAC: %02X:%02X:%02X:%02X:%02X:%02X", + hdr->macAddr[0], hdr->macAddr[1], + hdr->macAddr[2], hdr->macAddr[3], + hdr->macAddr[4], hdr->macAddr[5]); +#endif return; } @@ -475,7 +489,7 @@ void p2pRecvCb(p2pInfo* p2p, const uint8_t* mac_addr, const uint8_t* data, uint8 && 0 != memcmp(mac_addr, p2p->cnc.otherMac, sizeof(p2p->cnc.otherMac))) { // This isn't from the other known swadge - // ESP_LOGD("P2P", "DISCARD: Not from the other MAC"); + P2P_LOG("DISCARD: Not from the other MAC"); return; } @@ -494,13 +508,13 @@ void p2pRecvCb(p2pInfo* p2p, const uint8_t* mac_addr, const uint8_t* data, uint8 // Check it against the last known sequence number if (p2pHdr->seqNum == p2p->cnc.lastSeqNum) { - // ESP_LOGD("P2P", "DISCARD: Duplicate sequence number"); + P2P_LOG("DISCARD: Duplicate sequence number"); return; } else { p2p->cnc.lastSeqNum = p2pHdr->seqNum; - // ESP_LOGD("P2P", "Store lastSeqNum %d", p2p->cnc.lastSeqNum); + P2P_LOG("Store lastSeqNum %"PRIu8, p2p->cnc.lastSeqNum); } } @@ -510,7 +524,7 @@ void p2pRecvCb(p2pInfo* p2p, const uint8_t* mac_addr, const uint8_t* data, uint8 // ACKs can be received in any state if (p2p->ack.isWaitingForAck && isAck) { - // ESP_LOGD("P2P", "ACK Received when waiting for one"); + P2P_LOG("ACK Received when waiting for one"); // Save the function pointer to call it after clearing ACK vars p2pAckSuccessFn tmpSuccessFn = p2p->ack.SuccessFn; @@ -574,7 +588,7 @@ void p2pRecvCb(p2pInfo* p2p, const uint8_t* mac_addr, const uint8_t* data, uint8 // Received a response to our broadcast else if (!p2p->cnc.rxGameStartMsg && sizeof(p2p->startMsg) == len && p2pHdr->messageType == P2P_MSG_START) { - // ESP_LOGD("P2P", "Game start message received, ACKing"); + P2P_LOG("Game start message received, ACKing"); // This is another swadge trying to start a game, which means // they received our p2p->conMsg. First disable our p2p->conMsg @@ -587,11 +601,11 @@ void p2pRecvCb(p2pInfo* p2p, const uint8_t* mac_addr, const uint8_t* data, uint8 } else if (len >= sizeof(p2pCommonHeader_t)) { - // ESP_LOGD("P2P", "cnc.isconnected is true"); + P2P_LOG("cnc.isconnected is true"); // Let the mode handle it if (NULL != p2p->msgRxCbFn) { - // ESP_LOGD("P2P", "letting mode handle message"); + P2P_LOG("letting mode handle message"); // Call the callback p2p->msgRxCbFn(p2p, ((const p2pDataMsg_t*)data)->data, len - sizeof(p2pCommonHeader_t)); @@ -647,7 +661,7 @@ void p2pClearDataInAck(p2pInfo* p2p) */ static void p2pSendAckToMac(p2pInfo* p2p, const uint8_t* mac_addr) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); // Write the destination MAC address // Everything else should already be written @@ -665,7 +679,7 @@ static void p2pSendAckToMac(p2pInfo* p2p, const uint8_t* mac_addr) */ static void p2pGameStartAckRecv(p2pInfo* p2p, const uint8_t* data, uint8_t dataLen) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); p2pProcConnectionEvt(p2p, RX_GAME_START_ACK); } @@ -683,8 +697,8 @@ static void p2pGameStartAckRecv(p2pInfo* p2p, const uint8_t* data, uint8_t dataL */ static void p2pProcConnectionEvt(p2pInfo* p2p, connectionEvt_t event) { - // ESP_LOGD("P2P", "%s evt: %d, p2p->cnc.rxGameStartMsg %d, p2p->cnc.rxGameStartAck %d", __func__, event, - // p2p->cnc.rxGameStartMsg, p2p->cnc.rxGameStartAck); + P2P_LOG("%s evt: %"PRId16", p2p->cnc.rxGameStartMsg %s, p2p->cnc.rxGameStartAck %s", __func__, event, + p2p->cnc.rxGameStartMsg ? "true" : "false", p2p->cnc.rxGameStartAck ? "true" : "false"); switch (event) { @@ -755,7 +769,7 @@ static void p2pProcConnectionEvt(p2pInfo* p2p, connectionEvt_t event) */ static void p2pStartRestartTimer(void* arg) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); p2pInfo* p2p = (p2pInfo*)arg; // If the connection isn't established in FAILURE_RESTART_MS, restart @@ -781,7 +795,7 @@ static void p2pRestartTmrCb(void* arg) */ static void p2pRestart(p2pInfo* p2p) { - // ESP_LOGD("P2P", "%s", __func__); + P2P_LOG("%s", __func__); if (NULL != p2p->conCbFn) { @@ -813,8 +827,8 @@ static void p2pRestart(p2pInfo* p2p) */ void p2pSendCb(p2pInfo* p2p, const uint8_t* mac_addr __attribute__((unused)), esp_now_send_status_t status) { - // ESP_LOGD("P2P", "%s - %s", __func__, status == ESP_NOW_SEND_SUCCESS ? "ESP_NOW_SEND_SUCCESS" : - // "ESP_NOW_SEND_FAIL"); + P2P_LOG("%s - %s", __func__, status == ESP_NOW_SEND_SUCCESS ? "ESP_NOW_SEND_SUCCESS" : + "ESP_NOW_SEND_FAIL"); switch (status) { @@ -822,8 +836,10 @@ void p2pSendCb(p2pInfo* p2p, const uint8_t* mac_addr __attribute__((unused)), es { if (0 != p2p->ack.timeSentUs) { - // uint32_t transmissionTimeUs = esp_timer_get_time() - p2p->ack.timeSentUs; - // // ESP_LOGD("P2P", "Transmission time %dus", transmissionTimeUs); +#ifdef P2P_DEBUG + uint32_t transmissionTimeUs = esp_timer_get_time() - p2p->ack.timeSentUs; + P2P_LOG("Transmission time %"PRIu32"us", transmissionTimeUs); +#endif // // The timers are all millisecond, so make sure that // // transmissionTimeUs is at least 1ms // if (transmissionTimeUs < 1000) @@ -839,7 +855,7 @@ void p2pSendCb(p2pInfo* p2p, const uint8_t* mac_addr __attribute__((unused)), es // uint32_t waitTimeUs = 1000 * (((transmissionTimeUs + 500) / 1000) + 69 + (esp_random() & 0b1111)); // Start the timer - // ESP_LOGD("P2P", "ack timer set for %dus", waitTimeUs); + P2P_LOG("ack timer set for %"PRIu32"us", waitTimeUs); esp_timer_start_once(p2p->tmr.TxRetry, waitTimeUs); } break; From 8b8a6b990af9f66845f457f2198c66181baf6fc8 Mon Sep 17 00:00:00 2001 From: gelakinetic Date: Thu, 16 Nov 2023 00:55:41 -0500 Subject: [PATCH 44/54] Make lumberjack p2p symmetrical Start p2p after loading assets to avoid timing issues Properly center text Demote lumberjack debug from I to D --- main/modes/lumberjack/lumberjack.c | 52 +++++++++++--------------- main/modes/lumberjack/lumberjackGame.c | 45 ++++++++++++++-------- main/modes/lumberjack/lumberjackGame.h | 2 +- 3 files changed, 52 insertions(+), 47 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index aa14676cb..2e4c526c9 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -49,9 +49,8 @@ static char lumberjackGreenCharacter[] = "Character: Green"; static char lumberjackSpecialCharacter[] = "Character: Guy"; static char lumberjackChoCharacter[] = "Character: Cho"; -static const char lumberjackMenuSinglePlayer[] = "Single Player"; -static const char lumberjackMenuMultiPlayerHost[] = "Multi-Player"; -static const char lumberjackMenuMultiPlayerClient[] = "Multi-Player Join"; +static const char lumberjackMenuSinglePlayer[] = "Single Player"; +static const char lumberjackMenuMultiPlayer[] = "Multi-Player"; static const char lumberjackPlatformerUnlock[] = "pf_unlocks"; static const char lumberjackChoUnlock[] = "ray"; @@ -105,14 +104,12 @@ static void lumberjackEnterMode(void) lumberjack->menu = startSubMenu(lumberjack->menu, lumberjackPanic); addSingleItemToMenu(lumberjack->menu, lumberjackMenuSinglePlayer); - addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerHost); - addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerClient); + addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayer); lumberjack->menu = endSubMenu(lumberjack->menu); lumberjack->menu = startSubMenu(lumberjack->menu, lumberjackAttack); addSingleItemToMenu(lumberjack->menu, lumberjackMenuSinglePlayer); - addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerHost); - addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerClient); + addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayer); lumberjack->menu = endSubMenu(lumberjack->menu); //addSingleItemToMenu(lumberjack->menu, lumberjackSmack); @@ -292,17 +289,17 @@ static bool lumberjackSwadgeGuyUnlocked() static void lumberjackEspNowRecvCb(const esp_now_recv_info_t* esp_now_info, const uint8_t* data, uint8_t len, int8_t rssi) { - ESP_LOGI(LUM_TAG, "Getting: %d %d", len, rssi); + ESP_LOGD(LUM_TAG, "Getting: %d %d", len, rssi); for (int i = 0; i < len; i++) { - ESP_LOGI(LUM_TAG, "data %d) %d", i, data[i]); + ESP_LOGD(LUM_TAG, "data %d) %d", i, data[i]); } p2pRecvCb(&lumberjack->p2p, esp_now_info->src_addr, (const uint8_t*)data, len, rssi); } static void lumberjackEspNowSendCb(const uint8_t* mac_addr, esp_now_send_status_t status) { - //ESP_LOGI(LUM_TAG, "STATUS %d", status); + //ESP_LOGD(LUM_TAG, "STATUS %d", status); p2pSendCb(&lumberjack->p2p, mac_addr, status); } @@ -311,7 +308,8 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) // Do anything if (evt == CON_ESTABLISHED) { - ESP_LOGI(LUM_TAG, "LumberJack.Net ready! %d", (int)p2pGetPlayOrder(p2p)); + ESP_LOGD(LUM_TAG, "LumberJack.Net ready! %d", (int)p2pGetPlayOrder(p2p)); + lumberjack->host = (GOING_FIRST == p2pGetPlayOrder(p2p)); uint8_t payload[1 + LUMBERJACK_VLEN] = {VERSION_MSG}; memcpy(&payload[1], LUMBERJACK_VERSION, LUMBERJACK_VLEN); @@ -323,7 +321,7 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) if (evt == CON_LOST) { // Do we attempt to get it back? - ESP_LOGI(LUM_TAG, "We lost connection!"); + ESP_LOGD(LUM_TAG, "We lost connection!"); } lumberjack->conStatus = evt; @@ -332,7 +330,7 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) { // Do anything - ESP_LOGI(LUM_TAG, "Ya boi got something! %d", (uint8_t)payload[0]); + ESP_LOGD(LUM_TAG, "Ya boi got something! %d", (uint8_t)payload[0]); lumberjackQualityCheck(); @@ -340,7 +338,7 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) { if (payload[0] == VERSION_MSG) { - ESP_LOGI(LUM_TAG, "Version received!"); + ESP_LOGD(LUM_TAG, "Version received!"); if (memcmp(&payload[1], LUMBERJACK_VERSION, LUMBERJACK_VLEN)) { ESP_LOGI("LUM_TAG", "We're in!"); @@ -349,13 +347,13 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) if (payload[0] == READY_MSG) { - printf ("Test message"); + ESP_LOGD(LUM_TAG,"Test message"); lumberjackPlayGame(); } if (payload[0] == ATTACK_MSG) { - ESP_LOGI(LUM_TAG, "Incoming attack!"); + ESP_LOGD(LUM_TAG, "Incoming attack!"); lumberjackOnReceiveAttack(payload, len); } @@ -379,13 +377,13 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) int locX = (int)payload[1] << 0 | (uint32_t)payload[2] << 8; int locY = (int)payload[3] << 0 | (uint32_t)payload[4] << 8; uint8_t frame = (uint8_t)payload[5]; - printf("Got %d,%d %d|", locX, locY, frame); + ESP_LOGD(LUM_TAG,"Got %d,%d %d|", locX, locY, frame); } } - printf("Received %d %d!\n", *payload, len); + ESP_LOGD(LUM_TAG,"Received %d %d!\n", *payload, len); } void lumberjackSendGo(void) @@ -471,23 +469,15 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV lumberjack->gameMode = LUMBERJACK_MODE_ATTACK; } - if (label == lumberjackMenuMultiPlayerHost) + if (label == lumberjackMenuMultiPlayer) { - p2pInitialize(&lumberjack->p2p,(lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x13 : 0x15), lumberjackConCb, lumberjackMsgRxCb, -70); - p2pSetAsymmetric(&lumberjack->p2p, (lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x14 : 0x16)); - p2pStartConnection(&lumberjack->p2p); lumberjack->networked = true; - lumberjack->host = true; + // lumberjack->host is filled in after connection is established lumberjackJoinGame(); - } - else if (label == lumberjackMenuMultiPlayerClient) - { - p2pInitialize(&lumberjack->p2p, (lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x14 : 0x16), lumberjackConCb, lumberjackMsgRxCb, -70); - p2pSetAsymmetric(&lumberjack->p2p, (lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x13 : 0x15)); + // Start p2p after loading sprites, which takes time + p2pDeinit(&lumberjack->p2p); + p2pInitialize(&lumberjack->p2p,(lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x13 : 0x15), lumberjackConCb, lumberjackMsgRxCb, -70); p2pStartConnection(&lumberjack->p2p); - lumberjack->networked = true; - lumberjack->host = false; - lumberjackJoinGame(); } else if (label == lumberjackMenuSinglePlayer) { diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 26316ce5d..176d507f4 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -731,7 +731,7 @@ void lumberjackSetupLevel(int characterIndex) //Ghost is separate for reasons - //ESP_LOGI(LUM_TAG, "LOADED"); + //ESP_LOGD(LUM_TAG, "LOADED"); if (!lumv->levelMusic) { bzrPlayBgm(&lumv->song_theme, BZR_STEREO); @@ -867,7 +867,7 @@ void lumberjackGameLoop(int64_t elapsedUs) if (lumv->lastResponseSignal <= 0) { bzrStop(true); - //ESP_LOGI(LUM_TAG, "Connection lost!"); + //ESP_LOGD(LUM_TAG, "Connection lost!"); lumv->gameState = LUMBERJACK_GAMESTATE_GAMEOVER; lumv->transitionTimer = 500; lumv->localPlayer->state = LUMBERJACK_DEAD; @@ -968,7 +968,7 @@ void baseMode(int64_t elapsedUs) { lumv->loaded = true; - //ESP_LOGI(LUM_TAG, "Load Time %ld", (long)elapsedUs); + //ESP_LOGD(LUM_TAG, "Load Time %ld", (long)elapsedUs); // If networked, send "Loaded complete!" ? @@ -1029,7 +1029,7 @@ void baseMode(int64_t elapsedUs) if (!attackThisFrame && lumv->localPlayer->attackPressed) { - // ESP_LOGI(LUM_TAG, "Attack this frame!"); + // ESP_LOGD(LUM_TAG, "Attack this frame!"); int x = 0; for (int i = 0; i < 32; i ++) { @@ -1314,7 +1314,7 @@ void baseMode(int64_t elapsedUs) if (lumv->localPlayer->respawn <= 0 && lumv->lives > 0) { - //ESP_LOGI(LUM_TAG, "RESPAWN PLAYER!"); + //ESP_LOGD(LUM_TAG, "RESPAWN PLAYER!"); bzrStop(true); bzrPlaySfx(&lumv->song_respawn, BZR_RIGHT); @@ -1594,19 +1594,34 @@ void DrawTitle(void) if (lumv->gameReady) { - //Press A To Start - lumberjackTitleDisplayText(((lumv->lumberjackMain->host || !lumv->lumberjackMain->networked ) ? "Press A to start": "Host must start"), (TFT_WIDTH/2) - 70, 180); - } - else if (lumv->lumberjackMain->networked && lumv->lumberjackMain->host) - { - lumberjackTitleDisplayText("Waiting for client", (TFT_WIDTH/2) - 80, 180); + const char* hostText = "Press A to start"; + const char* clientText = "Host must start"; + int16_t tWidthH = textWidth(&lumv->arcade, hostText); + int16_t tWidthC = textWidth(&lumv->arcade, clientText); + + if(lumv->lumberjackMain->networked) + { + if(lumv->lumberjackMain->host) + { + lumberjackTitleDisplayText(hostText, (TFT_WIDTH - tWidthH) / 2, 180); + } + else + { + lumberjackTitleDisplayText(clientText, (TFT_WIDTH - tWidthC) / 2, 180); + } + } + else + { + lumberjackTitleDisplayText(hostText, (TFT_WIDTH - tWidthH) / 2, 180); + } } - else if (lumv->lumberjackMain->networked && !lumv->lumberjackMain->host) + else if (lumv->lumberjackMain->networked) { - lumberjackTitleDisplayText("Looking for host", (TFT_WIDTH/2) - 80, 180); + const char* connText = "Looking for connection"; + int16_t tWidth = textWidth(&lumv->arcade, connText); + lumberjackTitleDisplayText(connText, (TFT_WIDTH - tWidth)/2, 180); } - drawWsgSimple(&lumv->unusedBlockSprite[lumv->stageAnimationFrame % LUMBERJACK_BLOCK_ANIMATION_MAX], 8.5 * 16, 208 - 64); } @@ -1838,7 +1853,7 @@ void DrawGame(void) */ } -void lumberjackTitleDisplayText(char* string, int locationX, int locationY) +void lumberjackTitleDisplayText(const char* string, int locationX, int locationY) { drawText(&lumv->arcade, c000, string, locationX, locationY + 2); diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 01044556b..da7636441 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -24,7 +24,7 @@ bool lumberjackSpawnCheck(int64_t elapseUs); void lumberjackAttackCheck(int64_t elapseUs); void lumberjackScoreDisplay(int score, int locationX); -void lumberjackTitleDisplayText(char* string, int locationX, int locationY); +void lumberjackTitleDisplayText(const char* string, int locationX, int locationY); void baseMode(int64_t elapsedUs); From 7de1f282a4bc60ea3714a6042bb5c358174c0417 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Thu, 16 Nov 2023 12:24:32 -0800 Subject: [PATCH 45/54] Patched in Adams Multiplayer fix Temporarily turned off audio while loading for networking tests. Started to figure out a loading screen before game starts --- main/modes/lumberjack/lumberjack.c | 27 +++++------------ main/modes/lumberjack/lumberjackGame.c | 41 +++++++++++++++++++------- main/modes/lumberjack/lumberjackGame.h | 2 +- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index aa14676cb..2c61037b0 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -49,9 +49,8 @@ static char lumberjackGreenCharacter[] = "Character: Green"; static char lumberjackSpecialCharacter[] = "Character: Guy"; static char lumberjackChoCharacter[] = "Character: Cho"; -static const char lumberjackMenuSinglePlayer[] = "Single Player"; -static const char lumberjackMenuMultiPlayerHost[] = "Multi-Player"; -static const char lumberjackMenuMultiPlayerClient[] = "Multi-Player Join"; +static const char lumberjackMenuSinglePlayer[] = "Single Player"; +static const char lumberjackMenuMultiPlayer[] = "Multi-Player"; static const char lumberjackPlatformerUnlock[] = "pf_unlocks"; static const char lumberjackChoUnlock[] = "ray"; @@ -105,14 +104,12 @@ static void lumberjackEnterMode(void) lumberjack->menu = startSubMenu(lumberjack->menu, lumberjackPanic); addSingleItemToMenu(lumberjack->menu, lumberjackMenuSinglePlayer); - addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerHost); - addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerClient); + addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayer); lumberjack->menu = endSubMenu(lumberjack->menu); lumberjack->menu = startSubMenu(lumberjack->menu, lumberjackAttack); addSingleItemToMenu(lumberjack->menu, lumberjackMenuSinglePlayer); - addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerHost); - addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayerClient); + addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayer); lumberjack->menu = endSubMenu(lumberjack->menu); //addSingleItemToMenu(lumberjack->menu, lumberjackSmack); @@ -312,6 +309,7 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) if (evt == CON_ESTABLISHED) { ESP_LOGI(LUM_TAG, "LumberJack.Net ready! %d", (int)p2pGetPlayOrder(p2p)); + lumberjack->host = (GOING_FIRST == p2pGetPlayOrder(p2p)); uint8_t payload[1 + LUMBERJACK_VLEN] = {VERSION_MSG}; memcpy(&payload[1], LUMBERJACK_VERSION, LUMBERJACK_VLEN); @@ -471,22 +469,13 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV lumberjack->gameMode = LUMBERJACK_MODE_ATTACK; } - if (label == lumberjackMenuMultiPlayerHost) + if (label == lumberjackMenuMultiPlayer) { + p2pDeinit(&lumberjack->p2p); p2pInitialize(&lumberjack->p2p,(lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x13 : 0x15), lumberjackConCb, lumberjackMsgRxCb, -70); - p2pSetAsymmetric(&lumberjack->p2p, (lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x14 : 0x16)); p2pStartConnection(&lumberjack->p2p); lumberjack->networked = true; - lumberjack->host = true; - lumberjackJoinGame(); - } - else if (label == lumberjackMenuMultiPlayerClient) - { - p2pInitialize(&lumberjack->p2p, (lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x14 : 0x16), lumberjackConCb, lumberjackMsgRxCb, -70); - p2pSetAsymmetric(&lumberjack->p2p, (lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x13 : 0x15)); - p2pStartConnection(&lumberjack->p2p); - lumberjack->networked = true; - lumberjack->host = false; + // lumberjack->host is filled in after connection is established lumberjackJoinGame(); } else if (label == lumberjackMenuSinglePlayer) diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 26316ce5d..041612dca 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -76,6 +76,8 @@ lumberjackVars_t* lumv; void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) { + + drawRect(0, 0, 280, 220, c050); lumv = calloc(1, sizeof(lumberjackVars_t)); lumv->lumberjackMain = main; lumv->localPlayerType = characterIndex; @@ -575,6 +577,8 @@ bool lumberjackLoadLevel() void lumberjackSetupLevel(int characterIndex) { + bzrStop(true); // Stop the buzzer? + lumv->enemyKillCount = 0; lumv->totalEnemyCount = 0; lumv->comboTime = 0; @@ -734,9 +738,9 @@ void lumberjackSetupLevel(int characterIndex) //ESP_LOGI(LUM_TAG, "LOADED"); if (!lumv->levelMusic) { - bzrPlayBgm(&lumv->song_theme, BZR_STEREO); lumv->levelMusic = true; } + bzrPlayBgm(&lumv->song_theme, BZR_STEREO); } @@ -1594,19 +1598,34 @@ void DrawTitle(void) if (lumv->gameReady) { - //Press A To Start - lumberjackTitleDisplayText(((lumv->lumberjackMain->host || !lumv->lumberjackMain->networked ) ? "Press A to start": "Host must start"), (TFT_WIDTH/2) - 70, 180); - } - else if (lumv->lumberjackMain->networked && lumv->lumberjackMain->host) - { - lumberjackTitleDisplayText("Waiting for client", (TFT_WIDTH/2) - 80, 180); + const char* hostText = "Press A to start"; + const char* clientText = "Host must start"; + int16_t tWidthH = textWidth(&lumv->arcade, hostText); + int16_t tWidthC = textWidth(&lumv->arcade, clientText); + + if(lumv->lumberjackMain->networked) + { + if(lumv->lumberjackMain->host) + { + lumberjackTitleDisplayText(hostText, (TFT_WIDTH - tWidthH) / 2, 180); + } + else + { + lumberjackTitleDisplayText(clientText, (TFT_WIDTH - tWidthC) / 2, 180); + } + } + else + { + lumberjackTitleDisplayText(hostText, (TFT_WIDTH - tWidthH) / 2, 180); + } } - else if (lumv->lumberjackMain->networked && !lumv->lumberjackMain->host) + else if (lumv->lumberjackMain->networked) { - lumberjackTitleDisplayText("Looking for host", (TFT_WIDTH/2) - 80, 180); + const char* connText = "Looking for connection"; + int16_t tWidth = textWidth(&lumv->arcade, connText); + lumberjackTitleDisplayText(connText, (TFT_WIDTH - tWidth)/2, 180); } - drawWsgSimple(&lumv->unusedBlockSprite[lumv->stageAnimationFrame % LUMBERJACK_BLOCK_ANIMATION_MAX], 8.5 * 16, 208 - 64); } @@ -1838,7 +1857,7 @@ void DrawGame(void) */ } -void lumberjackTitleDisplayText(char* string, int locationX, int locationY) +void lumberjackTitleDisplayText(const char* string, int locationX, int locationY) { drawText(&lumv->arcade, c000, string, locationX, locationY + 2); diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 01044556b..da7636441 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -24,7 +24,7 @@ bool lumberjackSpawnCheck(int64_t elapseUs); void lumberjackAttackCheck(int64_t elapseUs); void lumberjackScoreDisplay(int score, int locationX); -void lumberjackTitleDisplayText(char* string, int locationX, int locationY); +void lumberjackTitleDisplayText(const char* string, int locationX, int locationY); void baseMode(int64_t elapsedUs); From 3e54a7c82b58369a16fbb13f22929d11263c52c8 Mon Sep 17 00:00:00 2001 From: gelakinetic Date: Thu, 16 Nov 2023 22:15:49 -0500 Subject: [PATCH 46/54] Added a few TODOs --- main/modes/lumberjack/lumberjack.c | 61 +++++++++++++++++++------- main/modes/lumberjack/lumberjackGame.c | 4 +- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index 2e4c526c9..4a8c78709 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -112,6 +112,11 @@ static void lumberjackEnterMode(void) addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayer); lumberjack->menu = endSubMenu(lumberjack->menu); + // TODO add instructions menu item & screen. Can be a simple synopsis that uses drawTextWordWrap() to draw a paragraph to the screen + // Should explain difference between panic and attack, maybe item usage, how to dodge ghost, etc. + // You can also do multi-page, because drawTextWordWrap() returns a pointer to any off-screen text. + // For reference, see rayDialogRender() + //addSingleItemToMenu(lumberjack->menu, lumberjackSmack); int characters = 2; @@ -305,23 +310,33 @@ static void lumberjackEspNowSendCb(const uint8_t* mac_addr, esp_now_send_status_ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) { - // Do anything - if (evt == CON_ESTABLISHED) + switch(evt) { - ESP_LOGD(LUM_TAG, "LumberJack.Net ready! %d", (int)p2pGetPlayOrder(p2p)); - lumberjack->host = (GOING_FIRST == p2pGetPlayOrder(p2p)); - - uint8_t payload[1 + LUMBERJACK_VLEN] = {VERSION_MSG}; - memcpy(&payload[1], LUMBERJACK_VERSION, LUMBERJACK_VLEN); + case CON_STARTED: + case RX_GAME_START_ACK: + case RX_GAME_START_MSG: + { + // TODO, optional, update menu to indicate connection progress + break; + } + case CON_ESTABLISHED: + { + ESP_LOGD(LUM_TAG, "LumberJack.Net ready! %d", (int)p2pGetPlayOrder(p2p)); + lumberjack->host = (GOING_FIRST == p2pGetPlayOrder(p2p)); - p2pSendMsg(&lumberjack->p2p, payload, sizeof(payload), lumberjackMsgTxCbFn); - lumberjackGameReady(); - } + uint8_t payload[1 + LUMBERJACK_VLEN] = {VERSION_MSG}; + memcpy(&payload[1], LUMBERJACK_VERSION, LUMBERJACK_VLEN); - if (evt == CON_LOST) - { - // Do we attempt to get it back? - ESP_LOGD(LUM_TAG, "We lost connection!"); + p2pSendMsg(&lumberjack->p2p, payload, sizeof(payload), lumberjackMsgTxCbFn); + lumberjackGameReady(); + break; + } + case CON_LOST: + { + // TODO drop back to main menu or show an error or something, its not recoverable + ESP_LOGD(LUM_TAG, "We lost connection!"); + break; + } } lumberjack->conStatus = evt; @@ -341,7 +356,7 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) ESP_LOGD(LUM_TAG, "Version received!"); if (memcmp(&payload[1], LUMBERJACK_VERSION, LUMBERJACK_VLEN)) { - ESP_LOGI("LUM_TAG", "We're in!"); + ESP_LOGD("LUM_TAG", "We're in!"); } } @@ -439,7 +454,7 @@ void lumberjackSendDeath(bool gameover) } /** - * @brief TODO use this somewhere + * @brief This is called after transmitting a p2p packet and receiving (or not receiving) an ack * * @param p2p * @param status @@ -448,7 +463,19 @@ void lumberjackSendDeath(bool gameover) */ static void lumberjackMsgTxCbFn(p2pInfo* p2p, messageStatus_t status, const uint8_t* data, uint8_t len) { - + switch(status) + { + case MSG_ACKED: + { + // All good + break; + } + case MSG_FAILED: + { + // TODO figure out what to do if a message fails to transmit (i.e. no ack). Retry? + break; + } + } } static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingVal) diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index dea411d6d..8fef75b28 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -790,6 +790,7 @@ void lumberjackTitleLoop(int64_t elapsedUs) lumberjackPlayGame(); lumberjackSendGo(); } + // TODO add an else here to back out to the main menu with PB_B lumv->highscore = 0; } else if (lumv->btnState & PB_A && lumv->gameReady) // And Game Ready! @@ -800,6 +801,7 @@ void lumberjackTitleLoop(int64_t elapsedUs) { lumberjackSendGo(); } + // TODO add an else here to back out to the main menu with PB_B } //Update Animation @@ -1466,7 +1468,7 @@ void baseMode(int64_t elapsedUs) //if Panic mode... check to see if player's head is under water. if (lumv->localPlayer->y > lumv->waterLevel && lumv->localPlayer->state != LUMBERJACK_DEAD && lumv->localPlayer->state != LUMBERJACK_OFFSCREEN) { - //ESP_LOGW(LUM_TAG, "UNDER WATER! %d", lumv->localPlayer->submergedTimer); + //ESP_LOGD(LUM_TAG, "UNDER WATER! %d", lumv->localPlayer->submergedTimer); lumv->localPlayer->submergedTimer -= elapsedUs / 10000; if (lumv->localPlayer->submergedTimer <= 0) From c6580e39bb97f3a475d61dab37b971c88a232f42 Mon Sep 17 00:00:00 2001 From: gelakinetic Date: Thu, 16 Nov 2023 22:26:51 -0500 Subject: [PATCH 47/54] Add note about cppcheck warning --- main/modes/lumberjack/lumberjackGame.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 8fef75b28..ae28a0c11 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -2207,6 +2207,7 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs bool bump = false; if ((tileA != NULL && lumberjackIsCollisionTile(tileA->type)) || (tileB != NULL && lumberjackIsCollisionTile(tileB->type))) { + // TODO fix this cppcheck warning. It always dereferences tileA, but it can be reached if tileA is NULL and tileB is not NULL destinationY = ((tileA->y + 1) * LUMBERJACK_TILE_SIZE); entity->jumpTimer = 0; entity->jumping = false; From 7fb4f10ff9c39441bf878df2a0c132520c9bd06e Mon Sep 17 00:00:00 2001 From: MrTroy Date: Thu, 16 Nov 2023 20:46:52 -0800 Subject: [PATCH 48/54] Started TODO fixes Started how to play Added back button --- main/modes/lumberjack/lumberjack.c | 34 +++++++++++++++++++++++--- main/modes/lumberjack/lumberjackGame.c | 23 ++++++++++++----- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index 4a8c78709..dcc124fbb 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -40,7 +40,7 @@ static bool lumberjackSwadgeGuyUnlocked(void); static const char lumberjackName[] = "Lumber Jacks"; static const char lumberjackPanic[] = "Panic"; static const char lumberjackAttack[] = "Attack"; -// static const char lumberjackSmack[] = "Smack"; +static const char lumberjackInstructions[] = "How to Play"; static const char lumberjackBack[] = "Back"; static const char lumberjackExit[] = "Exit"; @@ -105,11 +105,13 @@ static void lumberjackEnterMode(void) lumberjack->menu = startSubMenu(lumberjack->menu, lumberjackPanic); addSingleItemToMenu(lumberjack->menu, lumberjackMenuSinglePlayer); addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayer); + addSingleItemToMenu(lumberjack->menu, lumberjackInstructions); lumberjack->menu = endSubMenu(lumberjack->menu); lumberjack->menu = startSubMenu(lumberjack->menu, lumberjackAttack); addSingleItemToMenu(lumberjack->menu, lumberjackMenuSinglePlayer); addSingleItemToMenu(lumberjack->menu, lumberjackMenuMultiPlayer); + addSingleItemToMenu(lumberjack->menu, lumberjackInstructions); lumberjack->menu = endSubMenu(lumberjack->menu); // TODO add instructions menu item & screen. Can be a simple synopsis that uses drawTextWordWrap() to draw a paragraph to the screen @@ -117,7 +119,6 @@ static void lumberjackEnterMode(void) // You can also do multi-page, because drawTextWordWrap() returns a pointer to any off-screen text. // For reference, see rayDialogRender() - //addSingleItemToMenu(lumberjack->menu, lumberjackSmack); int characters = 2; @@ -254,7 +255,18 @@ static void lumberjackMenuLoop(int64_t elapsedUs) buttonEvt_t evt = {0}; while (checkButtonQueueWrapper(&evt)) { - lumberjack->menu = menuButton(lumberjack->menu, evt); + if (lumberjack->instructions) + { + if (evt.state & PB_B) + { + ESP_LOGD(LUM_TAG, "Mac Daddy!"); + lumberjack->instructions = false; + } + } + else + { + lumberjack->menu = menuButton(lumberjack->menu, evt); + } } drawMenuLogbook(lumberjack->menu, lumberjack->menuLogbookRenderer, elapsedUs); @@ -496,6 +508,22 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV lumberjack->gameMode = LUMBERJACK_MODE_ATTACK; } + if (label == lumberjackInstructions) + { + if (lumberjack->gameMode == LUMBERJACK_MODE_PANIC) + { + lumberjack->instructions = true; + } + else if (lumberjack->gameMode == LUMBERJACK_MODE_ATTACK) + { + lumberjack->instructions = true; + + } + + //There was a 3rd game mode planned but... I don't want to take any chances + + } + if (label == lumberjackMenuMultiPlayer) { lumberjack->networked = true; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index ae28a0c11..2b0da0590 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -783,11 +783,16 @@ void lumberjackTitleLoop(int64_t elapsedUs) lumv->btnState = evt.state; } - if (lumv->lumberjackMain->networked) + + if (lumv->btnState & PB_B) + { + switchToSwadgeMode(&lumberjackMode); + } + else if (lumv->lumberjackMain->networked) { if (lumv->btnState & PB_A && lumv->gameReady && lumv->lumberjackMain->host && lumv->lumberjackMain->conStatus == CON_ESTABLISHED) // And Game Ready! { - lumberjackPlayGame(); + lumberjackPlayGame(); lumberjackSendGo(); } // TODO add an else here to back out to the main menu with PB_B @@ -801,8 +806,7 @@ void lumberjackTitleLoop(int64_t elapsedUs) { lumberjackSendGo(); } - // TODO add an else here to back out to the main menu with PB_B - } + } //Update Animation lumv->worldTimer += elapsedUs; @@ -2207,8 +2211,15 @@ static void lumberjackUpdateEntity(lumberjackEntity_t* entity, int64_t elapsedUs bool bump = false; if ((tileA != NULL && lumberjackIsCollisionTile(tileA->type)) || (tileB != NULL && lumberjackIsCollisionTile(tileB->type))) { - // TODO fix this cppcheck warning. It always dereferences tileA, but it can be reached if tileA is NULL and tileB is not NULL - destinationY = ((tileA->y + 1) * LUMBERJACK_TILE_SIZE); + // Put in the full if statement because cppcheck wasn't happy with ternary + if (tileA != NULL) + { + destinationY = (tileA->y + 1) * LUMBERJACK_TILE_SIZE; + } + else{ + destinationY = ((tileB->y + 1) * LUMBERJACK_TILE_SIZE); + } + entity->jumpTimer = 0; entity->jumping = false; entity->vy = 0; From c897e297bcbb907996e5ae2056e7fe4852215c85 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Fri, 17 Nov 2023 17:56:07 -0800 Subject: [PATCH 49/54] Added instructions Remove magic high score --- main/modes/lumberjack/lumberjack.c | 126 +++++++++++++++++++++---- main/modes/lumberjack/lumberjack.h | 2 + main/modes/lumberjack/lumberjackGame.h | 1 + 3 files changed, 113 insertions(+), 16 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index dcc124fbb..b8a4700e1 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -13,8 +13,9 @@ #include "lumberjackGame.h" #define LUMBERJACK_VLEN 7 -#define LUMBERJACK_VERSION "231114a" +#define LUMBERJACK_VERSION "2311174a" +#define DEFAULT_HIGHSCORE 5000 static void lumberjackEnterMode(void); static void lumberjackExitMode(void); @@ -22,6 +23,7 @@ static void lumberjackMainLoop(int64_t elapsedUs); static void lumberjackMenuLoop(int64_t elapsedUs); static void lumberjackAudioCallback(uint16_t* samples, uint32_t sampleCnt); static void lumberjackBackgroundDrawCallback(int16_t x, int16_t y, int16_t w, int16_t h, int16_t up, int16_t upNum); +static void lumberjackInstructionText(const char* string, paletteColor_t color, int locationX, int locationY); static void lumberjackEspNowRecvCb(const esp_now_recv_info_t* esp_now_info, const uint8_t* data, uint8_t len, int8_t rssi); static void lumberjackEspNowSendCb(const uint8_t* mac_addr, esp_now_send_status_t status); @@ -37,11 +39,11 @@ static void lumberjackJoinGame(void); static bool lumberjackChoUnlocked(void); static bool lumberjackSwadgeGuyUnlocked(void); + static const char lumberjackName[] = "Lumber Jacks"; static const char lumberjackPanic[] = "Panic"; static const char lumberjackAttack[] = "Attack"; static const char lumberjackInstructions[] = "How to Play"; -static const char lumberjackBack[] = "Back"; static const char lumberjackExit[] = "Exit"; static char lumberjackRedCharacter[] = "Character: Red"; @@ -59,7 +61,7 @@ const char LUMBERJACK_SAVE[] = "lumberjackdata"; swadgeMode_t lumberjackMode = { .modeName = lumberjackName, - .wifiMode = ESP_NOW_IMMEDIATE, + .wifiMode = ESP_NOW, .overrideUsb = false, .usesAccelerometer = false, .usesThermometer = false, @@ -94,7 +96,7 @@ static void lumberjackEnterMode(void) lumberjackLoadSave(); loadFont("logbook.font", &lumberjack->logbook, false); - + loadFont("eightbit_atari_grube2.font", &lumberjack->arcade, false); lumberjack->menu = initMenu(lumberjackName, lumberjackMenuCb); lumberjack->menuLogbookRenderer = initMenuLogbookRenderer(&lumberjack->logbook); @@ -175,19 +177,19 @@ static void lumberjackLoadSave(void) int highscore = lumberjack->save.highScore; - if (highscore < 5000) + if (highscore < DEFAULT_HIGHSCORE) { - lumberjack->save.highScore = 5000; + lumberjack->save.highScore = DEFAULT_HIGHSCORE; } - if (lumberjack->save.attackHighScore < 5000) + if (lumberjack->save.attackHighScore < DEFAULT_HIGHSCORE) { - lumberjack->save.attackHighScore = 5000; + lumberjack->save.attackHighScore = DEFAULT_HIGHSCORE; } - if (lumberjack->save.panicHighScore < 5000) + if (lumberjack->save.panicHighScore < DEFAULT_HIGHSCORE) { - lumberjack->save.panicHighScore = 5000; + lumberjack->save.panicHighScore = DEFAULT_HIGHSCORE; } writeNvsBlob(LUMBERJACK_SAVE, &lumberjack->save, len); @@ -227,6 +229,7 @@ static void lumberjackExitMode(void) free(lumberjack->charactersArray); p2pDeinit(&lumberjack->p2p); freeFont(&lumberjack->logbook); + freeFont(&lumberjack->arcade); deinitMenu(lumberjack->menu); deinitMenuLogbookRenderer(lumberjack->menuLogbookRenderer); free(lumberjack); @@ -259,7 +262,6 @@ static void lumberjackMenuLoop(int64_t elapsedUs) { if (evt.state & PB_B) { - ESP_LOGD(LUM_TAG, "Mac Daddy!"); lumberjack->instructions = false; } } @@ -268,8 +270,103 @@ static void lumberjackMenuLoop(int64_t elapsedUs) lumberjack->menu = menuButton(lumberjack->menu, evt); } } - drawMenuLogbook(lumberjack->menu, lumberjack->menuLogbookRenderer, elapsedUs); + if (lumberjack->instructions) + { + fillDisplayArea(0, 0, TFT_WIDTH , TFT_HEIGHT , c145); + + + const char* closeText = "Press B to close"; + int16_t cWidthH = textWidth(&lumberjack->arcade, closeText); + int16_t dOffset = 15; + int16_t dyOffset = 50; + int16_t iWidth = 10; + + + if (lumberjack->gameMode == LUMBERJACK_MODE_PANIC) + { + + const char* titleText = "Panic"; + int16_t tWidthH = textWidth(&lumberjack->arcade, titleText); + lumberjackInstructionText(titleText, c555, (TFT_WIDTH-tWidthH)/2, 15); + + const char* ins = "Press A to jump\nAvoid upright baddies\nHit baddies from under\nThen kick them off\nDuck DOWN to avoid ghost\nAx blocks lowers water\nDon't drown"; + /* + lumberjackInstructionText("Press A to jump", c355, dOffset, 50); + lumberjackInstructionText("Avoid upright baddies", c355, dOffset, 70); + lumberjackInstructionText("Hit baddies from under", c355, dOffset, 90); + lumberjackInstructionText("Then go kick them off", c355, dOffset, 110); + lumberjackInstructionText("Duck Down to avoid ghost", c355, dOffset, 130); + lumberjackInstructionText("Ax blocks lowers water", c355, dOffset, 150); + */ + dOffset = 15; dyOffset = 49; + drawTextWordWrap(&lumberjack->arcade, c000, ins, &dOffset, &dyOffset, TFT_WIDTH - iWidth, TFT_HEIGHT - dOffset); + + dOffset = 15; dyOffset = 52; + drawTextWordWrap(&lumberjack->arcade, c000, ins, &dOffset, &dyOffset, TFT_WIDTH - iWidth, TFT_HEIGHT - dOffset); + + dOffset = 14; dyOffset = 50; + drawTextWordWrap(&lumberjack->arcade, c000, ins, &dOffset, &dyOffset, TFT_WIDTH - iWidth, TFT_HEIGHT - dOffset); + + dOffset = 16; dyOffset = 50; + drawTextWordWrap(&lumberjack->arcade, c000, ins, &dOffset, &dyOffset, TFT_WIDTH - iWidth + 1, TFT_HEIGHT - dOffset); + + dOffset = 15; dyOffset = 50; + drawTextWordWrap(&lumberjack->arcade, c355, ins, &dOffset, &dyOffset, TFT_WIDTH - iWidth, TFT_HEIGHT - dOffset); + + } + else if (lumberjack->gameMode == LUMBERJACK_MODE_ATTACK) + { + const char* titleText = "Attack"; + int16_t tWidthH = textWidth(&lumberjack->arcade, titleText); + lumberjackInstructionText(titleText, c555, (TFT_WIDTH-tWidthH)/2, 15); + + const char* ins = "Press A to jump\nAvoid upright baddies\nHit baddies from under\nThen kick them off\nDuck DOWN to avoid ghost\nAx blocks give item\nPress B uses item\n Upgrange: Harder baddies\n Impearvious: Invincible\n Grapes O' Wrath: Flip baddies"; + /* + lumberjackInstructionText("Press A to jump", c355, dOffset, 50); + lumberjackInstructionText("Avoid upright baddies", c355, dOffset, 70); + lumberjackInstructionText("Hit baddies from under", c355, dOffset, 90); + lumberjackInstructionText("Then go kick them off", c355, dOffset, 110); + lumberjackInstructionText("Duck Down to avoid ghost", c355, dOffset, 130); + lumberjackInstructionText("Ax blocks give items", c355, dOffset, 150); + lumberjackInstructionText("Press B uses item", c355, dOffset, 170); + */ + dOffset = 15; dyOffset = 49; + drawTextWordWrap(&lumberjack->arcade, c000, ins, &dOffset, &dyOffset, TFT_WIDTH - iWidth, TFT_HEIGHT - dOffset); + + dOffset = 15; dyOffset = 52; + drawTextWordWrap(&lumberjack->arcade, c000, ins, &dOffset, &dyOffset, TFT_WIDTH - iWidth, TFT_HEIGHT - dOffset); + + dOffset = 14; dyOffset = 50; + drawTextWordWrap(&lumberjack->arcade, c000, ins, &dOffset, &dyOffset, TFT_WIDTH - iWidth, TFT_HEIGHT - dOffset); + + dOffset = 16; dyOffset = 50; + drawTextWordWrap(&lumberjack->arcade, c000, ins, &dOffset, &dyOffset, TFT_WIDTH - iWidth + 1, TFT_HEIGHT - dOffset); + + dOffset = 15; dyOffset = 50; + drawTextWordWrap(&lumberjack->arcade, c355, ins, &dOffset, &dyOffset, TFT_WIDTH - iWidth, TFT_HEIGHT - dOffset); + + } + + dOffset = 15; dyOffset = 50; + + //dOffset = 20; + //drawText(&lumberjack->arcade, c555, closeText, (TFT_WIDTH-cWidthH)/2,(TFT_HEIGHT - dOffset - 5)); + lumberjackInstructionText(closeText, c555, (TFT_WIDTH-cWidthH)/2,(TFT_HEIGHT - dOffset - 5)); + + } +} + +static void lumberjackInstructionText(const char* string, paletteColor_t color, int locationX, int locationY) +{ + drawText(&lumberjack->arcade, c000, string, locationX, locationY-1); + drawText(&lumberjack->arcade, c000, string, locationX, locationY+2); + drawText(&lumberjack->arcade, c000, string, locationX -1, locationY); + drawText(&lumberjack->arcade, c000, string, locationX + 1, locationY); + drawText(&lumberjack->arcade, color, string, locationX, locationY); + + //drawTextWordWrap(&lumberjack->arcade, c555, string, &dOffset, &dOffset, TFT_WIDTH - dOffset, TFT_HEIGHT - dOffset); + } static void lumberjackAudioCallback(uint16_t* samples, uint32_t sampleCnt) @@ -510,6 +607,7 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV if (label == lumberjackInstructions) { + if (lumberjack->gameMode == LUMBERJACK_MODE_PANIC) { lumberjack->instructions = true; @@ -562,10 +660,6 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV lumberjack->selected = 3; } - if (label == lumberjackBack) - { - //.switchToSwadgeMode(&mainMenuMode); - } } else { diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index b5a451f1c..cebbfc7a9 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -45,10 +45,12 @@ typedef struct menu_t* menu; menuLogbookRenderer_t* menuLogbookRenderer; font_t logbook; + font_t arcade; uint8_t selected; bool networked; bool host; + bool instructions; // The pass throughs p2pInfo p2p; diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index da7636441..805209a5b 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -12,6 +12,7 @@ void lumberjackDrawWaterLevel(void); void lumberjackUpdate(int64_t elapseUs); + void lumberjackTitleLoop(int64_t elapsedUs); void lumberjackGameLoop(int64_t elapsedUs); From 9f7bce10f476a7707a86bd3e571814086d1fdf24 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Fri, 17 Nov 2023 19:06:36 -0800 Subject: [PATCH 50/54] Moved networking to after loading Removed vs player bump Removed Troy insulting Troy Fixed Axe spelling --- main/modes/lumberjack/lumberjack.c | 31 +++++++++++++------------- main/modes/lumberjack/lumberjackGame.c | 17 ++++++-------- main/modes/lumberjack/lumberjackGame.h | 2 +- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index b8a4700e1..7ed68d871 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -116,12 +116,6 @@ static void lumberjackEnterMode(void) addSingleItemToMenu(lumberjack->menu, lumberjackInstructions); lumberjack->menu = endSubMenu(lumberjack->menu); - // TODO add instructions menu item & screen. Can be a simple synopsis that uses drawTextWordWrap() to draw a paragraph to the screen - // Should explain difference between panic and attack, maybe item usage, how to dodge ghost, etc. - // You can also do multi-page, because drawTextWordWrap() returns a pointer to any off-screen text. - // For reference, see rayDialogRender() - - int characters = 2; if (lumberjack->save.choUnlocked) @@ -290,14 +284,14 @@ static void lumberjackMenuLoop(int64_t elapsedUs) int16_t tWidthH = textWidth(&lumberjack->arcade, titleText); lumberjackInstructionText(titleText, c555, (TFT_WIDTH-tWidthH)/2, 15); - const char* ins = "Press A to jump\nAvoid upright baddies\nHit baddies from under\nThen kick them off\nDuck DOWN to avoid ghost\nAx blocks lowers water\nDon't drown"; + const char* ins = "Press A to jump\nAvoid upright baddies\nHit baddies from under\nThen kick them off\nDuck DOWN to avoid ghost\nAxe blocks lowers water\nDon't drown"; /* lumberjackInstructionText("Press A to jump", c355, dOffset, 50); lumberjackInstructionText("Avoid upright baddies", c355, dOffset, 70); lumberjackInstructionText("Hit baddies from under", c355, dOffset, 90); lumberjackInstructionText("Then go kick them off", c355, dOffset, 110); lumberjackInstructionText("Duck Down to avoid ghost", c355, dOffset, 130); - lumberjackInstructionText("Ax blocks lowers water", c355, dOffset, 150); + lumberjackInstructionText("Axe blocks lowers water", c355, dOffset, 150); */ dOffset = 15; dyOffset = 49; drawTextWordWrap(&lumberjack->arcade, c000, ins, &dOffset, &dyOffset, TFT_WIDTH - iWidth, TFT_HEIGHT - dOffset); @@ -321,14 +315,14 @@ static void lumberjackMenuLoop(int64_t elapsedUs) int16_t tWidthH = textWidth(&lumberjack->arcade, titleText); lumberjackInstructionText(titleText, c555, (TFT_WIDTH-tWidthH)/2, 15); - const char* ins = "Press A to jump\nAvoid upright baddies\nHit baddies from under\nThen kick them off\nDuck DOWN to avoid ghost\nAx blocks give item\nPress B uses item\n Upgrange: Harder baddies\n Impearvious: Invincible\n Grapes O' Wrath: Flip baddies"; + const char* ins = "Press A to jump\nAvoid upright baddies\nHit baddies from under\nThen kick them off\nDuck DOWN to avoid ghost\nAxe blocks give item\nPress B uses item\n Upgrange: Harder baddies\n Impearvious: Invincible\n Grapes O' Wrath: Flip baddies"; /* lumberjackInstructionText("Press A to jump", c355, dOffset, 50); lumberjackInstructionText("Avoid upright baddies", c355, dOffset, 70); lumberjackInstructionText("Hit baddies from under", c355, dOffset, 90); lumberjackInstructionText("Then go kick them off", c355, dOffset, 110); lumberjackInstructionText("Duck Down to avoid ghost", c355, dOffset, 130); - lumberjackInstructionText("Ax blocks give items", c355, dOffset, 150); + lumberjackInstructionText("Axe blocks give items", c355, dOffset, 150); lumberjackInstructionText("Press B uses item", c355, dOffset, 170); */ dOffset = 15; dyOffset = 49; @@ -443,7 +437,8 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) case CON_LOST: { // TODO drop back to main menu or show an error or something, its not recoverable - ESP_LOGD(LUM_TAG, "We lost connection!"); + ESP_LOGI(LUM_TAG, "We lost connection!"); + break; } } @@ -501,7 +496,7 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) int locX = (int)payload[1] << 0 | (uint32_t)payload[2] << 8; int locY = (int)payload[3] << 0 | (uint32_t)payload[4] << 8; uint8_t frame = (uint8_t)payload[5]; - ESP_LOGD(LUM_TAG,"Got %d,%d %d|", locX, locY, frame); + //ESP_LOGD(LUM_TAG,"Got %d,%d %d|", locX, locY, frame); } } @@ -587,6 +582,15 @@ static void lumberjackMsgTxCbFn(p2pInfo* p2p, messageStatus_t status, const uint } } +void lumberjackInitp2p() +{ + //ESP_LOGD(LUM_TAG, "Init connection!"); + + p2pDeinit(&lumberjack->p2p); + p2pInitialize(&lumberjack->p2p,(lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x13 : 0x15), lumberjackConCb, lumberjackMsgRxCb, -70); + p2pStartConnection(&lumberjack->p2p); +} + static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingVal) { if (selected) @@ -628,9 +632,6 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV // lumberjack->host is filled in after connection is established lumberjackJoinGame(); // Start p2p after loading sprites, which takes time - p2pDeinit(&lumberjack->p2p); - p2pInitialize(&lumberjack->p2p,(lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x13 : 0x15), lumberjackConCb, lumberjackMsgRxCb, -70); - p2pStartConnection(&lumberjack->p2p); } else if (label == lumberjackMenuSinglePlayer) { diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 2b0da0590..5b3edbb6b 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -416,6 +416,12 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->song_theme.shouldLoop = true; lumv->song_title.shouldLoop = true; + if (lumv->lumberjackMain->networked) + { + + lumberjackInitp2p(); + } + bzrPlayBgm(&lumv->song_title, BZR_STEREO); } @@ -763,9 +769,6 @@ void lumberjackUnloadLevel(void) } } -/** - * @brief TODO use this somewhere - */ void restartLevel(void) { lumv->lives--; @@ -795,7 +798,7 @@ void lumberjackTitleLoop(int64_t elapsedUs) lumberjackPlayGame(); lumberjackSendGo(); } - // TODO add an else here to back out to the main menu with PB_B + lumv->highscore = 0; } else if (lumv->btnState & PB_A && lumv->gameReady) // And Game Ready! @@ -2516,7 +2519,6 @@ void lumberjackDoControls(void) buttonPressed = true; } - // TODO: This is sloppy Troy if (lumv->btnState & PB_A) { lumv->localPlayer->jumpPressed = true; @@ -2526,7 +2528,6 @@ void lumberjackDoControls(void) lumv->localPlayer->jumpPressed = false; } - // TODO: This is sloppy too Troy if (lumv->btnState & PB_B) { lumv->localPlayer->attackPressed = true; @@ -2584,10 +2585,6 @@ static bool lumberjackIsCollisionTile(int index) bool lumberjackDetectBump(lumberjackTile_t* tile) { bool bump = false; - if (lumv->localPlayer->state != LUMBERJACK_BUMPED && lumv->localPlayer->state != LUMBERJACK_DEAD) - { - // TODO put in bump the player - } for (int enemyIndex = 0; enemyIndex < ARRAY_SIZE(lumv->enemy); enemyIndex++) { diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 805209a5b..8da9fb6df 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -12,7 +12,7 @@ void lumberjackDrawWaterLevel(void); void lumberjackUpdate(int64_t elapseUs); - +void lumberjackInitp2p(void); void lumberjackTitleLoop(int64_t elapsedUs); void lumberjackGameLoop(int64_t elapsedUs); From fab95656eda38f6d5fdb8143bc52583a8ca1a063 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 18 Nov 2023 00:22:45 -0800 Subject: [PATCH 51/54] Lite networking fixes Fixed Panic vs level that was causing crash Put in bandaid to ignore double hosting while testing Fixed panic 9 annoying area where enemies were unkillable Show vs enemy lives on screen now --- assets/lumbers/lumberjacks_panic_9.bin | Bin 488 -> 488 bytes assets/lumbers/lumberjacks_panic_vs.bin | Bin 920 -> 740 bytes main/modes/lumberjack/lumberjack.c | 67 +++++++++++++++++----- main/modes/lumberjack/lumberjack.h | 3 + main/modes/lumberjack/lumberjackGame.c | 71 +++++++++++++++++++----- main/modes/lumberjack/lumberjackGame.h | 8 ++- 6 files changed, 119 insertions(+), 30 deletions(-) diff --git a/assets/lumbers/lumberjacks_panic_9.bin b/assets/lumbers/lumberjacks_panic_9.bin index 193cac0f006996300e01fd510da77e7b475c0f47..80e5be03dfe2bae452694046855db6e873c56818 100644 GIT binary patch delta 16 WcmaFC{DOHyCL;?E5KPWxtOfur%>~7B diff --git a/assets/lumbers/lumberjacks_panic_vs.bin b/assets/lumbers/lumberjacks_panic_vs.bin index 13501a7817dcb04ab816ca6509ce32fb2edfc4dc..8656036514b81faac1132f618bec99dadc7008e5 100644 GIT binary patch delta 48 zcmbQi{)ClLVp2p, esp_now_info->src_addr, (const uint8_t*)data, len, rssi); } @@ -420,12 +423,15 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) case RX_GAME_START_MSG: { // TODO, optional, update menu to indicate connection progress + ESP_LOGI(LUM_TAG, "LumberJack.Net ack! "); + break; } case CON_ESTABLISHED: { - ESP_LOGD(LUM_TAG, "LumberJack.Net ready! %d", (int)p2pGetPlayOrder(p2p)); - lumberjack->host = (GOING_FIRST == p2pGetPlayOrder(p2p)); + int index = (int)p2pGetPlayOrder(p2p); + ESP_LOGI(LUM_TAG, "LumberJack.Net ready! %d", index); + lumberjack->host = (GOING_FIRST == index); uint8_t payload[1 + LUMBERJACK_VLEN] = {VERSION_MSG}; memcpy(&payload[1], LUMBERJACK_VERSION, LUMBERJACK_VLEN); @@ -438,7 +444,7 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) { // TODO drop back to main menu or show an error or something, its not recoverable ESP_LOGI(LUM_TAG, "We lost connection!"); - + lumberjackInitp2p(); break; } } @@ -481,6 +487,12 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) lumberjackOnReceiveScore(payload); } + if (payload[0] == CHARACTER_MSG) + { + ESP_LOGI(LUM_TAG, "CH"); + lumberjackOnReceiveCharacter(payload[1]); + } + if (payload[0] == BUMP_MSG) { lumberjackOnReceiveBump(); @@ -488,17 +500,26 @@ static void lumberjackMsgRxCb(p2pInfo* p2p, const uint8_t* payload, uint8_t len) if (payload[0] == DEATH_MSG) { - lumberjackOnReceiveDeath(payload[1] != 0x00); + lumberjackOnReceiveDeath(payload[1]); } + if (payload[0] == HOST_MSG) + { + if (lumberjack->host == false) + { + lumberjack->host = true; + } + } + + /* if (payload[0] == 0x19) { - int locX = (int)payload[1] << 0 | (uint32_t)payload[2] << 8; - int locY = (int)payload[3] << 0 | (uint32_t)payload[4] << 8; - uint8_t frame = (uint8_t)payload[5]; + //int locX = (int)payload[1] << 0 | (uint32_t)payload[2] << 8; + //int locY = (int)payload[3] << 0 | (uint32_t)payload[4] << 8; + //uint8_t frame = (uint8_t)payload[5]; //ESP_LOGD(LUM_TAG,"Got %d,%d %d|", locX, locY, frame); - } + }*/ } @@ -514,6 +535,15 @@ void lumberjackSendGo(void) } } +void lumberjackSendHostRequest(void) +{ + if (lumberjack->networked) + { + const uint8_t msg[] = {HOST_MSG}; + p2pSendMsg(&lumberjack->p2p, msg, ARRAY_SIZE(msg), lumberjackMsgTxCbFn); + } +} + void lumberjackSendAttack(uint8_t* number) { if (lumberjack->networked) @@ -548,11 +578,20 @@ void lumberjackSendScore(int score) } } -void lumberjackSendDeath(bool gameover) +void lumberjackSendCharacter(uint8_t character) +{ + if (lumberjack->networked) + { + uint8_t payload[2] = {CHARACTER_MSG, character}; + p2pSendMsg(&lumberjack->p2p, payload, ARRAY_SIZE(payload), lumberjackMsgTxCbFn); + } +} + +void lumberjackSendDeath(uint8_t lives) { if (lumberjack->networked) { - const uint8_t payload[2] = {DEATH_MSG, (gameover ? 0x01 : 0x00)}; + const uint8_t payload[2] = {DEATH_MSG, lives}; p2pSendMsg(&lumberjack->p2p, payload, ARRAY_SIZE(payload), lumberjackMsgTxCbFn); } } @@ -577,6 +616,7 @@ static void lumberjackMsgTxCbFn(p2pInfo* p2p, messageStatus_t status, const uint case MSG_FAILED: { // TODO figure out what to do if a message fails to transmit (i.e. no ack). Retry? + ESP_LOGI(LUM_TAG, "Failed?"); break; } } @@ -584,9 +624,10 @@ static void lumberjackMsgTxCbFn(p2pInfo* p2p, messageStatus_t status, const uint void lumberjackInitp2p() { - //ESP_LOGD(LUM_TAG, "Init connection!"); + ESP_LOGI(LUM_TAG, "Init connection!"); p2pDeinit(&lumberjack->p2p); + lumberjack->conStatus = CON_LOST; p2pInitialize(&lumberjack->p2p,(lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x13 : 0x15), lumberjackConCb, lumberjackMsgRxCb, -70); p2pStartConnection(&lumberjack->p2p); } diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index cebbfc7a9..b592fffaa 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -111,6 +111,8 @@ typedef struct int upgrade; int resume; int lives; + uint8_t nLives; + int64_t worldTimer; int64_t levelTime; @@ -128,6 +130,7 @@ typedef struct int score; int highscore; int localPlayerType; + uint8_t netPlayerType; int enemyAttackQueue; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 5b3edbb6b..11dcac685 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -81,6 +81,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv = calloc(1, sizeof(lumberjackVars_t)); lumv->lumberjackMain = main; lumv->localPlayerType = characterIndex; + lumv->netPlayerType = 1; lumv->score = 0; lumv->highscore = lumv->lumberjackMain->save.highScore; @@ -105,6 +106,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->gameState = LUMBERJACK_GAMESTATE_TITLE; lumv->levelIndex = 0; lumv->lives = 3; + lumv->nLives = 3; lumv->gameReady = !(main->networked); lumv->invincibleColor = c000; @@ -113,6 +115,7 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->itemBlockIndex = -1; lumv->itemBlockItemAnimation = 0; + loadWsg("lumbers_title.wsg", &lumv->title, true); if (main->screen == LUMBERJACK_A) @@ -416,14 +419,15 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) lumv->song_theme.shouldLoop = true; lumv->song_title.shouldLoop = true; + + + bzrPlayBgm(&lumv->song_title, BZR_STEREO); + if (lumv->lumberjackMain->networked) { lumberjackInitp2p(); } - - bzrPlayBgm(&lumv->song_title, BZR_STEREO); - } bool lumberjackLoadLevel() @@ -497,6 +501,7 @@ bool lumberjackLoadLevel() lumv->itemBlockIndex = -1; } + ESP_LOGI(LUM_TAG, "Loading level!"); size_t ms; uint8_t *buffer = spiffsReadFile(fname, &ms, false); @@ -552,6 +557,8 @@ bool lumberjackLoadLevel() lumv->waterSpeed = (int)buffer[11]; lumv->waterTimer = (int)buffer[11]; + + //return false; for (int i = 0; i < lumv->currentMapHeight * LUMBERJACK_MAP_WIDTH; i++) { @@ -583,7 +590,7 @@ bool lumberjackLoadLevel() void lumberjackSetupLevel(int characterIndex) { - bzrStop(true); // Stop the buzzer? + //bzrStop(true); // Stop the buzzer? lumv->enemyKillCount = 0; lumv->totalEnemyCount = 0; @@ -744,9 +751,9 @@ void lumberjackSetupLevel(int characterIndex) //ESP_LOGD(LUM_TAG, "LOADED"); if (!lumv->levelMusic) { + bzrPlayBgm(&lumv->song_theme, BZR_STEREO); lumv->levelMusic = true; } - bzrPlayBgm(&lumv->song_theme, BZR_STEREO); } @@ -789,26 +796,30 @@ void lumberjackTitleLoop(int64_t elapsedUs) if (lumv->btnState & PB_B) { + p2pDeinit(&lumv->lumberjackMain->p2p); + switchToSwadgeMode(&lumberjackMode); } else if (lumv->lumberjackMain->networked) { if (lumv->btnState & PB_A && lumv->gameReady && lumv->lumberjackMain->host && lumv->lumberjackMain->conStatus == CON_ESTABLISHED) // And Game Ready! { - lumberjackPlayGame(); + lumberjackSendCharacter(lumv->localPlayerType); lumberjackSendGo(); + lumberjackPlayGame(); + + } + + if (lumv->lumberjackMain->host == false && lumv->btnState & PB_START) + { + lumberjackSendHostRequest(); } lumv->highscore = 0; } else if (lumv->btnState & PB_A && lumv->gameReady) // And Game Ready! { - lumberjackPlayGame(); - - if (lumv->lumberjackMain->networked && lumv->lumberjackMain->conStatus == CON_ESTABLISHED) - { - lumberjackSendGo(); - } + lumberjackPlayGame(); } //Update Animation @@ -827,8 +838,18 @@ void lumberjackTitleLoop(int64_t elapsedUs) void lumberjackPlayGame() { + if (lumv->gameState == LUMBERJACK_GAMESTATE_PLAYING) + { + return; + } + lumv->gameState = LUMBERJACK_GAMESTATE_PLAYING; lumberjackSetupLevel(lumv->localPlayerType); + + if (lumv->lumberjackMain->networked) + { + lumberjackSendCharacter(lumv->localPlayerType); + } } void lumberjackGameReady(void) @@ -875,6 +896,7 @@ void lumberjackGameLoop(int64_t elapsedUs) { lumv->wakeupSignal = 100; lumberjackSendScore(lumv->score); //Send score just to ping + } if (lumv->lastResponseSignal <= 0) @@ -1574,7 +1596,7 @@ void lumberjackOnLocalPlayerDeath(void) if (lumv->lumberjackMain->networked) { - lumberjackSendDeath(lumv->lives <= 0); + lumberjackSendDeath(lumv->lives); } } @@ -1748,6 +1770,18 @@ void DrawGame(void) drawWsgSimple(&lumv->minicharacters[icon], (i * 14) + 22, 32); } + for (int i = 0; i < lumv->nLives; i++) + { + + int icon = lumv->netPlayerType; + + if (icon > ARRAY_SIZE(lumv->minicharacters)) + { + icon = 0; + } + drawWsgSimple(&lumv->minicharacters[icon], (i * 14) + 206, 32); + } + if (lumv->gameState == LUMBERJACK_GAMESTATE_GAMEOVER) { if (lumv->lumberjackMain->networked && lumv->lastResponseSignal <= 0) @@ -2028,6 +2062,11 @@ void lumberjackOnReceiveScore(const uint8_t* score) lumv->highscore = locX; } +void lumberjackOnReceiveCharacter(uint8_t character) +{ + lumv->netPlayerType = character; +} + void lumberjackOnReceiveBump(void) { if (lumv->localPlayer->onGround) @@ -2061,10 +2100,10 @@ void lumberjackOnReceiveBump(void) lumv->itemBlockIndex = -1; } -void lumberjackOnReceiveDeath(bool gameover) +void lumberjackOnReceiveDeath(uint8_t lives) { - if (gameover) + if (lives < 1) { lumv->hasWon = true; @@ -2076,6 +2115,8 @@ void lumberjackOnReceiveDeath(bool gameover) } } + ESP_LOGI(LUM_TAG, "Lives: %d", lives); + lumv->nLives = lives - 1; } void lumberjackAttackCheck(int64_t elapseUs) diff --git a/main/modes/lumberjack/lumberjackGame.h b/main/modes/lumberjack/lumberjackGame.h index 8da9fb6df..f57f5a7aa 100644 --- a/main/modes/lumberjack/lumberjackGame.h +++ b/main/modes/lumberjack/lumberjackGame.h @@ -33,17 +33,21 @@ void lumberjackQualityCheck(void); void lumberjackSendAttack(uint8_t* number); void lumberjackSendScore(int score); -void lumberjackSendDeath(bool gameover); +void lumberjackSendCharacter(uint8_t character); +void lumberjackSendDeath(uint8_t lives); void lumberjackSendBump(void); void lumberjackOnReceiveAttack(const uint8_t* attack, int len); void lumberjackOnReceiveScore(const uint8_t* score); -void lumberjackOnReceiveDeath(bool gameover); +void lumberjackOnReceiveCharacter(uint8_t character); +void lumberjackOnReceiveDeath(uint8_t lives); void lumberjackOnReceiveBump(void); void lumberjackGameReady(void); void lumberjackPlayGame(void); void lumberjackSendGo(void); +void lumberjackSendHostRequest(void); + void drawSolidWsg(const wsg_t* wsg, int16_t xOff, int16_t yOff, bool flipLR, bool flipUD, uint8_t inColor); From 4fb603560d307aa4fd3180c216dedd0ba5c317e2 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 18 Nov 2023 16:16:41 -0800 Subject: [PATCH 52/54] Added connection lost functionality Added call to action if on title. Added a kick out if in the game. --- main/modes/lumberjack/lumberjack.c | 9 ++-- main/modes/lumberjack/lumberjack.h | 4 +- main/modes/lumberjack/lumberjackGame.c | 75 +++++++------------------- 3 files changed, 27 insertions(+), 61 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index 401961f3e..edca43752 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -61,7 +61,7 @@ const char LUMBERJACK_SAVE[] = "lumberjackdata"; swadgeMode_t lumberjackMode = { .modeName = lumberjackName, - .wifiMode = ESP_NOW, + .wifiMode = ESP_NOW_IMMEDIATE, .overrideUsb = false, .usesAccelerometer = false, .usesThermometer = false, @@ -248,6 +248,7 @@ static void lumberjackMainLoop(int64_t elapsedUs) break; } } + } static void lumberjackMenuLoop(int64_t elapsedUs) @@ -444,7 +445,9 @@ static void lumberjackConCb(p2pInfo* p2p, connectionEvt_t evt) { // TODO drop back to main menu or show an error or something, its not recoverable ESP_LOGI(LUM_TAG, "We lost connection!"); - lumberjackInitp2p(); + + lumberjack->connLost = true; + //lumberjack->menuReturn = 3000; break; } } @@ -624,8 +627,6 @@ static void lumberjackMsgTxCbFn(p2pInfo* p2p, messageStatus_t status, const uint void lumberjackInitp2p() { - ESP_LOGI(LUM_TAG, "Init connection!"); - p2pDeinit(&lumberjack->p2p); lumberjack->conStatus = CON_LOST; p2pInitialize(&lumberjack->p2p,(lumberjack->gameMode == LUMBERJACK_MODE_PANIC ? 0x13 : 0x15), lumberjackConCb, lumberjackMsgRxCb, -70); diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index b592fffaa..a3b8b65ab 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -48,10 +48,12 @@ typedef struct font_t arcade; uint8_t selected; - bool networked; bool host; bool instructions; + bool networked; + bool connLost; + // The pass throughs p2pInfo p2p; connectionEvt_t conStatus; diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index 11dcac685..cbd603d57 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -418,14 +418,12 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadSong("l_song_gameover.sng", &lumv->song_gameover, false); lumv->song_theme.shouldLoop = true; lumv->song_title.shouldLoop = true; - - + bzrPlayBgm(&lumv->song_title, BZR_STEREO); if (lumv->lumberjackMain->networked) { - lumberjackInitp2p(); } } @@ -892,11 +890,12 @@ void lumberjackGameLoop(int64_t elapsedUs) lumv->wakeupSignal -= elapsedUs/10000; lumv->lastResponseSignal -= elapsedUs/10000; + if (lumv->lumberjackMain->connLost) lumv->lastResponseSignal = 0; + if (lumv->wakeupSignal < 0) { lumv->wakeupSignal = 100; lumberjackSendScore(lumv->score); //Send score just to ping - } if (lumv->lastResponseSignal <= 0) @@ -1627,7 +1626,14 @@ void DrawTitle(void) drawWsgSimple(&lumv->floorTiles[7], i * LUMBERJACK_TILE_SIZE, 224); } - if (lumv->gameReady) + if (lumv->lumberjackMain->connLost) + { + drawWsgSimple(&lumv->connectLostSprite, (TFT_WIDTH/2) - 90, (TFT_HEIGHT/2) - 9); + const char* error = "Press B"; + int16_t tWidthC = textWidth(&lumv->arcade, error); + + lumberjackTitleDisplayText(error, (TFT_WIDTH - tWidthC) / 2, 180); + } else if (lumv->gameReady) { const char* hostText = "Press A to start"; const char* clientText = "Host must start"; @@ -1782,13 +1788,15 @@ void DrawGame(void) drawWsgSimple(&lumv->minicharacters[icon], (i * 14) + 206, 32); } - if (lumv->gameState == LUMBERJACK_GAMESTATE_GAMEOVER) + if (lumv->lumberjackMain->connLost) + { + drawWsgSimple(&lumv->connectLostSprite, (TFT_WIDTH/2) -80, (TFT_HEIGHT/2) - 9); + } + else if (lumv->gameState == LUMBERJACK_GAMESTATE_GAMEOVER) { if (lumv->lumberjackMain->networked && lumv->lastResponseSignal <= 0) - { - - drawWsgSimple(&lumv->connectLostSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); - + { + drawWsgSimple(&lumv->connectLostSprite, (TFT_WIDTH/2) -80, (TFT_HEIGHT/2) - 9); } else if (lumv->hasWon) { drawWsgSimple(&lumv->gamewinSprite, (TFT_WIDTH/2) -72, (TFT_HEIGHT/2) - 9); @@ -1850,54 +1858,9 @@ void DrawGame(void) } - //currentBonus->time += ; - //currentBonus->bonusAmount = lumv->comboAmount; - } - - - //drawRect() - // Debug - - /* - char debug[20] = {0}; - snprintf(debug, sizeof(debug), "Enemy: %d ", - lumv->totalEnemyCount); - drawText(&lumv->arcade, c000, debug, 16, 16); - - - drawRect(lumv->localPlayer->cX, lumv->localPlayer->cY - lumv->yOffset, lumv->localPlayer->cX + - lumv->localPlayer->cW, lumv->localPlayer->cY - lumv->yOffset + lumv->localPlayer->cH, c050); - - if (lumv->localPlayer->jumpPressed) - { - drawText(&lumv->arcade, c555, "A", 16, 32); - } - else - { - drawText(&lumv->arcade, c000, "A", 16, 32); } + - if (lumv->localPlayer->attackPressed) - { - drawText(&lumv->arcade, c555, "B", 48, 32); - } - else - { - drawText(&lumv->arcade, c000, "B", 48, 32); - } - - if (lumv->localPlayer->onGround) - { - drawText(&lumv->arcade, c555, "G", 80, 32); - } - else - { - drawText(&lumv->arcade, c000, "G", 80, 32); - } //lumv->spawnTimer - - snprintf(debug, sizeof(debug), "%d", lumv->spawnTimer); - drawText(&lumv->arcade, c555, debug, 122, 32); - */ } void lumberjackTitleDisplayText(const char* string, int locationX, int locationY) From 83fb45c10dd772b4f44d7c7cbd9c91fd931c6576 Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 18 Nov 2023 17:06:58 -0800 Subject: [PATCH 53/54] Fixed networking icons Disabled 2nd player icons when not networked Fixed typos --- main/modes/lumberjack/lumberjack.c | 21 ++------------------- main/modes/lumberjack/lumberjackGame.c | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index edca43752..a84f35838 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -13,7 +13,7 @@ #include "lumberjackGame.h" #define LUMBERJACK_VLEN 7 -#define LUMBERJACK_VERSION "2311174a" +#define LUMBERJACK_VERSION "231118a" #define DEFAULT_HIGHSCORE 5000 @@ -684,24 +684,7 @@ static void lumberjackMenuCb(const char* label, bool selected, uint32_t settingV else if (label == lumberjackExit) { switchToSwadgeMode(&mainMenuMode); - } - - if (label == lumberjackRedCharacter) - { - lumberjack->selected = 0; - } - else if (label == lumberjackGreenCharacter) - { - lumberjack->selected = 1; - } - else if (label == lumberjackSpecialCharacter) - { - lumberjack->selected = 2; - } - else if (label == lumberjackChoCharacter) - { - lumberjack->selected = 3; - } + } } else diff --git a/main/modes/lumberjack/lumberjackGame.c b/main/modes/lumberjack/lumberjackGame.c index cbd603d57..f53e32444 100644 --- a/main/modes/lumberjack/lumberjackGame.c +++ b/main/modes/lumberjack/lumberjackGame.c @@ -179,8 +179,6 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_rtile_4.wsg", &lumv->animationTiles[15], true); - - //Loading Characters //*Loading character icons loadWsg("lumbers_red_lives.wsg", &lumv->minicharacters[0], true); @@ -389,9 +387,9 @@ void lumberjackStartGameMode(lumberjack_t* main, uint8_t characterIndex) loadWsg("lumbers_items_pear4.wsg", &lumv->itemIcons[15], true); loadWsg("lumbers_items_pear5.wsg", &lumv->itemIcons[16], true); loadWsg("lumbers_items_pear6.wsg", &lumv->itemIcons[17], true); - } + //Sounds? if (lumv->gameType == LUMBERJACK_MODE_ATTACK) @@ -1776,16 +1774,19 @@ void DrawGame(void) drawWsgSimple(&lumv->minicharacters[icon], (i * 14) + 22, 32); } - for (int i = 0; i < lumv->nLives; i++) + if (lumv->lumberjackMain->networked) { - - int icon = lumv->netPlayerType; - - if (icon > ARRAY_SIZE(lumv->minicharacters)) + for (int i = 0; i < lumv->nLives; i++) { - icon = 0; + + int icon = lumv->netPlayerType; + + if (icon > ARRAY_SIZE(lumv->minicharacters)) + { + icon = 0; + } + drawWsgSimple(&lumv->minicharacters[icon], (i * 14) + 206, 32); } - drawWsgSimple(&lumv->minicharacters[icon], (i * 14) + 206, 32); } if (lumv->lumberjackMain->connLost) From 12802219016d6b317485fd78dad6153715df3f8c Mon Sep 17 00:00:00 2001 From: MrTroy Date: Sat, 18 Nov 2023 18:30:36 -0800 Subject: [PATCH 54/54] Fixed secret characters not loading --- main/modes/lumberjack/lumberjack.c | 17 ++++++++++++----- main/modes/lumberjack/lumberjack.h | 10 ++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/main/modes/lumberjack/lumberjack.c b/main/modes/lumberjack/lumberjack.c index a84f35838..7bab4ef62 100644 --- a/main/modes/lumberjack/lumberjack.c +++ b/main/modes/lumberjack/lumberjack.c @@ -7,6 +7,7 @@ #include "mainMenu.h" #include "menu.h" +#include "mode_ray.h" // For lumberjack #include "lumberjack.h" @@ -54,7 +55,7 @@ static char lumberjackChoCharacter[] = "Character: Cho"; static const char lumberjackMenuSinglePlayer[] = "Single Player"; static const char lumberjackMenuMultiPlayer[] = "Multi-Player"; -static const char lumberjackPlatformerUnlock[] = "pf_unlocks"; +static const char lumberjackPlatformerUnlock[] = "pf_scores"; static const char lumberjackChoUnlock[] = "ray"; const char* LUM_TAG = "LUM"; const char LUMBERJACK_SAVE[] = "lumberjackdata"; @@ -385,14 +386,20 @@ static void lumberjackBackgroundDrawCallback(int16_t x, int16_t y, int16_t w, in static bool lumberjackChoUnlocked() { - int32_t kei; - return readNvs32(lumberjackChoUnlock, &kei); + rayPlayer_t cho; + size_t size = sizeof(cho); + + return readNvsBlob(lumberjackChoUnlock, &cho, &(size)); } static bool lumberjackSwadgeGuyUnlocked() { - int32_t kei; - return readNvs32(lumberjackPlatformerUnlock, &kei); + pfHighScores_t highScores; + size_t size = sizeof(pfHighScores_t); + // Try reading the value + + return readNvsBlob(lumberjackPlatformerUnlock, &(highScores), &(size)); + } //============================================================================== diff --git a/main/modes/lumberjack/lumberjack.h b/main/modes/lumberjack/lumberjack.h index a3b8b65ab..fbb3cb018 100644 --- a/main/modes/lumberjack/lumberjack.h +++ b/main/modes/lumberjack/lumberjack.h @@ -237,4 +237,14 @@ typedef struct } lumberjackVars_t; +#define NUM_PLATFORMER_HIGH_SCORES 5 + +typedef struct { + uint32_t scores[NUM_PLATFORMER_HIGH_SCORES]; + char initials[NUM_PLATFORMER_HIGH_SCORES][3]; +} pfHighScores_t; + +typedef struct +{ ///< All the players items +} pfRay_t; #endif \ No newline at end of file