From: Brendan Hansen Date: Wed, 30 Dec 2020 17:31:06 +0000 (-0600) Subject: working on this again; small clean ups X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=2ba23832f7bfbd419f259c6d1c251c73911071ce;p=onyx-game.git working on this again; small clean ups --- diff --git a/src/font.onyx b/src/font.onyx index ea4c167..be920c6 100644 --- a/src/font.onyx +++ b/src/font.onyx @@ -26,7 +26,7 @@ binary_reader_create :: proc (data: [] u8, initial_pos := 0) -> BinaryReader { } #private_file seek :: proc (use br: ^BinaryReader, new_pos: u32) -> u32 { - old_pos :: pos; + old_pos := pos; pos = new_pos; return old_pos; } diff --git a/src/gfx/quad_renderer.onyx b/src/gfx/quad_renderer.onyx index 7f1ea79..b653d1d 100644 --- a/src/gfx/quad_renderer.onyx +++ b/src/gfx/quad_renderer.onyx @@ -26,11 +26,11 @@ QuadRenderer :: struct { Color4f32 :: struct { r: f32; g: f32; b: f32; a: f32; } Quad :: struct { - pos : V2f = V2f.{ 0f, 0f }; - size : V2f = V2f.{ 0f, 0f }; + pos : V2f = V2f.{}; + size : V2f = V2f.{}; - tex_pos : V2f = V2f.{ 0f, 0f }; - tex_size : V2f = V2f.{ 0f, 0f }; + tex_pos : V2f = V2f.{}; + tex_size : V2f = V2f.{}; color : Color4f32 = Color4f32.{ 0f, 0f, 0f, 0f }; } @@ -165,8 +165,6 @@ update_at_index :: proc (use qr: ^QuadRenderer, idx: i32, quad: Quad) { rebuffer_data :: proc (use qr: ^QuadRenderer) { if !is_data_dirty do return; - println("Rebuffering DATA!!"); - gl.bindBuffer(gl.ARRAY_BUFFER, quadBuffer); gl.bufferSubData(gl.ARRAY_BUFFER, 0, (#type [] void).{ count = quad_data.count * sizeof Quad, diff --git a/src/input.onyx b/src/input.onyx index 00ea2ee..fabefa8 100644 --- a/src/input.onyx +++ b/src/input.onyx @@ -45,8 +45,8 @@ init :: proc (use state: ^InputState) { mouse.x = 0; mouse.y = 0; - mouse.wheel_ups = ~~0; - mouse.wheel_downs = ~~0; + mouse.wheel_ups = 0; + mouse.wheel_downs = 0; } process_event :: proc (use state: ^InputState, ev: ^event.Event) { @@ -95,8 +95,8 @@ process_event :: proc (use state: ^InputState, ev: ^event.Event) { // @FIXME: This could overflow... if there were 256+ wheel up/down events // in one frame. Still something that should be considered. - if is_up do mouse.wheel_ups += ~~1; - else do mouse.wheel_downs += ~~1; + if is_up do mouse.wheel_ups += 1; + else do mouse.wheel_downs += 1; } } } @@ -107,8 +107,8 @@ postupdate :: proc (use state: ^InputState) { for ^key: keys_just_down do *key = false; for ^button: mouse.buttons_just_down do *button = false; - if mouse.wheel_ups > ~~0 do mouse.wheel_ups -= ~~1; - if mouse.wheel_downs > ~~0 do mouse.wheel_downs -= ~~1; + if mouse.wheel_ups > 0 do mouse.wheel_ups -= 1; + if mouse.wheel_downs > 0 do mouse.wheel_downs -= 1; mouse.dx = 0; mouse.dy = 0; diff --git a/src/main.onyx b/src/main.onyx index e52ff8c..282edc7 100644 --- a/src/main.onyx +++ b/src/main.onyx @@ -300,9 +300,12 @@ Dude :: struct { dude_create_random :: proc () -> Dude { return Dude.{ - pos = V2f.{ random.float(0.0f, 1200.0f), random.float(0.0f, 1200.0f) }, - vel = V2f.{ random.float(-3.0f, 3.0f), random.float(-3.0f, 3.0f) }, - size = random.float(4.0f, 6.0f), + entity = Entity.{ + pos = V2f.{ random.float(0.0f, 1200.0f), random.float(0.0f, 1200.0f) }, + vel = V2f.{ random.float(-3.0f, 3.0f), random.float(-3.0f, 3.0f) }, + size = random.float(4.0f, 6.0f), + }, + color = Dude_Color_Table[random.int() % 3], // BUG: These should not have to be here but because of the "use entity" in the defintion of Dude, they do. @@ -367,7 +370,6 @@ dude_try_move :: proc (use dude: ^Dude, dt: f32, other_dudes: ^QuadTree(Dude)) { collided = false; pos.y += vel.y * dt; -// if pos.y - size < ~~-half_window_height || pos.y + size >= ~~half_window_height do collided = true; if !aabb_contains(other_dudes.region, pos) do collided = true; dude_aabb = dude_get_aabb(dude); diff --git a/src/vecmath.onyx b/src/vecmath.onyx index b1bac22..391be16 100644 --- a/src/vecmath.onyx +++ b/src/vecmath.onyx @@ -3,7 +3,7 @@ package vecmath use package core // BUG: Default values do not work on polymorphic structs. -V2 :: struct ($T) { x: T; y: T; } +V2 :: struct ($T) { x: T = 0; y: T = 0; } V2f :: #type V2(f32); V2i :: #type V2(i32);