From 423c99862f5057b13bd2f8cb277fb04d7c6222f3 Mon Sep 17 00:00:00 2001 From: schneefux Date: Mon, 18 Nov 2013 16:20:35 +0100 Subject: improved error feedback --- engine.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'engine.c') 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 +*/ -- cgit v1.3.1