Support new map and tileset

This commit is contained in:
Camden Dixie O'Brien 2024-12-28 19:56:07 +00:00
parent c24cd75360
commit 31f7895bf3

View File

@ -14,30 +14,30 @@
#define SCALE 4
#define TILESIZE 32
#define VIEWWIDTH (8 * TILESIZE)
#define VIEWHEIGHT (6 * TILESIZE)
#define TILESIZE 16
#define VIEWWIDTH (16 * TILESIZE)
#define VIEWHEIGHT (12 * TILESIZE)
#define MAX_PATH_LEN 128
#define MAP_ASSET "/map.tmx"
#define MAPWIDTH 112
#define MAPHEIGHT 112
#define MAPSHIFTX 48
#define MAPSHIFTY 48
#define MAPWIDTH 64
#define MAPHEIGHT 64
#define MAPSHIFTX 32
#define MAPSHIFTY 32
#define TSASSET "/tileset.png"
#define TSCOLS 56
#define TSASSET "/overworld.png"
#define TSCOLS 40
#define PIDLE_ASSET "/player/idle.png"
#define PWALK_ASSET "/player/walk.png"
#define PWIDTH 48
#define PHEIGHT 64
#define PANIMLEN 8
#define PFBWIDTH 12
#define PFBHEIGHT 6
#define PFBOFFX -6
#define PFBOFFY 6
#define PFBWIDTH 20
#define PFBHEIGHT 16
#define PFBOFFX -10
#define PFBOFFY 2
#define WALKSPEED 72 // pixels per second
@ -67,8 +67,8 @@ static SDL_Renderer *renderer;
static unsigned map[MAPWIDTH][MAPHEIGHT];
static SDL_Texture *tstex, *pidle, *pwalk, *ptex;
static input_state_t input;
static dvec_t vpos = { 512, 0 };
static const unsigned passable[] = { 118, 178 };
static dvec_t vpos = { -128, -96 };
static const unsigned impassable[] = { 284 };
static inline double mag(dvec_t v)
{
@ -88,11 +88,11 @@ static inline unsigned tileat(double x, double y)
static inline bool tilepassable(int x, int y)
{
const unsigned id = tileat(x, y);
for (unsigned i = 0; i < NELEMS(passable); ++i) {
if (passable[i] == id)
return true;
for (unsigned i = 0; i < NELEMS(impassable); ++i) {
if (impassable[i] == id)
return false;
}
return false;
return true;
}
int main(int argc, char *argv[])
@ -207,7 +207,7 @@ int main(int argc, char *argv[])
// Initialize player
SDL_Rect psrc = { .y = 0, .w = PWIDTH, .h = PHEIGHT };
SDL_Rect pdest = { .w = SCALE * PWIDTH, .h = SCALE * PHEIGHT };
dvec_t pvel = { 0, 0 }, ppos = { 640, 96 };
dvec_t pvel = { 0, 0 }, ppos = { 0, 0 };
sprite_dir_t pdir = SPRITE_DIR_DOWN;
ptex = pidle;