1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// if you'd prefer to use positive y meaning up, as is more standard in math
// this isnt fully stable/implemented and things like drawing text dont work
use sge::prelude::*;
#[main("Flip y")]
async fn main() -> anyhow::Result<()> {
init("Flip y")?;
use_positive_y_up();
let mut position = window_center();
loop {
if window_resized().is_some() {
position = window_center();
}
draw_circle(position, 100.0, Color::PINK_400);
let speed = delta_time() * window_height() / 2.0;
if key_held(KeyCode::ArrowUp) {
position.y += speed;
}
if key_held(KeyCode::ArrowDown) {
position.y -= speed;
}
if should_quit() {
break;
}
next_frame().await;
}
Ok(())
}