Fix demo1 OOB

This commit is contained in:
Miloslav Číž 2018-09-16 14:44:43 +02:00
parent bb26598418
commit 7c26888a16

View file

@ -11,7 +11,7 @@
*/ */
// redefine some parameters // redefine some parameters
#define FPS 40 #define FPS 60
#define GRAVITY_ACCELERATION (UNITS_PER_SQUARE * 3) #define GRAVITY_ACCELERATION (UNITS_PER_SQUARE * 3)
#define PLAYER_JUMP_SPEED 700 #define PLAYER_JUMP_SPEED 700
#define CAMERA_COLL_HEIGHT_BELOW ((3 * UNITS_PER_SQUARE) / 2) #define CAMERA_COLL_HEIGHT_BELOW ((3 * UNITS_PER_SQUARE) / 2)
@ -950,9 +950,12 @@ const unsigned char spriteTorch2[] =
const unsigned char *textures[] = {texture1, texture2, texture3, texture4}; const unsigned char *textures[] = {texture1, texture2, texture3, texture4};
#define withinMapReturn(what,whatElse)\ #define withinMapReturn(what,whatElse)\
if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES)\
{\
int16_t index = (LEVEL_Y_RES - y - 1) * LEVEL_X_RES + x;\ int16_t index = (LEVEL_Y_RES - y - 1) * LEVEL_X_RES + x;\
if (index > 0 && index < LEVEL_Y_RES * LEVEL_X_RES)\
return (what);\ return (what);\
}\
else\
return (whatElse); return (whatElse);
Unit textureAt(int16_t x, int16_t y) Unit textureAt(int16_t x, int16_t y)