Grid helper

main
parent c2c6513f56
commit d468253f21

Binary file not shown.

@ -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);

Loading…
Cancel
Save