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,10 +950,13 @@ 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)\
int16_t index = (LEVEL_Y_RES - y - 1) * LEVEL_X_RES + x;\ if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES)\
if (index > 0 && index < LEVEL_Y_RES * LEVEL_X_RES)\ {\
int16_t index = (LEVEL_Y_RES - y - 1) * LEVEL_X_RES + x;\
return (what);\ return (what);\
return (whatElse); }\
else\
return (whatElse);
Unit textureAt(int16_t x, int16_t y) Unit textureAt(int16_t x, int16_t y)
{ {