MCPcopy Create free account
hub / github.com/chyyuu/os_kernel_lab / main

Function main

user/src/bin/gui_snake.rs:329–351  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

327const CR: u8 = 0x0du8;
328#[no_mangle]
329pub fn main() -> i32 {
330 let mut disp = Display::new(Size::new(VIRTGPU_XRES, VIRTGPU_YRES));
331 let mut game = SnakeGame::<20, Rgb888>::new(1280, 800, 20, 20, Rgb888::RED, Rgb888::YELLOW, 50);
332 let _ = disp.clear(Rgb888::BLACK).unwrap();
333 loop {
334 if key_pressed() {
335 let c = getchar();
336 match c {
337 LF => break,
338 CR => break,
339 b'w' => game.set_direction(Direction::Up),
340 b's' => game.set_direction(Direction::Down),
341 b'a' => game.set_direction(Direction::Left),
342 b'd' => game.set_direction(Direction::Right),
343 _ => (),
344 }
345 }
346 let _ = disp.clear(Rgb888::BLACK).unwrap();
347 game.draw(&mut disp);
348 sleep(10);
349 }
350 0
351}

Callers

nothing calls this directly

Calls 6

key_pressedFunction · 0.85
getcharFunction · 0.85
sleepFunction · 0.85
clearMethod · 0.80
set_directionMethod · 0.80
drawMethod · 0.80

Tested by

no test coverage detected