summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2013-11-18 16:20:35 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2013-11-18 16:20:35 +0100
commit423c99862f5057b13bd2f8cb277fb04d7c6222f3 (patch)
tree0602e1ea1be462f50eeb70b79f2d6563acd06cec
parent0d9a7c969269fc4d0b94b732136bff70903116ba (diff)
downloadfx-maze-423c99862f5057b13bd2f8cb277fb04d7c6222f3.tar.gz
fx-maze-423c99862f5057b13bd2f8cb277fb04d7c6222f3.zip
improved error feedback
-rw-r--r--engine.c14
-rw-r--r--fxmaze.c2
-rw-r--r--global.c6
-rw-r--r--global.h4
-rw-r--r--mapgen.c2
5 files changed, 16 insertions, 12 deletions
diff --git a/engine.c b/engine.c
index 8391fe8..5db84c4 100644
--- a/engine.c
+++ b/engine.c
@@ -91,7 +91,9 @@ static void pshoot()
xadd = ((sprites[c].x - x) / Abs(y - sprites[c].y));
yadd = sgn(sprites[c].y - y);
}
-
+
+ // the enemy must be between dirplayer_left and right, that means visible on the screen
+
direnemy = xadd / yadd;
dirplayer_left = (player.dirX - player.planeX) / (player.dirY - player.planeY);
@@ -113,7 +115,7 @@ static void pshoot()
{
sprites[c] = sprites[spritecnt];
sprites = (struct st_sprite *) realloc(sprites, spritecnt-- * sizeof(struct st_sprite));
- if(sprites == NULL)error();
+ if(sprites == NULL)error("Memory; delete enemy after hit");
}
// we hit an enemy, go back to the game
return;
@@ -215,7 +217,7 @@ void move()
// delete it
sprites[c] = sprites[spritecnt];
sprites = (struct st_sprite *) realloc(sprites, spritecnt-- * sizeof(struct st_sprite));
- if(sprites == NULL)error();
+ if(sprites == NULL)error("Memory; delete a pack");
output = 2;
// got it
@@ -296,9 +298,9 @@ void cast()
int foundsprite = FALSE, spritehere;
spriteDist = (float *) calloc(spritecnt, sizeof(float));
- if(spriteDist == NULL)error();
+ if(spriteDist == NULL)error("Memory; locate spriteDist");
spriteOrder = (int *) calloc(spritecnt, sizeof(int));
- if(spriteOrder == NULL)error();
+ if(spriteOrder == NULL)error("Memory; locate spriteOrder");
for(x = 0; x < spritecnt; x++)
{
@@ -917,4 +919,4 @@ void cast()
free(spriteDist);
}
}
-*/ \ No newline at end of file
+*/
diff --git a/fxmaze.c b/fxmaze.c
index 3f9811d..15fb95a 100644
--- a/fxmaze.c
+++ b/fxmaze.c
@@ -161,7 +161,7 @@ int AddIn_main(int isAppli, unsigned short OptionNum)
{
sprites = (struct st_sprite *) malloc(ENEMYCNT * sizeof(struct st_sprite));
// these are debug checks; there should be enough memory
- if(sprites == NULL)error();
+ if(sprites == NULL)error("Memory; locate enemies");
}
// spritecnt holds the number of all sprites; enemies, items and whatever else will come
diff --git a/global.c b/global.c
index 083f7d8..10dd7db 100644
--- a/global.c
+++ b/global.c
@@ -99,10 +99,12 @@ uint solids[MAPSIZE][MAPSIZE] = {0}; // here you can check whether you can walk
// nice idea would be a hidden wall you can walk through to access a secret room... hmmm
// something happened that should not happen
-void error(void)
+void error(char * msg)
{
+ int k;
+
clear_vram();
PrintMini(1,1, "ERROR!");
+ PrintMini(1, 10, msg);
display_vram();
- while(1);
}
diff --git a/global.h b/global.h
index 185f227..699e52d 100644
--- a/global.h
+++ b/global.h
@@ -81,9 +81,9 @@ extern struct st_sprite{float x, y; int type, effect; struct{int *ptr; uint widt
extern uint spritecnt;
-void error(void);
+void error(char *);
extern const char *status;
extern unsigned int statustimer;
-#endif \ No newline at end of file
+#endif
diff --git a/mapgen.c b/mapgen.c
index a7e7072..df8d6ab 100644
--- a/mapgen.c
+++ b/mapgen.c
@@ -375,7 +375,7 @@ start:
if(cntwall(curx, cury) >= 3)
{
sprites = (struct st_sprite *) realloc(sprites, (spritecnt + 1) * sizeof(struct st_sprite));
- if(sprites == NULL)error();
+ if(sprites == NULL)error("Memory; create sprites");
sprites[spritecnt].x = curx + 0.5;
sprites[spritecnt].y = cury + 0.5;
sprites[spritecnt].texture.ptr = &pack;