diff options
author | ubq323 <ubq323@ubq323.website> | 2024-04-13 15:18:46 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-04-13 15:18:46 +0100 |
commit | 8d562c375e5b8c75dd5dd3a89fb55d4f26ef1934 (patch) | |
tree | 06141daebc238eb49673fa325361b5ebf11096ab /client | |
parent | 7608e2967954104771b06612e4e6c21ca7811c9f (diff) |
better messages slightly
Diffstat (limited to 'client')
-rw-r--r-- | client/main.ha | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/client/main.ha b/client/main.ha index 28d6694..e720b65 100644 --- a/client/main.ha +++ b/client/main.ha @@ -27,7 +27,7 @@ export fn main() void = { let offs: []pos = []; for (let x = -1; x < 3; x+=1) for (let y = -1; y < 3; y+=1) - append(offs, (x*CHUNKSIZE,y*CHUNKSIZE)); + append(offs, (1024+x*CHUNKSIZE,y*CHUNKSIZE)); let pictures: []drawing::picture = alloc([],NCHUNKS); let picture_surfaces: []*sdl2::SDL_Surface = alloc([], NCHUNKS); @@ -171,11 +171,11 @@ fn do_movement(pos: *pos) void = { pos.1 += dy * speed; }; -fn is_picture_visible(camera_pos: pos, pic: *drawing::picture) bool = { +fn is_picture_visible(camera_pos: pos, pic_pos: pos) bool = { const s_min: pos = camera_pos; const s_max: pos = (camera_pos.0 + WIN_W, camera_pos.1 + WIN_H); - const p_min: pos = pic.world_pos; - const p_max: pos = (pic.world_pos.0 + pic.w: i32, pic.world_pos.1 + pic.h: i32); + const p_min: pos = pic_pos; + const p_max: pos = (pic_pos.0 + CHUNKSIZE: i32, pic_pos.1 + CHUNKSIZE: i32); return (s_min.0 <= p_max.0 && s_max.0 >= p_min.0) && (s_min.1 <= p_max.1 && s_max.1 >= p_min.1); }; @@ -188,9 +188,13 @@ fn find_picture_for_chunkdata(camera_pos: pos, world_pos: pos, pictures: []drawi for (const pic &.. pictures) { if (pic.world_pos.0 == world_pos.0 && pic.world_pos.1 == world_pos.1) { + fmt::printfln("found already pic at {},{}",pic.world_pos.0, pic.world_pos.1)!; return pic; }; - if (invisible == null && !is_picture_visible(camera_pos, pic)) invisible = pic; + if (invisible == null && !is_picture_visible(camera_pos, pic.world_pos)) { + fmt::printfln("can recycle pic at {},{}",pic.world_pos.0,pic.world_pos.1)!; + invisible = pic; + }; }; match (invisible) { |