diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2013-11-18 16:20:35 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2013-11-18 16:20:35 +0100 |
| commit | 423c99862f5057b13bd2f8cb277fb04d7c6222f3 (patch) | |
| tree | 0602e1ea1be462f50eeb70b79f2d6563acd06cec | |
| parent | 0d9a7c969269fc4d0b94b732136bff70903116ba (diff) | |
| download | fx-maze-423c99862f5057b13bd2f8cb277fb04d7c6222f3.tar.gz fx-maze-423c99862f5057b13bd2f8cb277fb04d7c6222f3.zip | |
improved error feedback
| -rw-r--r-- | engine.c | 14 | ||||
| -rw-r--r-- | fxmaze.c | 2 | ||||
| -rw-r--r-- | global.c | 6 | ||||
| -rw-r--r-- | global.h | 4 | ||||
| -rw-r--r-- | mapgen.c | 2 |
5 files changed, 16 insertions, 12 deletions
@@ -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 +*/
@@ -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
@@ -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);
}
@@ -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
@@ -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;
|
