From: Brendan Hansen Date: Wed, 23 Sep 2020 17:45:32 +0000 (-0500) Subject: started using 'use' X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=a5bca8412a67332d66bbba12d8f9abf11c8ee7bc;p=onyx-game.git started using 'use' --- diff --git a/src/font.onyx b/src/font.onyx index 0ec7779..48597d1 100644 --- a/src/font.onyx +++ b/src/font.onyx @@ -706,28 +706,28 @@ ttf_render_glyph :: proc (use ttf: ^TrueTypeFont, glyph: ^TTGlyph, data: ^u8, wi count += 1; state = 0; - for p: poly_points { - print_vec(p); + // for p: poly_points { + // print_vec(p); - tx := cast(i32) (~~p.x * height / ~~units_per_em); - ty := cast(i32) (~~p.y * height / ~~units_per_em); + // tx := cast(i32) (~~p.x * height / ~~units_per_em); + // ty := cast(i32) (~~p.y * height / ~~units_per_em); - if tx >= 0 && ty >= 0 && tx < width && ty < height { - data[tx + (height - 1 - ty) * width] += cast(u8) 100; - } - } - - // for y: 0 .. height do for x: 0 .. width { - // sx := x * ~~units_per_em / width; - // sy := y * ~~units_per_em / height; - - // if is_inside_polygon(array_to_slice(^poly_points), V2i.{ sx, sy }) { - // curr := data[x + (height - 1 - y) * width]; - // if curr == ~~0 do data[x + (height - 1 - y) * width] = cast(u8) 255; - // else do data[x + (height - 1 - y) * width] = cast(u8) 0; + // if tx >= 0 && ty >= 0 && tx < width && ty < height { + // data[tx + (height - 1 - ty) * width] += cast(u8) 100; // } // } + for y: 0 .. height do for x: 0 .. width { + sx := x * ~~units_per_em / width; + sy := y * ~~units_per_em / height; + + if is_inside_polygon(array_to_slice(^poly_points), V2i.{ sx, sy }) { + curr := data[x + (height - 1 - y) * width]; + if curr == ~~0 do data[x + (height - 1 - y) * width] = cast(u8) 255; + else do data[x + (height - 1 - y) * width] = cast(u8) 0; + } + } + array_clear(^poly_points); } } diff --git a/src/main.onyx b/src/main.onyx index 1d09552..e07a9ff 100644 --- a/src/main.onyx +++ b/src/main.onyx @@ -91,17 +91,13 @@ player : Player poll_events :: proc () { + use event.DomEventKind; + ev : event.Event; while event.poll(^ev) do switch ev.kind { - case event.DomEventKind.KeyDown, - event.DomEventKind.KeyUp, - event.DomEventKind.MouseDown, - event.DomEventKind.MouseUp, - event.DomEventKind.MouseMove { - input.process_event(^input_state, ^ev); - } + case KeyDown, KeyUp, MouseDown, MouseUp, MouseMove do input.process_event(^input_state, ^ev); - case event.DomEventKind.Resize { + case Resize { window_width = ev.resize.width; window_height = ev.resize.height; @@ -209,7 +205,7 @@ main :: proc (args: [] cstring) { ttf = ttf_create(ttf_data); glyph : ^TTGlyph = null; - glyph_index := ttf_lookup_glyph_by_char(^ttf, ~~ #char "~"); + glyph_index := ttf_lookup_glyph_by_char(^ttf, ~~ #char "A"); glyph = ttf_read_glyph(^ttf, glyph_index); if glyph == null do return; defer ttf_glyph_destroy(glyph);