31 lines
921 B
Rust
31 lines
921 B
Rust
mod raylib;
|
|
|
|
fn main() {
|
|
let screen = raylib::Vector2::<u32> { x: 800, y: 600 };
|
|
let mut pos = raylib::Vector2::<u32> {
|
|
x: screen.x / 2,
|
|
y: screen.y / 2
|
|
};
|
|
raylib::init_window(screen.x, screen.y, "Hello, raylib");
|
|
raylib::set_target_fps(60);
|
|
|
|
while !raylib::window_should_close() {
|
|
raylib::begin_drawing();
|
|
raylib::clear_background(raylib::colors::BLACK);
|
|
|
|
if raylib::is_key_down(raylib::Key::W) {
|
|
pos.y -= 10;
|
|
} else if raylib::is_key_down(raylib::Key::S) {
|
|
pos.y += 10;
|
|
} else if raylib::is_key_down(raylib::Key::A) {
|
|
pos.x -= 10;
|
|
} else if raylib::is_key_down(raylib::Key::D) {
|
|
pos.x += 10;
|
|
}
|
|
|
|
raylib::draw_rect(pos.x, pos.y, 100, 100, raylib::colors::RED);
|
|
raylib::end_drawing();
|
|
}
|
|
}
|
|
|