]> _ Git - aichan-platformer.git/commitdiff
interactable objects!! (images are placeholders, ill work on those next
authorparking_turkeys <roya1060wien@gmail.com>
Wed, 22 Jul 2026 22:55:04 +0000 (18:55 -0400)
committerparking_turkeys <roya1060wien@gmail.com>
Wed, 22 Jul 2026 22:55:04 +0000 (18:55 -0400)
game.h
level.c
level_data.h
main_v2.c
player.c

diff --git a/game.h b/game.h
index a6fe8b8..739b155 100644 (file)
--- a/game.h
+++ b/game.h
@@ -20,6 +20,7 @@
 struct character *spielersetup(void);
 int next_level(struct character *player);
 int kill_chara(struct character *player);
+int interact(struct Rectangle *rect);
 
 int bühnezeichnen(void); //i dont think stage works here but it seems better than window
 int spielerzeichnen(void);
@@ -57,6 +58,15 @@ struct dialogue {
        Color characolour;
 };
 
+struct object {
+       Rectangle rect;
+       char *name;
+       char *imgfile;
+       struct dialogue *dialogues;
+       int dialogue_count;
+       int index;
+};
+
 struct stage {
        char *name;
        struct platform *platforms;
@@ -65,6 +75,8 @@ struct stage {
        int dialogue_count;
        struct platform *dangers;
        int danger_count;
+       struct object *objects;
+       int object_count;
 };
 
 struct spritesheet {
@@ -78,3 +90,4 @@ struct spritesheet {
 
 extern int level;
 extern int frozen;
+extern int objects_interacted[];
diff --git a/level.c b/level.c
index 76d2bee..246062b 100644 (file)
--- a/level.c
+++ b/level.c
 
 int current_dialogue = 0;
 
-int drawdialogue(void);
+int drawdialogue(struct dialogue *dialogue);
 int drawcharname(char *name, Color colour);
 int drawcharimage(char *filename);
 int drawdialogueline(char *line);
 
+int drawobject(struct object *object);
+
+int objects_interacted[OBJECTCOUNT] = {0};
+
 int bühnezeichnen(void)
 {
        ClearBackground(BLUE);
+       struct stage *currstage = stages+level;
        //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);
@@ -34,11 +39,15 @@ int bühnezeichnen(void)
                DrawRectangleRec(stages[level].dangers[i].rect, stages[level].dangers[i].colour);
        }
 
-       if (frozen) { //currently in dialogue
+       for (int i = 0; i < currstage->object_count; i++) {
+               drawobject(currstage->objects+i);
+       }
+
+       if (frozen == 1) { //currently in dialogue at beginning of stage
                if (stages[level].dialogues == NULL) {
                        frozen = 0;
                } else {
-               drawdialogue();
+               drawdialogue(stages[level].dialogues+current_dialogue);
                if (IsKeyPressed(ADVANCEKEY)) {
                        if (++current_dialogue == stages[level].dialogue_count) { //dialogue over
                                current_dialogue = 0; //is this not activating or smth...
@@ -46,7 +55,17 @@ int bühnezeichnen(void)
                        }
                }
                }
-       };
+       } else if (frozen > 1) { //currently interacting with an object
+               struct object *o = currstage->objects + (frozen - 2);
+               drawdialogue(o->dialogues + current_dialogue);
+               if (IsKeyPressed(ADVANCEKEY)) {
+                       if (++current_dialogue == o->dialogue_count) {
+                               current_dialogue = 0;
+                               frozen = 0;
+                               objects_interacted[o->index] = 1;
+                       };
+               };
+       }
 
        return 1;
 }
@@ -119,9 +138,8 @@ int is_killed(struct Rectangle *rect) {
        return 0;
 };
 
-int drawdialogue(void)
+int drawdialogue(struct dialogue *dlg)
 {
-       struct dialogue *dlg = &(stages[level].dialogues[current_dialogue]);
        DrawRectangle(0,DLGY,640,DLGHEIGHT,RAYWHITE);
        drawcharname(dlg->charaname,dlg->characolour);
        drawcharimage(dlg->image);
@@ -184,4 +202,24 @@ int cleanup_level(void)
        return 1;
 }
 
+int drawobject(struct object *o)
+{
+       Texture2D t;
+       Image img = LoadImage(o->imgfile);
+       ImageResize(&img, o->rect.width,o->rect.height);
+       t = LoadTextureFromImage(img);
+       UnloadImage(img);
+       DrawTexture(t,o->rect.x,o->rect.y,WHITE);
+       //DrawText("R", <-- I was going to try to add an "R" tip but it seemed hard... ill do it sometime lol
+       return 1;
+};
 
+int interact(Rectangle *r)
+{
+       for (int i = 0; i < stages[level].object_count; i++) {
+               if (CheckCollisionRecs(*r, stages[level].objects[i].rect)) {
+                       frozen = 2 + i;
+               }
+       }
+       return 1;
+};
index 31ae70b..e9b02cb 100644 (file)
@@ -1,7 +1,8 @@
 #define STAGECOUNT 7
-#define DIALOGUECOUNT 14
+#define DIALOGUECOUNT 18
 #define PLATFORMCOUNT 23
 #define DANGERCOUNT 12
+#define OBJECTCOUNT 1
 
 #include "game.h"
 #include <stddef.h>
@@ -32,6 +33,12 @@ struct dialogue dialogues[DIALOGUECOUNT] = {
        {"This level may seem impossible but it is in fact possible.", "Context", "dialogue-img/aichan-default.png", BLACK},
 
 
+       {"Hi Ai-chan >:(", "Sin Mal", "dialogue-img/aichan-default.png", PINK},
+       {"Rozaliya and Liliya want to challenge you to a super peak idol fight", "Sin Mal", "dialogue-img/aichan-default.png", PINK},
+       {"Ok sure", "Ai-chan", "dialogue-img/aichan-neutral.png", GREEN},
+       {"The dialogue in this game keeps getting lower-effort...", "Context", "dialogue-img/aichan-default.png", BLACK},
+
+
        {"YOU WIN!!", "Ai-chan", "dialogue-img/aichan-smile.png", GREEN}
 };
 
@@ -90,17 +97,21 @@ struct platform danger[DANGERCOUNT] = {
        {{460,350,60,20},RED},
 
 
-       {{150,430,20,10},RED},
+       {{150,430,19,10},RED},
        {{420,310,10,10},RED},
-       {{500,310,20,10},RED}
+       {{500,310,19,10},RED}
+};
+
+struct object objects[OBJECTCOUNT] = {
+       {{440,418,15,22}, "Sin Mal", "img/senti_15_22.png" /*temporary*/, dialogues+13,4, 0}
 };
 
 struct stage stages[STAGECOUNT] = {
-       {"Movement", platforms, 1, dialogues, 7, danger, 0},
-       {"Jumping", platforms+1, 2, dialogues+7, 1, danger, 0},
-       {"Danger", platforms+3, 1, dialogues+8, 1, danger, 4},
-       {"(level)", platforms+4, 5, NULL,0,danger+4,1},
-       {"Wall-jumping", platforms+9, 3,dialogues+9,1,danger,0},
-       {"(level)", platforms+12, 7, NULL,0,danger+5,4},
-       {"Interact", platforms+19,4, dialogues+10,3,danger+9,3}
-};     
+       {"Movement", platforms, 1, dialogues, 7, danger, 0,NULL,0},
+       {"Jumping", platforms+1, 2, dialogues+7, 1, danger, 0,NULL,0},
+       {"Danger", platforms+3, 1, dialogues+8, 1, danger, 4,NULL,0},
+       {"(level)", platforms+4, 5, NULL,0,danger+4,1,NULL,0},
+       {"Wall-jumping", platforms+9, 3,dialogues+9,1,danger,0,NULL,0},
+       {"(level)", platforms+12, 7, NULL,0,danger+5,4,NULL,0},
+       {"Interact", platforms+19,4, dialogues+10,3,danger+9,3,objects,1}
+};
index cf7ec85..277e772 100644 (file)
--- a/main_v2.c
+++ b/main_v2.c
@@ -11,7 +11,7 @@
 #include <stdio.h> // seems useful
 
 int level = 6;
-int frozen = 0;
+int frozen = 0; //0:game, 1:stage dialogue, 2+:object[frozen-2] dialogue
 
 int main(void)
 {
index 1ed2176..6150b30 100644 (file)
--- a/player.c
+++ b/player.c
@@ -3,7 +3,7 @@
 #include <math.h>
 #include "game.h"
 struct character player = {{0,300,6,18},{0,0}};
-int inputs[3] = {KEY_A,KEY_D,KEY_H}; //left, right, jump/advance dialogue
+int inputs[6] = {KEY_A,KEY_D,KEY_W,KEY_S,KEY_H,KEY_R}; //left, right, up, down, jump/advance dialogue, interact
 
 static struct spritesheet front_sheet, walk_sheet;
 static struct spritesheet *sheets[2];
@@ -85,10 +85,10 @@ int spieler_bewegen(float delta) // should actually only change velocity, physic
               player.velocity.y = 0;
               //printf("ON FLOOR");
        };             
-       if (on_floor(&player.rect) && IsKeyDown(inputs[2])) {
+       if (on_floor(&player.rect) && IsKeyDown(inputs[4])) {
                player.velocity.y = JUMPVELOCITY;
                //printf("JUMP");
-       } else if (IsKeyDown(inputs[2]) && (d = sliding_wall(&player.rect))) {
+       } else if (IsKeyDown(inputs[4]) && (d = sliding_wall(&player.rect))) {
                player.velocity.y = JUMPVELOCITY * 1.5;
                player.velocity.x =   d * SPEED * 1.5;
                walljumpprogress = 1;
@@ -102,6 +102,10 @@ int spieler_bewegen(float delta) // should actually only change velocity, physic
                walljumpprogress = 0;
        };
 
+       if (IsKeyDown(inputs[5])) {
+               interact(&player.rect);
+       };
+
        
        //printf("direction * SPEED: %d; velocity.x: %d; int playervelocityx = player.velocity.x:%d\n", direction * SPEED, (player.velocity.x), playervelocityx);
        return 1;