From 1e586ce7ab8df9e9e32e46343a1f0148ecfe415c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sun, 22 Mar 2020 11:31:02 +0100 Subject: [PATCH] Limit ammo and health --- TODO.txt | 30 ++++++++++++++++-------------- assets/levelY.gif | Bin 0 -> 2838 bytes constants.h | 13 ++++++++++++- main.c | 30 ++++++++++++++++++++++-------- settings.h | 7 ++++++- 5 files changed, 56 insertions(+), 24 deletions(-) create mode 100644 assets/levelY.gif diff --git a/TODO.txt b/TODO.txt index 6334ade..5f0f80a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,21 +1,8 @@ general: -- try to make z-buffer 3 line instead of 1D, possibly like this (to keep - performance): - - at compile time selct X = power of 2 closest to vertical resolution - (or something like that) - - in pixel funct do something like - if (pixel->y % X == 0 && pixel->y != 0) - write to z-buffer -- let player start with 100 HP, but allow for collecting a higher amount, e.g. - up to 150. -- Add blinking: - - In menu, the selected level number should blink to indicate it can be - changed. - - Near locked door the specific unlocking card should blink on the HUD bar. - - Add setting SFG_BLINK_PERIOD to control blinking speed. - try to remove the debug flag (-g1) from compiler and see if it decreases size - port to GB Meta +- add enemy moving/dying sound - sounds (music?) - level 2D map (with revealing, bitmap), special key for quick displaying map - save/load (optional) @@ -64,6 +51,9 @@ level ideas: has to slowly kill, which means he has to first get rid of the other monsters. +- ceiling with "holes" through which sky (background) can be seen -- can be done + by having the ceiling texture set transparent and then alternating ceiling and + no ceiling - boss level: skyscraper top, player goes upwards in a spiral along the OUTSIDE side of the skyscraper - two levels could partially overlap, e.g. level one, a city, could overlap @@ -141,6 +131,7 @@ bugs: done: - add headbob +- add blinking - make zBuffer 8bit only? - texture coords of floor walls should start from the floor? NO, CAUSES ISSUES - vertical visual noise when standing on elevator @@ -161,4 +152,15 @@ done: check collisions for both player and monsters against this array (elevate these squares for collisions only) -- will also be faster - more level prop items +- let player start with 100 HP, but allow for collecting a higher amount, e.g. + up to 150. +- limit maximum ammo amounts +scratched: +- try to make z-buffer 3 line instead of 1D, possibly like this (to keep + performance): + - at compile time selct X = power of 2 closest to vertical resolution + (or something like that) + - in pixel funct do something like + if (pixel->y % X == 0 && pixel->y != 0) + write to z-buffer diff --git a/assets/levelY.gif b/assets/levelY.gif new file mode 100644 index 0000000000000000000000000000000000000000..a73ba268de035887c6e3e70aec152549c4210c70 GIT binary patch literal 2838 zcmV+x3+ePnNk%w1VT%BZ0O$Vz0096803iVbA|L<&4*)?J03ja%5C{h#0t-JG2p=N= zVIT*06zc~Ap#F#A`bu(6CYpz02mY@9~1~76BaoDpb!`$ z9~BT76h8nV08s#603Z$qAOHj)2x0&)4;&aD84d&?8VweII|9QEAP^297JvW%G7~-- zAO#yB02m+)K@ulH6c7L%piKbb3MD~t0EB@6OCls8Tmbn2EJ2|F04N||KOq4CCBusV zprHU*Cn!I`00Iss;bI;hKqoRcDL+3cC{Q3?06_*pED|L#Kw=(213)G>D1*QNX{i9g z2tXj>000$002@FMA2?wVKsFgJ`9U-$`Tzi5F#rlgUf}?CFhC6`KrSjkDaQceBtbbi zKmdX!CTJ*sI6xM9sfL$e0WPb#JR&G@NDS!as zM@B7xMrmtkIe;ZaaK9*jdT(f>ze?iaMxcOfO#qF-z-0hYfMStnpmBcy0H7IIfKpC? zd7o)!Xn-f8XNmY!PH%uvp>#0_pK;hz`ecEjPJ`btpaA$*xB#KzD4<|Np(=%d!ZDzi z-*^C?iD&@97gCq`uYbb8fPjvWjlhAPz==Tsz<+U{XlS5+kDvf$p_qlCFMpW96u0>K zhX9bEXhXpOpOxS{z;7_Xx>CVE0^kqcm5|Ys;@_0Q;h#jpq<@pI-xc7LfxwrFz<#=@ z_n^Q$vA_U>z_(N20I{^NvA}>#;C%U~r4RfnWZ**Rsrmb-*ht{m0Q{`@xlH1}ji<}| zUi<`(;Iqfz0G{EFjp5qD-$GCPlzRM1Q~dbO;gQza)%e?{r2WRY{HW&q0NVUasr~lq z{G|E&`2YX^A^8LW3IP8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1SX9<6rwpAs6^A* zP>jNJqx&@IJ@5HXiab;+_AIG8SGv-Y{&S=xC22lEs?Q>Y>7*tdX-;v(QkA|GrZ3&8 zNspvansU>dK@Dn4VcJrcvb3o^Md?y6I#Z)^be$DV5><;Pp4 zV})XEvTD|$RwS+CEUQv2I@G8Blp@JoW;34|&1qKino=SuTH)Hna_aQ1Qa$NK^U6$T zLQ|U5wB{LdikFKJ_NXIKtWTY)(}yy4uaEVsWCQ!q!Csc1CTc5BL2_Dcf;CSuz5eT^ zOxs!lzP3zDP3mlGtIpJ3Dz>@J6K#3R(2=NCN5ds9I&Q0_t?J0R?NaU~jY}rG=t;Ws z^et|G1YJ~Nx3JVbZqB}&K<0`!xx_W^anZ|L^{SS=wRLY>;oDmInw7q%wQpGQds+Q@ zl)r@aFGc|jR{=wmz-cuwLJ>Sx1*7UHmL)H0ZJOBJN>!yy-KocJ@PRaapizj5#s|JZ z;t#mY9v|RknrT;da_c*PNJv2Bg3*x(k~r-`iy zn{IrG9G_yxB>skpUG`%Ruvo}L*6y^B5@akFH?4*VcCW`XSs-Upz)RH zis&t!o+GwbfxuupN8JWJx`1GH{dl o``|LE$VwERGlmNsC`CcI#8YAuFfH8TKj}!sC(iMXLnI&oJD9{9rT_o{ literal 0 HcmV?d00001 diff --git a/constants.h b/constants.h index 84f0610..35b03b0 100644 --- a/constants.h +++ b/constants.h @@ -114,7 +114,12 @@ /** Maximum player health. */ -#define SFG_PLAYER_MAX_HEALTH 100 +#define SFG_PLAYER_MAX_HEALTH 150 + +/** + Start health of player. +*/ +#define SFG_PLAYER_START_HEALTH 100 /** At which value health indicator shows a warning (red color). @@ -166,6 +171,10 @@ #define SFG_AMMO_INCREASE_ROCKETS 5 #define SFG_AMMO_INCREASE_PLASMA 8 +#define SFG_AMMO_MAX_BULLETS 200 +#define SFG_AMMO_MAX_ROCKETS 100 +#define SFG_AMMO_MAX_PLASMA 150 + /** Duration of story text (intro/outro) in ms. */ @@ -355,6 +364,8 @@ #define SFG_HUD_BORDER_INDICATOR_DURATION_FRAMES 1 #endif +#define SFG_BLINK_PERIOD_FRAMES (SFG_BLINK_PERIOD / SFG_MS_PER_FRAME) + #define SFG_HUD_BAR_HEIGHT \ (SFG_FONT_CHARACTER_SIZE * SFG_FONT_SIZE_MEDIUM + SFG_HUD_MARGIN * 2 + 1) diff --git a/main.c b/main.c index 75df9ce..59d53d8 100755 --- a/main.c +++ b/main.c @@ -1119,7 +1119,7 @@ void SFG_initPlayer() SFG_player.lastHurtFrame = SFG_game.frame; SFG_player.lastItemTakenFrame = SFG_game.frame; - SFG_player.health = SFG_PLAYER_MAX_HEALTH; + SFG_player.health = SFG_PLAYER_START_HEALTH; SFG_player.cards = 0; @@ -2479,7 +2479,7 @@ void SFG_gameStepPlaying() return; } - int8_t recomputeDirection = 0; + int8_t recomputeDirection = SFG_currentLevel.frameStart == SFG_game.frame; RCL_Vector2D moveOffset; @@ -2877,21 +2877,33 @@ void SFG_gameStepPlaying() switch (e->type) { case SFG_LEVEL_ELEMENT_HEALTH: - SFG_playerChangeHealth(SFG_HEALTH_KIT_VALUE); + if (SFG_player.health < SFG_PLAYER_MAX_HEALTH) + SFG_playerChangeHealth(SFG_HEALTH_KIT_VALUE); + else + eliminate = 0; break; - + +#define addAmmo(type) \ + if (SFG_player.ammo[SFG_AMMO_##type] < SFG_AMMO_MAX_##type) \ + SFG_player.ammo[SFG_AMMO_##type] = RCL_min(SFG_AMMO_MAX_##type,\ + SFG_player.ammo[SFG_AMMO_##type] + SFG_AMMO_INCREASE_##type);\ + else\ + eliminate = 0; + case SFG_LEVEL_ELEMENT_BULLETS: - SFG_player.ammo[SFG_AMMO_BULLETS] += SFG_AMMO_INCREASE_BULLETS; + addAmmo(BULLETS) break; case SFG_LEVEL_ELEMENT_ROCKETS: - SFG_player.ammo[SFG_AMMO_ROCKETS] += SFG_AMMO_INCREASE_ROCKETS; + addAmmo(ROCKETS) break; case SFG_LEVEL_ELEMENT_PLASMA: - SFG_player.ammo[SFG_AMMO_PLASMA] += SFG_AMMO_INCREASE_PLASMA; + addAmmo(PLASMA) break; +#undef addAmmo + case SFG_LEVEL_ELEMENT_CARD0: case SFG_LEVEL_ELEMENT_CARD1: case SFG_LEVEL_ELEMENT_CARD2: @@ -3562,7 +3574,9 @@ void SFG_drawMenu() SFG_drawText(text,drawX,y,SFG_FONT_SIZE_MEDIUM,textColor,0,0); - if (item == SFG_MENU_ITEM_PLAY) + if (item == SFG_MENU_ITEM_PLAY && + (((i != SFG_game.selectedMenuItem) || + (SFG_game.frame / SFG_BLINK_PERIOD_FRAMES) % 2))) SFG_drawNumber((SFG_game.selectedLevel + 1), drawX + SFG_characterSize(SFG_FONT_SIZE_MEDIUM) * (textLen + 1), y,SFG_FONT_SIZE_MEDIUM,93); diff --git a/settings.h b/settings.h index 5b54e53..2020210 100644 --- a/settings.h +++ b/settings.h @@ -189,12 +189,17 @@ */ #define SFG_BACKGROUND_BLUR 0 +/** + Defines the period, in ms, of things that blink, such as text. +*/ +#define SFG_BLINK_PERIOD 500 + //------ developer/debug settings ------ /** Developer cheat for having infinite ammo in all weapons. */ -#define SFG_INFINITE_AMMO 1 +#define SFG_INFINITE_AMMO 0 /** Developer cheat for immortality.