-
-
Notifications
You must be signed in to change notification settings - Fork 416
Expand file tree
/
Copy pathinput_keys.rs
More file actions
28 lines (24 loc) · 649 Bytes
/
input_keys.rs
File metadata and controls
28 lines (24 loc) · 649 Bytes
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
use macroquad::prelude::*;
#[macroquad::main("InputKeys")]
async fn main() {
let mut x = screen_width() / 2.0;
let mut y = screen_height() / 2.0;
loop {
clear_background(LIGHTGRAY);
if is_key_down(KeyCode::Right) {
x += 1.0;
}
if is_key_down(KeyCode::Left) {
x -= 1.0;
}
if is_key_down(KeyCode::Down) {
y += 1.0;
}
if is_key_down(KeyCode::Up) {
y -= 1.0;
}
draw_circle(x, y, 15.0, YELLOW);
draw_text("move the ball with arrow keys", 20.0, 20.0, 20.0, DARKGRAY);
next_frame().await
}
}