64 Commits

Author SHA1 Message Date
5eff48b449 Use object bounding box for y sorting 2025-01-04 16:14:38 +00:00
48ae6b7873 Load object bounding box from objectsprites XML 2025-01-04 16:14:38 +00:00
3f8ac4f890 Add a bounding box to dynentity_t 2025-01-04 16:14:35 +00:00
080de0da3c Use doubles instead of ints for y sorting 2025-01-04 16:13:49 +00:00
765e2c32c8 Implement drawlist updating for decreasing y 2025-01-04 16:13:47 +00:00
f3c9d6ac30 Implement drawlist updating for increasing y 2025-01-04 13:03:15 +00:00
9325563991 Draw entities using drawlist 2025-01-04 10:32:41 +00:00
56dbf9dbb4 Construct drawlist at end of game_init() 2025-01-04 10:32:13 +00:00
8763c437b3 Add tag and prev, next pointers to entity structs 2025-01-04 10:32:13 +00:00
6c248b0707 Track and display maxima in performance monitor 2025-01-04 10:32:13 +00:00
51cd623af9 Rearrange and rename helper functions 2025-01-04 05:57:25 +00:00
6bd85d9ebf Rename entity_t and obj_t to dynentity_t and objentity_t 2025-01-04 04:51:27 +00:00
77725a5ce4 Round coordinates in collision detection
This fixes an issue where the player could get stuck to an edge when
being aligned to the pixel grid due to the rounded coordinate being
outside an invalid tile but the truncated position being inside.  Also
we should be doing it anyway.
2025-01-04 02:13:40 +00:00
6d01f8cc3f Tweak performance message to include frame interval 2025-01-04 02:12:43 +00:00
a8e2c8d89a Rename game_evthandle() to game_evt() 2025-01-02 18:52:15 +00:00
8dbdea6ac4 Fix some memory leaks 2025-01-02 17:53:40 +00:00
2c8d01df49 Fix UB in tileat() 2025-01-02 17:16:05 +00:00
61c0e17fd8 Remove ASAN from sanitizers config
SDL2 seems to use some unintialized memory in SDL_Init() so ASAN just
kills the program right away if it's enabled (sad).  UBSAN is still
very useful in its own right, though, so makes sense to have an option
to enable only that.
2025-01-02 17:16:01 +00:00
3952d93bb0 Add CMake option to enable/disable performance monitoring 2025-01-02 17:13:35 +00:00
c1dd9cd33a Remove frame blinker
Not really needed any more
2025-01-02 16:55:06 +00:00
65a4b08f34 Use vsync instead of delay-based synchronization
Also changed the game_update() interface to take dt in seconds as a
double (rather than milliseconds as an unsigned integer) as we're now
computing the refresh interval as a double anyway (by querying the
display mode).  To my eye (and on my machine), all chunkiness is now
gone; the game feels very smooth.
2025-01-02 16:54:01 +00:00
427cdef867 Add frame blinker back in 2025-01-02 16:37:43 +00:00
cda484c9ab Wait for remaining time in interval rather than busy looping 2025-01-02 16:20:00 +00:00
178d6a23d3 Reduce performance analysis frequency 2025-01-02 15:50:15 +00:00
e7e1b40dd9 Take ceiling of endx and endy in mapdraw()
This fixes an issue where tiles around the right and bottom edges
would not be drawn when vpos was just under a tile boundary.  I'm
guessing it wasn't noticable before fixing the frame rate as the buggy
frames were only on-screen for a hilariously short amount of time.
2025-01-02 15:43:31 +00:00
bbaf58869a Measure game code performance in engine 2025-01-02 15:35:57 +00:00
d9981d8d61 Rename app/ directory to game/ 2025-01-02 14:21:12 +00:00
2dd55b5533 Restructure game to use engine 2025-01-02 14:18:37 +00:00
b14d2f292a Create basic engine 2025-01-02 14:16:35 +00:00
c02068f1ba Move player entity into static 2025-01-02 00:18:25 +00:00
f196440112 Remove unused tests directory 2025-01-02 00:16:58 +00:00
dc53a2d8de Snap view and entity positions to grid when not in motion
This fixes some chunky movement badness.
2025-01-01 21:31:47 +00:00
e8eba7e90c Add blinking box to indicate frames 2025-01-01 21:06:08 +00:00
e48e566dd2 Round coordinates when drawing 2025-01-01 17:24:53 +00:00
cbb4b7884c Add support for map objects 2025-01-01 16:50:51 +00:00
12751a49f8 Store asset dir path in static var 2025-01-01 13:38:11 +00:00
dab37ddeff Update impassable tiles 2024-12-31 20:28:47 +00:00
8397666cb2 Write script to extract frames from a spritesheet 2024-12-31 20:07:24 +00:00
0aab456433 Load and draw additional layers 2024-12-31 13:55:34 +00:00
8de374bcfb Extract map logic into functions 2024-12-31 13:15:57 +00:00
b39189b6d1 Create entity_t struct and define entityupdate() and entitydraw() 2024-12-31 13:01:48 +00:00
e7a19b7d91 Fix camera when at edge of map 2024-12-29 18:49:04 +00:00
31f7895bf3 Support new map and tileset 2024-12-28 19:56:07 +00:00
c24cd75360 Implement terrain collisions 2024-12-28 18:57:29 +00:00
f17530af4a Use walking animation 2024-12-28 17:22:48 +00:00
c5daa136c1 Use directional sprites for player 2024-12-28 14:27:13 +00:00
10bb223bdd Move view to keep player on-screen 2024-12-28 14:01:10 +00:00
e5752a5fe7 Draw player centered on position 2024-12-28 14:01:10 +00:00
6ca053f126 Use game coordinates for view and player positions 2024-12-28 13:35:13 +00:00
fad49a7d15 Handle player motion (arrow keys) 2024-12-28 13:35:13 +00:00