M README.md => README.md +5 -1
@@ 25,7 25,7 @@ with this 2D game
- [ ] zoom camera with pinch gesture
- [ ] place block with single click
- [ ] destroy block with long click
-- [ ] Settings menu (i.e for Keybindings)
+- [ ] Settings menu (i.e for Keybindings and audio)
- [x] Background music (ambient)
- [x] Add more assets
- [x] SketchTown Expansion pack
@@ 68,6 68,10 @@ with this 2D game
| Close Inventory | `Q`, `I` or `<Escape>` |
| Page down | `<ArrowDown>` |
| Page up | `<ArrowUp>` |
+| rotate blocks: North | `K` |
+| rotate blocks: South | `J` |
+| rotate blocks: West | `H` |
+| rotate blocks: East | `L` |
### Level Select screen
| Action | Key(s) / MouseButton |
M src/screens/build.rs => src/screens/build.rs +18 -15
@@ 334,6 334,8 @@ impl GameComponent for BuildScreen {
}
for (i, slot) in self.inventory_widgets.widgets_slots.iter_mut().enumerate() {
+ slot.update_dir(&world.inventory.direction);
+
match slot.ev_loop() {
ButtonEvent::LeftClick => {
// user selected block
@@ 348,7 350,6 @@ impl GameComponent for BuildScreen {
}
} else {
-
// process inventory events
if is_key_down(KeyCode::I) {
// open inventory
@@ 534,20 535,6 @@ impl GameComponent for BuildScreen {
self.mouse_position = None;
}
- // change block direction
- if is_key_pressed(KeyCode::K) {
- world.inventory.direction = Direction::North;
- }
- if is_key_pressed(KeyCode::L) {
- world.inventory.direction = Direction::East;
- }
- if is_key_pressed(KeyCode::J) {
- world.inventory.direction = Direction::South;
- }
- if is_key_pressed(KeyCode::H) {
- world.inventory.direction = Direction::West;
- }
-
// save the world
if is_key_pressed(KeyCode::S)
|| is_key_pressed(KeyCode::Q)
@@ 569,7 556,23 @@ impl GameComponent for BuildScreen {
return GameEvent::ChangeScreen(Screen::default());
}
}
+ }
+ // change block direction
+ // player might do this in following cenarios:
+ // - in inventory
+ // - in world
+ if is_key_pressed(KeyCode::K) {
+ world.inventory.direction = Direction::North;
+ }
+ if is_key_pressed(KeyCode::L) {
+ world.inventory.direction = Direction::East;
+ }
+ if is_key_pressed(KeyCode::J) {
+ world.inventory.direction = Direction::South;
+ }
+ if is_key_pressed(KeyCode::H) {
+ world.inventory.direction = Direction::West;
}
} else {
// game has no world
M src/ui/item_frame.rs => src/ui/item_frame.rs +5 -0
@@ 94,6 94,11 @@ impl ItemFrame {
}
self.direction = direction.clone();
}
+ /// updates the block orientation
+ #[allow(dead_code)]
+ pub fn update_dir(&mut self, direction: &Direction) {
+ self.direction = direction.clone();
+ }
}
impl Widget for ItemFrame {
type Event = ButtonEvent;