diff --git a/demo1.cpp b/demo1.cpp index e62cc81..a1ee53b 100644 --- a/demo1.cpp +++ b/demo1.cpp @@ -11,7 +11,7 @@ */ // redefine some parameters -#define FPS 40 +#define FPS 60 #define GRAVITY_ACCELERATION (UNITS_PER_SQUARE * 3) #define PLAYER_JUMP_SPEED 700 #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}; #define withinMapReturn(what,whatElse)\ - int16_t index = (LEVEL_Y_RES - y - 1) * LEVEL_X_RES + x;\ - if (index > 0 && index < LEVEL_Y_RES * LEVEL_X_RES)\ + 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;\ return (what);\ - return (whatElse); + }\ + else\ + return (whatElse); Unit textureAt(int16_t x, int16_t y) {