Map works!
This commit is contained in:
@ -267,6 +267,25 @@ void sys_sprite_draw_ext(
|
||||
}
|
||||
}
|
||||
|
||||
void sys_map_draw(
|
||||
sys_map map,
|
||||
sys_spritesheet spritesheet,
|
||||
sys_i32 sx, sys_i32 sy,
|
||||
sys_i32 tile_x, sys_i32 tile_y,
|
||||
sys_i32 tile_w, sys_i32 tile_h
|
||||
) {
|
||||
for (sys_i32 ty = 0; ty < tile_h; ty++) {
|
||||
for (sys_i32 tx = 0; tx < tile_w; tx++) {
|
||||
sys_i32 real_tx = tx + tile_x;
|
||||
sys_i32 real_ty = ty + tile_y;
|
||||
if (real_tx < 0 || real_tx >= map.width) { continue; }
|
||||
if (real_ty < 0 || real_ty >= map.height) { continue; }
|
||||
sys_maptile tile = map.tiles[real_tx + map.width * real_ty];
|
||||
sys_sprite_draw(spritesheet, tile, sx + tx * 8, sy + ty * 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// == internal primitives ==
|
||||
void sys_pixel_internal_set(sys_i32 x, sys_i32 y, sys_color c) {
|
||||
sys_color realc = sys_dpal[c];
|
||||
|
@ -167,5 +167,16 @@ void sys_sprite_draw_ext(
|
||||
// TODO: SSPR
|
||||
// TODO: FILLP?
|
||||
|
||||
void sys_map_draw(
|
||||
// NOTE: not the same order of args
|
||||
// as on pico 8
|
||||
// but: more consistent!
|
||||
sys_map map,
|
||||
sys_spritesheet spritesheet,
|
||||
sys_i32 sx, sys_i32 sy,
|
||||
sys_i32 tile_x, sys_i32 tile_y,
|
||||
sys_i32 tile_w, sys_i32 tile_h
|
||||
// TODO: Layers?
|
||||
);
|
||||
|
||||
#endif // CROCPARTY_SYS_GRAPHICS_H
|
||||
|
Reference in New Issue
Block a user