MCPcopy Create free account
hub / github.com/17cupsofcoffee/rl / update

Method update

src/main.rs:42–62  ·  view source on GitHub ↗
(&mut self, ctx: &mut Context)

Source from the content-addressed store, hash-verified

40
41impl State for GameState {
42 fn update(&mut self, ctx: &mut Context) -> tetra::Result {
43 if input::is_key_pressed(ctx, Key::F5) {
44 *self = GameState::new(ctx)?;
45 }
46
47 self.resources.input.up =
48 input::is_key_down(ctx, Key::Up) || input::is_key_down(ctx, Key::W);
49 self.resources.input.down =
50 input::is_key_down(ctx, Key::Down) || input::is_key_down(ctx, Key::S);
51 self.resources.input.left =
52 input::is_key_down(ctx, Key::Left) || input::is_key_down(ctx, Key::A);
53 self.resources.input.right =
54 input::is_key_down(ctx, Key::Right) || input::is_key_down(ctx, Key::D);
55
56 systems::grant_energy(&mut self.world, &mut self.resources);
57 systems::player_movement(&mut self.world, &mut self.resources);
58 systems::basic_enemy_movement(&mut self.world, &mut self.resources);
59 systems::process_movement(&mut self.world, &mut self.resources);
60
61 Ok(())
62 }
63
64 fn draw(&mut self, ctx: &mut Context) -> tetra::Result {
65 graphics::clear(ctx, Color::BLACK);

Callers

nothing calls this directly

Calls 4

grant_energyFunction · 0.85
player_movementFunction · 0.85
basic_enemy_movementFunction · 0.85
process_movementFunction · 0.85

Tested by

no test coverage detected