From: parking_turkeys Date: Sat, 25 Jul 2026 18:45:42 +0000 (-0400) Subject: add hitbox feature (press Q) and fix the background on the timer! X-Git-Tag: v1.0~12 X-Git-Url: http://git.parking-turkeys.net/?a=commitdiff_plain;h=9602134dd9c058b005d2f1c64fd2788aec588d14;p=aichan-platformer.git add hitbox feature (press Q) and fix the background on the timer! --- diff --git a/game.h b/game.h index de0af09..3110af7 100644 --- a/game.h +++ b/game.h @@ -114,3 +114,4 @@ extern int mode; extern int inputs[]; extern int deaths; extern int COIN_COUNT; +extern int drawhitboxes; diff --git a/level.c b/level.c index 91c177b..1776024 100644 --- a/level.c +++ b/level.c @@ -40,17 +40,20 @@ int bühnezeichnen(void) //draw all the platforms and stuff for (int i = 0; i < stages[level].platform_count; i++) { DrawRectangleRec(stages[level].platforms[i].rect, stages[level].platforms[i].colour); + if (drawhitboxes) { DrawRectangleLinesEx(currstage->platforms[i].rect, 1, BLACK); }; }; for (int i = 0; i < stages[level].danger_count; i++) { DrawRectangleRec(stages[level].dangers[i].rect, stages[level].dangers[i].colour); + if (drawhitboxes) { DrawRectangleLinesEx(currstage->dangers[i].rect, 1, WHITE); }; } for (int i = 0; i < currstage->object_count; i++) { drawobject(currstage->objects+i); } for (int i = 0; i < currstage->coingroup_count; i++) { - drawcoingroup(currstage->coingroups+i); + drawcoingroup(currstage->coingroups+i); + }; if (frozen == 1) { //currently in dialogue at beginning of stage @@ -160,7 +163,8 @@ int is_killed(struct Rectangle *rect) for (int i = 0; i < (s->coingroup_count); i++) { struct coingroup *cg = s->coingroups+i; for (int n = 0; n < (cg->coin_count); n++) { - if ((cg->collected[n] == 0) && (CheckCollisionRecs(*rect,(Rectangle){(cg->position.x + 2 + n * (cg->padding + COINWIDTH)), cg->position.y, COINWIDTH - 4, COINWIDTH}))) { + Rectangle cr = {(cg->position.x + 2 + n * (cg->padding + COINWIDTH)), (cg->position.y + 2), (COINWIDTH - 4), (COINWIDTH - 4)}; + if ((cg->collected[n] == 0) && (CheckCollisionRecs(*rect,cr))) { collectcoin(cg, n); }; }; @@ -246,6 +250,9 @@ int drawobject(struct object *o) t = LoadTextureFromImage(img); UnloadImage(img); DrawTexture(t,o->rect.x,o->rect.y,WHITE); + if (drawhitboxes) { + DrawRectangleLinesEx(o->rect,1,PINK); + }; //DrawText("R", <-- I was going to try to add an "R" tip but it seemed hard... ill do it sometime lol return 1; }; @@ -273,6 +280,10 @@ int drawcoingroup(struct coingroup *cg) if (cg->collected[i] == 0) { //draw the coin :3 DrawTexture(coin_txtr, cg->position.x + i * (COINWIDTH + cg->padding), cg->position.y, WHITE); + if (drawhitboxes) { + Rectangle cr = {(cg->position.x + 2 + i * (cg->padding + COINWIDTH)), (cg->position.y + 2), (COINWIDTH - 4), (COINWIDTH - 4)}; + DrawRectangleLinesEx(cr, 1, PINK); + }; }; }; }; diff --git a/level_data.h b/level_data.h index f5e7c47..971c6b1 100644 --- a/level_data.h +++ b/level_data.h @@ -3,8 +3,8 @@ #define PLATFORMCOUNT 83 #define DANGERCOUNT 34 #define OBJECTCOUNT 5 -#define COINCOUNT 106 -#define COINGROUPCOUNT 11 +#define COINCOUNT 153 +#define COINGROUPCOUNT 16 #include "game.h" #include @@ -270,7 +270,17 @@ struct coingroup coins[COINGROUPCOUNT] = { {{100,285},5,collected_coins+76,6}, {{200,255},4,collected_coins+81,5}, {{280,225},15,collected_coins+85,5}, - {{560,405},5,collected_coins+100,6} + {{560,405},5,collected_coins+100,6}, + + + {{80,305},31,collected_coins+105,5}, + {{400,65},5,collected_coins+136,6}, + {{540,85},5,collected_coins+141,6}, + + + {{80,385},6,collected_coins+146,6}, + {{175,400},1,collected_coins+152,5} + }; struct object objects[OBJECTCOUNT] = { @@ -286,8 +296,8 @@ struct stage stages[STAGECOUNT] = { {"Jumping", platforms+1, 2, dialogues+7, 1, danger, 0,NULL,0,coins+1,3}, {"Danger", platforms+3, 1, dialogues+8, 1, danger, 4,NULL,0,coins+4,2}, {"(level)", platforms+4, 5, NULL,0,danger+4,1,NULL,0,coins+6,5}, - {"Wall-jumping", platforms+9, 3,dialogues+9,1,danger,0,NULL,0,NULL,0}, - {"(level)", platforms+12, 7, NULL,0,danger+5,4,NULL,0,NULL,0}, + {"Wall-jumping", platforms+9, 3,dialogues+9,1,danger,0,NULL,0,coins+11,3}, + {"(level)", platforms+12, 7, NULL,0,danger+5,4,NULL,0,coins+14,2}, {"Interact", platforms+19,4, dialogues+10,3,danger+9,3,objects,1,NULL,0}, {"(level)", platforms+23,11,NULL,0,danger+12,5,NULL,0,NULL,0}, {"Ominous", platforms+34,14,dialogues+17,2,danger+17,4,NULL,0,NULL,0}, diff --git a/main_v2.c b/main_v2.c index 89fbcd5..63bbeb7 100644 --- a/main_v2.c +++ b/main_v2.c @@ -10,11 +10,12 @@ #include #include // seems useful -int level = 3; +int level = 5; int frozen = 0; //0:game, 1:stage dialogue, 2+:object[frozen-2] dialogue int mode = 0; //0:'start game', 1: 'levels', 2:'end screen' (later: 2 will be bossfight and 3 will be end screen lol) int fullsectime = 0; int deaths = 0; +int drawhitboxes = 0; int main(void) { @@ -37,13 +38,14 @@ int main(void) break; case LEVELMODE: if (!frozen) {variables(GetFrameTime(), player);}; + if (IsKeyPressed(KEY_Q)) { drawhitboxes = 1; }; if (mode == LEVELMODE) { ZeichnenAnfangen(); bühnezeichnen(); if (!frozen) {spielerzeichnen();}; DrawRectangle(1, 468, 45, 12, WHITE); DrawText(TextFormat("FPS: %2i", GetFPS()), 2, 469, 10, BLACK); - DrawRectangle(1, 0, 45, 12, WHITE); + DrawRectangle(1, 0,115, 12, WHITE); DrawText(TextFormat("Seconds played: %5.2f", GetTime()), 2, 0, 10, BLACK); ZeichnenAufhören(); }; diff --git a/player.c b/player.c index a787caf..4a4b3bd 100644 --- a/player.c +++ b/player.c @@ -57,6 +57,7 @@ int spielerzeichnen(void) time_since_switch = 0.0; } DrawTexture(txtr, player.rect.x + x_offset, player.rect.y, WHITE); + if (drawhitboxes) { DrawRectangleLinesEx(player.rect, 1, YELLOW); }; } int spieler_bewegen(float delta) // should actually only change velocity, physics file moves player based on velocity uwu