From b7ba33a77a1e54616f434f420a05ac655f577c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 8 Feb 2020 20:53:10 +0100 Subject: [PATCH] Take cards --- TODO.txt | 1 + assets/item_card.png | Bin 0 -> 547 bytes images.h | 20 ++++++++++++++++++++ levels.h | 7 +++++-- main.c | 41 ++++++++++++++++++++++++++++++++++------- raycastlib.h | 10 +++++----- 6 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 assets/item_card.png diff --git a/TODO.txt b/TODO.txt index d9065d2..5c487fe 100644 --- a/TODO.txt +++ b/TODO.txt @@ -20,6 +20,7 @@ - add jump pads? - add robot deactivator item? (encourages "stealth" gameplay) - add "pletivo" transparent wall texture? +- add universal corpse sprite? bugs: diff --git a/assets/item_card.png b/assets/item_card.png new file mode 100644 index 0000000000000000000000000000000000000000..c71954b41facc14ddc57657061014d88bbfb3de2 GIT binary patch literal 547 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7l!{JxM1({$v_d#0*}aI z1_nK45N51cYF`EvWH0gbb!C6T#LjMD5hBaL3KWtoag8W(&d<$F%`0JWE=o--Nlj5G z&n(GMaQE~L2yf&QXJBCL_H=O!i8%arntt&i2Z5vVb324Z1%Z&mjzLJW( zUmfoav9*U)L`<*8na3u4KJcZq;A+|@_p{s&-u-5;>wcTuSTajdrtIwL-_PtJWF2QPI58E@uP<(gFTaK_@8s52~SyVh`jl4N$+63wh%Yhc*aFZv_1LE#Fk z1w%`2V8g$iyq_luNAyp^Hws&Nua%8UhZ;)U)Gt3*Q(@?JU$w#%7type - SFG_LEVEL_ELEMENT_CARD0); + break; + default: eliminate = 0; break; @@ -2449,6 +2465,7 @@ void SFG_gameStep() SFG_currentLevel.checkedDoorIndex = 0; } + // move door up/down: for (uint32_t i = 0; i < SFG_currentLevel.doorRecordCount; ++i) { SFG_DoorRecord *door = &(SFG_currentLevel.doorRecords[i]); @@ -2948,7 +2965,8 @@ void SFG_draw() if (p.depth > 0) { - SFG_drawScaledSprite(SFG_itemSprites[e.type - 1], + SFG_drawScaledSprite( + SFG_itemSprites[SFG_getLevelElementSpriteIndex(e.type)], p.position.x * SFG_RAYCASTING_SUBSAMPLE,p.position.y, RCL_perspectiveScale(SFG_SPRITE_SIZE(size),p.depth), p.depth / (RCL_UNITS_PER_SQUARE * 2),p.depth - 1000); @@ -3024,11 +3042,13 @@ void SFG_draw() color = 2; } + #define TEXT_Y (SFG_GAME_RESOLUTION_Y - SFG_HUD_MARGIN - \ + SFG_FONT_CHARACTER_SIZE * SFG_FONT_SIZE_MEDIUM) + SFG_drawNumber( // health SFG_player.health, SFG_HUD_MARGIN, - SFG_GAME_RESOLUTION_Y - SFG_HUD_MARGIN - - SFG_FONT_CHARACTER_SIZE * SFG_FONT_SIZE_MEDIUM, + TEXT_Y, SFG_FONT_SIZE_MEDIUM, SFG_player.health > SFG_PLAYER_HEALTH_WARNING_LEVEL ? 4 : 175); @@ -3036,10 +3056,17 @@ void SFG_draw() SFG_player.ammo[SFG_weaponAmmo(SFG_player.weapon)], SFG_GAME_RESOLUTION_X - SFG_HUD_MARGIN - SFG_FONT_CHARACTER_SIZE * SFG_FONT_SIZE_MEDIUM * 3, - SFG_GAME_RESOLUTION_Y - SFG_HUD_MARGIN - - SFG_FONT_CHARACTER_SIZE * SFG_FONT_SIZE_MEDIUM, + TEXT_Y, SFG_FONT_SIZE_MEDIUM, - 4); + 4); + + for (uint8_t i = 0; i < 3; ++i) // access cards + if (SFG_player.cards & (1 << i)) + SFG_drawText(",",SFG_HUD_MARGIN + SFG_FONT_CHARACTER_SIZE * + SFG_FONT_SIZE_MEDIUM * (6 + i), + TEXT_Y,SFG_FONT_SIZE_MEDIUM,i == 0 ? 93 : (i == 1 ? 124 : 60)); + + #undef TEXT_Y // border indicator diff --git a/raycastlib.h b/raycastlib.h index 033efc2..6e24a52 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -26,7 +26,7 @@ author: Miloslav "drummyfish" Ciz license: CC0 1.0 - version: 0.901 + version: 0.902 */ #include @@ -1680,8 +1680,7 @@ RCL_PixelInfo RCL_mapToScreen(RCL_Vector2D worldPosition, RCL_Unit height, middleColumn + (-1 * toPoint.y * middleColumn) / RCL_nonZero(result.depth); result.position.y = camera.resolution.y / 2 - -(((3 * camera.resolution.y) / 4 ) * -// ((camera.resolution.y / 2) * + (((3 * camera.resolution.y) / 4 ) * RCL_perspectiveScale(height - camera.height,result.depth)) / RCL_UNITS_PER_SQUARE + camera.shear; @@ -1760,8 +1759,9 @@ void RCL_moveCameraWithCollision(RCL_Camera *camera, RCL_Vector2D planeOffset, dir##Collides = 1;\ else if (ceilingHeightFunc != 0)\ {\ - height = ceilingHeightFunc(s1,s2);\ - if (height < topLimit)\ + RCL_Unit height2 = ceilingHeightFunc(s1,s2);\ + if ((height2 < topLimit) || ((height2 - height) < \ + (RCL_CAMERA_COLL_HEIGHT_ABOVE + RCL_CAMERA_COLL_HEIGHT_BELOW)))\ dir##Collides = 1;\ }\ }\