Bounding boxes: origins

This commit is contained in:
2024-02-28 12:54:59 -08:00
parent b0f4106d51
commit d6db2f3e5f
7 changed files with 55 additions and 17 deletions

View File

@ -58,6 +58,9 @@ sys_color sys_pixel_get(sys_i32 x, sys_i32 y) {
}
void sys_print(char* str, sys_i32 x, sys_i32 y, sys_color col) {
x += sys_cam_dx;
y += sys_cam_dy;
sys_i32 x_orig = x;
for (sys_i32 i = 0;; i++) {
uint8_t c = str[i];
@ -135,6 +138,11 @@ void sys_oval_fill(
void sys_oval_draw_ext(
sys_i32 x0, sys_i32 y0, sys_i32 x1, sys_i32 y1, sys_color c, bool fill
) {
x0 += sys_cam_dx;
y0 += sys_cam_dy;
x1 += sys_cam_dx;
y1 += sys_cam_dy;
assert(sys_get_initialized());
if (x0 == x1 || y0 == y1) { return; }
@ -186,6 +194,11 @@ void sys_oval_draw_ext(
void sys_line_draw(
sys_i32 x0, sys_i32 y0, sys_i32 x1, sys_i32 y1, sys_color c
) {
x0 += sys_cam_dx;
y0 += sys_cam_dy;
x1 += sys_cam_dx;
y1 += sys_cam_dy;
assert(sys_get_initialized());
if (x0 == x1 || y0 == y1) { return; }
@ -254,6 +267,9 @@ void sys_sprite_draw_ext(
sys_i32 w, sys_i32 h,
bool flip_x, bool flip_y
) {
x += sys_cam_dx;
y += sys_cam_dy;
// map n to a specific entity on the spritesheet
// (this is necessary for w and h)
for (int sy = 0; sy < h; sy++) {
@ -283,6 +299,10 @@ void sys_map_draw(
sys_i32 tile_x, sys_i32 tile_y,
sys_i32 tile_w, sys_i32 tile_h
) {
// no need to do this, sys_sprite_draw does it
// sx += sys_cam_dx;
// sy += sys_cam_dy;
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;