diff --git a/Roboto-Regular.ttf b/Roboto-Regular.ttf new file mode 100644 index 0000000..ddf4bfa Binary files /dev/null and b/Roboto-Regular.ttf differ diff --git a/physics.jai b/physics.jai index 178c5c8..c4cc7c7 100644 --- a/physics.jai +++ b/physics.jai @@ -74,6 +74,14 @@ push_pip :: (d: DrawingSettings, at: Vector2) } } } +font: *Simp.Dynamic_Font; +text :: (using d: DrawingSettings, t: string, p: Vector2) { + drawing_at := p; + if world_space { + drawing_at = world_to_screen(drawing_at); + } + Simp.draw_text(font, xx drawing_at.x, xx drawing_at.y, t, color = color); +} draw_pips :: (dt: float) { for * pips if it.alive_for > 0.0 @@ -195,8 +203,12 @@ main :: () { Simp.set_render_target(window); + font = Simp.get_font_at_size(".", "Roboto-Regular.ttf", 18); + assert(font != null); + bodies: [..]Body; array_add(*bodies, .{pos = .{0.0, 0.0}, shape = .{type = .Circle, radius = 1.0}}); + array_add(*bodies, .{pos = .{3.0, 0.0}, shape = .{type = .Circle, radius = 1.0}}); quit := false; last_time := get_time(); @@ -275,15 +287,23 @@ main :: () { // draw grid grid_d: DrawingSettings = .{true,.{0.2, 0.2, 0.2, 0.5}}; + text_d := grid_d; + text_d.color = .{0.6, 0.6, 0.6, 1.0}; + help_text_max :: 8; + help_zoom_max :: 0.04; for x: -30..30 { line(grid_d, xy(x, 30), xy(x, -30)); + if camera.zoom <= help_zoom_max && abs(x) < help_text_max then text(text_d, tprint("%m", x), .{xx x, 0.0}); } for y: -30..30 { line(grid_d, xy(30, y), xy(-30, y)); + if camera.zoom <= help_zoom_max && abs(y) < help_text_max then text(text_d, tprint("%m", y), .{0.0, xx y}); } draw_pips(dt); for bodies draw_body(it); + + Simp.immediate_flush(); Simp.swap_buffers(window);