]> _ Git - aichan-platformer.git/commitdiff
fun collectable coins with the most obnoxious sound possible!!
authorparking_turkeys <roya1060wien@gmail.com>
Sat, 25 Jul 2026 00:40:43 +0000 (20:40 -0400)
committerparking_turkeys <roya1060wien@gmail.com>
Sat, 25 Jul 2026 00:40:43 +0000 (20:40 -0400)
coin.wav [new file with mode: 0644]
endscreen.c
game.h
level.c
level_data.h

diff --git a/coin.wav b/coin.wav
new file mode 100644 (file)
index 0000000..b64d5dc
Binary files /dev/null and b/coin.wav differ
index 0291b04..27694da 100644 (file)
@@ -2,12 +2,15 @@
 #include "game.h"
 #include <stdio.h>
 
+
+extern int collected_coins[];
 struct time {
        int min;
        int sec;
 };
 
 static struct time *formattime(int seconds);
+static int getcoincount(int *collected, int coin_count);
 
 int drawendscreen(int seconds)
 {
@@ -18,6 +21,7 @@ int drawendscreen(int seconds)
        //printf("time to draw the gametime");
        DrawText(TextFormat("Time:  %02d:%02d",gametime->min,gametime->sec),80,240,20, GRAY);
        DrawText(TextFormat("Deaths:  %d",deaths),240,240,20,GRAY);
+       DrawText(TextFormat("Coins: %d/%d",getcoincount(collected_coins,COIN_COUNT), COIN_COUNT),400,240,20,GRAY);
        return 1;
 };
 
@@ -28,3 +32,13 @@ static struct time *formattime(int s)
        t->sec = s - t->min * 60; //fairly simple :p
        return t;
 }
+
+static int getcoincount(int *c, int count)
+{
+       int r = 0;
+       for (int i = 0; i < count; i++) {
+               r += c[i];
+       };
+       return r;
+};
+               
diff --git a/game.h b/game.h
index 9a0f960..d3498e5 100644 (file)
--- a/game.h
+++ b/game.h
@@ -77,6 +77,12 @@ struct object {
        int index;
 };
 
+struct coingroup {
+       Vector2 position;
+       int coin_count;
+       int *collected;
+};
+
 struct stage {
        char *name;
        struct platform *platforms;
@@ -87,6 +93,8 @@ struct stage {
        int danger_count;
        struct object *objects;
        int object_count;
+       struct coingroup *coingroups;
+       int coingroup_count;
 };
 
 struct spritesheet {
@@ -104,3 +112,4 @@ extern int objects_interacted[];
 extern int mode;
 extern int inputs[];
 extern int deaths;
+extern int COIN_COUNT;
diff --git a/level.c b/level.c
index 246062b..0d91901 100644 (file)
--- a/level.c
+++ b/level.c
 #define CHARANAMETEXTSIZE 30
 #define DLGTEXTWIDTH SCREENWIDTH - DLGPADDING * 2 - CHARADISPLAYWIDTH
 
+#define COINPADDING 5
+#define COINWIDTH 10
+
+int COIN_COUNT = COINCOUNT;
+
 
 int current_dialogue = 0;
 
@@ -23,6 +28,8 @@ int drawcharimage(char *filename);
 int drawdialogueline(char *line);
 
 int drawobject(struct object *object);
+int drawcoingroup(struct coingroup *coingroup);
+int collectcoin(struct coingroup *group, int index);
 
 int objects_interacted[OBJECTCOUNT] = {0};
 
@@ -42,6 +49,9 @@ int bühnezeichnen(void)
        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);
+       };
 
        if (frozen == 1) { //currently in dialogue at beginning of stage
                if (stages[level].dialogues == NULL) {
@@ -130,11 +140,22 @@ int sliding_wall(struct Rectangle *rect)
 };
 
 int is_killed(struct Rectangle *rect) {
-       for (int i = 0; i < stages[level].danger_count; i++) {
-               if (CheckCollisionRecs(*rect, stages[level].dangers[i].rect)) {
+       struct stage *s = &stages[level];
+       for (int i = 0; i < s->danger_count; i++) {
+               if (CheckCollisionRecs(*rect, s->dangers[i].rect)) {
                        return 1;
                };
        };
+
+       //haha im just going to add checkign coins into here loll
+       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 * (COINPADDING + COINWIDTH)), cg->position.y, COINWIDTH - 2, COINWIDTH}))) { 
+                               collectcoin(cg, n);
+                       };
+               };
+       };
        return 0;
 };
 
@@ -196,9 +217,15 @@ int drawdialogueline(char *l)
        //DrawText(l, CHARADISPLAYWIDTH + DLGPADDING, DLGY + DLGPADDING * 2 ,20, BLACK); //add text wrapping later
 };
 
+Texture2D coin_txtr;
+Sound coin_sound;
+
 int cleanup_level(void)
 {
        UnloadTexture(txtr);
+       UnloadTexture(coin_txtr);
+       UnloadSound(coin_sound);
+       CloseAudioDevice();
        return 1;
 }
 
@@ -223,3 +250,37 @@ int interact(Rectangle *r)
        }
        return 1;
 };
+
+int drawcoingroup(struct coingroup *cg)
+{
+       static int coin_loaded = 0;
+       if (!coin_loaded) {
+               Image img = LoadImage("img/coin_10_10.png");
+               coin_txtr = LoadTextureFromImage(img);
+               UnloadImage(img);
+               coin_loaded = 1;
+       };
+       for (int i = 0; i < cg->coin_count; i++) {
+               if (cg->collected[i] == 0) {
+                       //draw the coin :3
+                       DrawTexture(coin_txtr, cg->position.x + i * (COINWIDTH + COINPADDING), cg->position.y, WHITE);
+               };
+       };
+};
+
+
+int collectcoin(struct coingroup *cg, int i)
+{
+       static int sound_loaded = 0;
+       if (!sound_loaded) {
+               InitAudioDevice();
+               coin_sound = LoadSound("coin.wav"); // the sound is taken from an UTAU i recorded (i wanted to make sure i had the rights to it, and, well, it's my voice :))
+               if (IsSoundValid(coin_sound)) {
+                       sound_loaded = 1;
+               };
+       };
+       if (sound_loaded) {
+               PlaySound(coin_sound);
+       };
+       cg->collected[i] = 1;
+};
index 1e1af65..acbb5ad 100644 (file)
@@ -3,11 +3,13 @@
 #define PLATFORMCOUNT 83
 #define DANGERCOUNT 34
 #define OBJECTCOUNT 5
+#define COINCOUNT 32
+#define COINGROUPCOUNT 1
 
 #include "game.h"
 #include <stddef.h>
 
-//icons are 40x40
+//icons are 130x130
 
 struct dialogue dialogues[DIALOGUECOUNT] = {
        {"Hello!! [press 'H' to advance dialogue]", "Ai-chan", "dialogue-img/aichan-smile.png", GREEN},
@@ -62,7 +64,7 @@ struct dialogue dialogues[DIALOGUECOUNT] = {
        {"This is probably some scheme by those two!!", "Ai-chan", "dialogue-img/aichan-angry.png", ORANGE},
        {"no actually it's just too annoying to add dialogue that's different based on other things", "CONTEXT", "dialogue-img/context.png", BLACK},
 
-       {"Hello! How are you, Ai-chan?", "Seele", "dialogue-img/seele.png", DARKBLUE},
+       {"Hello! How are you, Ai-chan?", "Seele", "dialogue-img/aichan-default.png", DARKBLUE},
        {"... LITERALLY TERRIBLE BECAUSE OF YOUR FAKE IDOL FRIENDS >:(", "Ai-chan", "dialogue-img/aichan-angry", GREEN},
        {"It cannot be this serious.", "Context", "dialogue-img/context.png", BLACK},
        {"This cannot be this serious, can you just get it over with soon??", "Seele", "dialogue-img/seele_b.png", RED},
@@ -249,6 +251,12 @@ struct platform danger[DANGERCOUNT] = {
 
 };
 
+int collected_coins[COINCOUNT] = {0};
+
+struct coingroup coins[COINGROUPCOUNT] = {
+       {{80,305},32,collected_coins}
+};
+
 struct object objects[OBJECTCOUNT] = {
        {{440,418,15,22}, "Sin Mal", "img/sin_15_22.png" ,dialogues+13,4, 0},
        {{60,38,15,22}, "Herrscher of Sentience", "img/senti_15_22.png", dialogues+21,7, 1},
@@ -258,17 +266,17 @@ struct object objects[OBJECTCOUNT] = {
 };
 
 struct stage stages[STAGECOUNT] = {
-       {"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},
-       {"(level)", platforms+23,11,NULL,0,danger+12,5,NULL,0},
-       {"Ominous", platforms+34,14,dialogues+17,2,danger+17,4,NULL,0},
-       {"Senti", platforms+48,13,dialogues+19,2,danger+21,9,objects+1,1},
-       {"Seele", platforms+61,12,dialogues+28,1,danger+30,1,objects+2,3},
-       {"(level)", platforms+73,7,NULL,0,danger+31,2,NULL,0},
-       {"Last level", platforms+80,3,dialogues+39,2,danger+33,1,NULL,0}
+       {"Movement", platforms, 1, dialogues, 7, danger, 0,NULL,0,coins,1},
+       {"Jumping", platforms+1, 2, dialogues+7, 1, danger, 0,NULL,0,NULL,0},
+       {"Danger", platforms+3, 1, dialogues+8, 1, danger, 4,NULL,0,NULL,0},
+       {"(level)", platforms+4, 5, NULL,0,danger+4,1,NULL,0,NULL,0},
+       {"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},
+       {"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},
+       {"Senti", platforms+48,13,dialogues+19,2,danger+21,9,objects+1,1,NULL,0},
+       {"Seele", platforms+61,12,dialogues+28,1,danger+30,1,objects+2,3,NULL,0},
+       {"(level)", platforms+73,7,NULL,0,danger+31,2,NULL,0,NULL,0},
+       {"Last level", platforms+80,3,dialogues+39,2,danger+33,1,NULL,0,NULL,0}
 };