#define LEVELS 3
struct character *spielersetup(void);
+int next_level(void);
int bühnezeichnen(void); //i dont think stage works here but it seems better than window
int spielerzeichnen(void);
int on_floor(struct Rectangle *rect);
int in_floor(struct Rectangle *rect);
+int level_cleanup(void);
+int player_cleanup(void);
+
//structures
struct character {
struct Rectangle rect;
};
if (frozen) { //currently in dialogue
+ printf("d");
drawdialogue();
if (IsKeyPressed(ADVANCEKEY)) {
if (++current_dialogue == stages[level].dialogue_count) { //dialogue over
int drawdialogue(void)
{
- struct dialogue *dlg = &(stages[level].dialogues[current_dialogue]);
+ struct dialogue dlg = stages[level].dialogues[current_dialogue];
+ printf("g"); //grab dialogue
DrawRectangle(0,DLGY,640,DLGHEIGHT,RAYWHITE);
- drawcharname(dlg->charaname,dlg->characolour);
- drawcharimage(dlg->image);
- drawdialogueline(dlg->line);
-
+ printf("r"); //rectange
+ //drawcharname(dlg.charaname,dlg.characolour);
+ DrawText(dlg.charaname,DLGPADDING,DLGY + DLGPADDING,CHARANAMETEXTSIZE,dlg.characolour);
+ printf("n"); //name THIS IS WHERE IT CRASHES
+ drawcharimage(dlg.image);
+ printf("i"); //image THIS CRASHES TOO?? ig... the issue is with dlg->???? but specifically when the function uses it... AND SPECIFICALLY WHEN IT'S A STRING
+ // so... our mystery bug has these traits:
+ //only happens on the second level played (NOT only on level == 1. If you manually set level to 1 at the start it crashes on entering stages[2] instead.
+ //happens when a property of dlg is accessed in one of functions and used to do smth (so it doesn't crash if it's just entered into the function) (although maybe that's bc of compiler??)
+ //it also happens if DrawText (and presumably the other ones too) are attempted inside of drawdialogue().
+ //the property must be a string.
+ drawdialogueline(dlg.line);
+ printf("l"); //line
return 1;
};
return 1;
}
+static Texture2D txtr;
+
int drawcharimage(char *filename)
{
static char *lastfilename = "";
- static Texture2D txtr;
if (lastfilename != filename) {
+ UnloadTexture(txtr);
Image img = LoadImage(filename);
ImageResize(&img, CHARADISPLAYWIDTH - DLGPADDING * 2, CHARADISPLAYWIDTH - DLGPADDING * 2);
txtr = LoadTextureFromImage(img);
+ UnloadImage(img);
lastfilename = filename;
}
DrawTexture(txtr,DLGPADDING,DLGY + CHARANAMETEXTSIZE + DLGPADDING * 3,WHITE);
{
DrawText(line, CHARADISPLAYWIDTH + DLGPADDING, DLGY + DLGPADDING * 2 ,20, BLACK); //add text wrapping later
};
+
+int cleanup_level(void)
+{
+ UnloadTexture(txtr);
+ return 1;
+}
struct character *spielersetup(void)
{
- front_single = LoadTextureFromImage(LoadImage("aichan-front.png"));
+ Image img = LoadImage("aichan-front.png");
+ front_single = LoadTextureFromImage(img);
+ UnloadImage(img);
front_sheet = LoadImage("aichan-front-sheet.png");
return 1;
}
-
+int player_cleanup(void)
+{
+ UnloadTexture(front_single);
+ UnloadImage(front_sheet);
+ return 1;
+}