From aff22299c8b86f1151155269e601544eb64ec749 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Tue, 22 Dec 2020 22:28:25 -0600 Subject: [PATCH] clean up with updated version of onyx --- src/main.onyx | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/main.onyx b/src/main.onyx index c709f32..e52ff8c 100644 --- a/src/main.onyx +++ b/src/main.onyx @@ -150,8 +150,8 @@ update :: proc (dt: f32) { if input.key_down(^input_state, Key.ArrowLeft) do renderer.trans_x += (500.0f / renderer.scale) * dt; if input.key_down(^input_state, Key.ArrowRight) do renderer.trans_x -= (500.0f / renderer.scale) * dt; - if input_state.mouse.wheel_ups > ~~0 do renderer.scale *= 1.125f; - if input_state.mouse.wheel_downs > ~~0 do renderer.scale /= 1.125f; + if input_state.mouse.wheel_ups > 0 do renderer.scale *= 1.125f; + if input_state.mouse.wheel_downs > 0 do renderer.scale /= 1.125f; if input_state.mouse.buttons_down[0] { renderer.trans_x += ~~input_state.mouse.dx / renderer.scale; @@ -171,14 +171,14 @@ update :: proc (dt: f32) { if d.can_move_x do d.pos.x += d.vel.x * dt; if d.can_move_y do d.pos.y += d.vel.y * dt; - if !d.can_move_x && !d.can_move_y do d.couldnt_move_count += ~~1; + if !d.can_move_x && !d.can_move_y do d.couldnt_move_count += 1; } } for ^tile: tilemap.tiles { - if tile.r < ~~255 do tile.r += ~~1; else do tile.r = ~~255; - if tile.g < ~~255 do tile.g += ~~1; else do tile.g = ~~255; - if tile.b < ~~255 do tile.b += ~~1; else do tile.b = ~~255; + if tile.r < 255 do tile.r += 1; else do tile.r = 255; + if tile.g < 255 do tile.g += 1; else do tile.g = 255; + if tile.b < 255 do tile.b += 1; else do tile.b = 255; } } @@ -265,10 +265,6 @@ main :: proc (args: [] cstr) { event.init(); input.init(^input_state); - Dude_Color_Table[0] = Color4f32.{ 1.0f, 0.2f, 0.2f, 1.0f }; - Dude_Color_Table[1] = Color4f32.{ 0.2f, 1.0f, 0.2f, 1.0f }; - Dude_Color_Table[2] = Color4f32.{ 0.2f, 0.2f, 1.0f, 1.0f }; - array.init(^dudes); for i: 0 .. 2000 { array.push(^dudes, dude_create_random()); @@ -280,8 +276,11 @@ main :: proc (args: [] cstr) { game_launch(); } - -Dude_Color_Table : [3] Color4f32; +Dude_Color_Table := Color4f32.[ + Color4f32.{ 1.0f, 0.2f, 0.2f, 1.0f }, + Color4f32.{ 0.2f, 1.0f, 0.2f, 1.0f }, + Color4f32.{ 0.2f, 0.2f, 1.0f, 1.0f }, +]; Entity :: struct { pos : V2f; @@ -296,7 +295,7 @@ Dude :: struct { can_move_x : bool = true; can_move_y : bool = true; - couldnt_move_count : u16 = ~~0; + couldnt_move_count : u16 = 0; } dude_create_random :: proc () -> Dude { @@ -310,15 +309,15 @@ dude_create_random :: proc () -> Dude { // I presume this is because entity counts as toward the number of needed elements, even though it shouldn't. can_move_x = false, can_move_y = false, - couldnt_move_count = ~~0, + couldnt_move_count = 0, }; } dude_update :: proc (use dude: ^Dude, dt: f32, other_dudes: ^QuadTree(Dude)) { - if random.between(0, 100) < 1 || couldnt_move_count >= ~~2 { + if random.between(0, 100) < 1 || couldnt_move_count >= 2 { vel.x = random.float(-300.0f, 300.0f); vel.y = random.float(-300.0f, 300.0f); - couldnt_move_count = ~~0; + couldnt_move_count = 0; } dude_try_move(dude, dt, other_dudes); @@ -400,9 +399,9 @@ Tilemap :: struct { } Tile :: struct { - r : u8 = ~~255; - g : u8 = ~~255; - b : u8 = ~~255; + r : u8 = 255; + g : u8 = 255; + b : u8 = 255; } tilemap_init :: proc (use tm: ^Tilemap, w := 10, h := 10) { -- 2.25.1