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);
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;
int dialogue_count;
struct platform *dangers;
int danger_count;
+ struct object *objects;
+ int object_count;
};
struct spritesheet {
extern int level;
extern int frozen;
+extern int objects_interacted[];
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);
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...
}
}
}
- };
+ } 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;
}
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);
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;
+};
#define STAGECOUNT 7
-#define DIALOGUECOUNT 14
+#define DIALOGUECOUNT 18
#define PLATFORMCOUNT 23
#define DANGERCOUNT 12
+#define OBJECTCOUNT 1
#include "game.h"
#include <stddef.h>
{"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}
};
{{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}
+};
#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)
{
#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];
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;
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;