Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions examples/4_tiny_video_game/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
import polyscope as ps
from polyscope import imgui
import keyboard
from uipc import view
from uipc import Engine, World, Scene, Animation
from uipc import Vector3, Vector2, Transform, Logger, Quaternion, AngleAxis
Expand All @@ -16,11 +15,17 @@
ps.init()
Logger.set_level(Logger.Level.Warn)

_KEY_MAP = {
"w": imgui.ImGuiKey_W, "s": imgui.ImGuiKey_S, "d": imgui.ImGuiKey_D,
"a": imgui.ImGuiKey_A, "e": imgui.ImGuiKey_E, "q": imgui.ImGuiKey_Q,
}

class IO:
@staticmethod
def is_key_down(key_str:str):
return keyboard.is_pressed(key_str.lower())

key = _KEY_MAP.get(key_str.lower())
return imgui.IsKeyDown(key) if key is not None else False

@staticmethod
def movement():
w = 1.0 if IO.is_key_down("W") else 0.0
Expand Down