diff options
author | UnavailableDev <ggwildplay@gmail.com> | 2023-03-13 09:57:34 +0100 |
---|---|---|
committer | UnavailableDev <ggwildplay@gmail.com> | 2023-03-13 09:57:34 +0100 |
commit | 5c4bf7d451135cd3af3e51976251f01cbb6e6573 (patch) | |
tree | 82990aa7c7df22c0888543a87dbd05799217cc99 /src/engine/draw_screen.c | |
parent | bb2839a81d64e8644c57d83806ae41cc4cfad9dd (diff) |
camera, movement, collisions
Diffstat (limited to 'src/engine/draw_screen.c')
-rw-r--r-- | src/engine/draw_screen.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/engine/draw_screen.c b/src/engine/draw_screen.c index 0295241..c4f3389 100644 --- a/src/engine/draw_screen.c +++ b/src/engine/draw_screen.c @@ -3,20 +3,20 @@ uint8_t hh_world_to_tile(vec2 pos){ - FILE* level = fopen("../test/bin/test_map.bin", "rb"); /* open binary file */ + FILE* level = fopen("../test/bin/level1_test.bin", "rb"); /* open binary file */ if (!level) { /* check if file opened successfully */ fprintf(stderr, "Error: Failed to open file.\n"); return 0; } - int index = (pos.y + pos.x); + int index = ((pos.y/16)*40 + pos.x/16);//TODO: remove magic number(s) fseek(level, (index * sizeof(int)) + sizeof(int), SEEK_SET); - int* tile = (int*)malloc(sizeof(int)); - fread(tile, sizeof(int), 1, level); // read 1 tile from binary + int tile;// = (int*)malloc(sizeof(int)); + fread(&tile, sizeof(int), 1, level); // read 1 tile from binary fclose(level); - int val = *tile; - free(tile); - return val; + // int val = tile; + // free(tile); + return tile; } @@ -26,8 +26,8 @@ void hh_draw_screen(vec_cor viewport){ if (viewport.x == previousViewport.x && viewport.y == previousViewport.y) return; hh_ppu_update_aux((hh_s_ppu_loc_aux){ - .bg_shift_x = viewport.x*HH_PPU_SPRITE_WIDTH, - .bg_shift_y = viewport.y*HH_PPU_SPRITE_HEIGHT, + .bg_shift_x = viewport.x, + .bg_shift_y = viewport.y, .fg_fetch = 0, .sysreset = 0, }); |