From 31f7895bf376cf31cb2e7c5fbc5a81446ef417ea Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sat, 28 Dec 2024 19:56:07 +0000 Subject: [PATCH] Support new map and tileset --- app/main.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/main.c b/app/main.c index ae8e8c3..4e2551a 100644 --- a/app/main.c +++ b/app/main.c @@ -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;