This commit is contained in:
Schluffe
2026-03-15 14:48:17 +01:00
parent 650b28a660
commit a1c4dd8401
4 changed files with 108 additions and 19 deletions
+12 -12
View File
@@ -21,22 +21,22 @@ const process = defineEntity("hero", {
});
process((id, delta) => {
const position = $<Vector>("position").get(id)!;
const velocity = $<Vector>("velocity").get(id)!;
const position = $<Vector>("position").get(id)!.value;
const velocity = $<Vector>("velocity").get(id)!.value;
if (pointer.isDown) {
position.value.x = pointer.position.x;
position.value.y = pointer.position.y;
position.x = pointer.position.x;
position.y = pointer.position.y;
}
velocity.value.x -= keyboardInput.arrowLeft ? speed : 0;
velocity.value.x += keyboardInput.arrowRight ? speed : 0;
velocity.value.y -= keyboardInput.arrowUp ? speed : 0;
velocity.value.y += keyboardInput.arrowDown ? speed : 0;
velocity.x -= keyboardInput.arrowLeft ? speed : 0;
velocity.x += keyboardInput.arrowRight ? speed : 0;
velocity.y -= keyboardInput.arrowUp ? speed : 0;
velocity.y += keyboardInput.arrowDown ? speed : 0;
position.value.x = Math.round(velocity.value.x * delta + position.value.x);
position.value.y = Math.round(velocity.value.y * delta + position.value.y);
position.x = Math.round(velocity.x * delta + position.x);
position.y = Math.round(velocity.y * delta + position.y);
velocity.value.x = 0;
velocity.value.y = 0;
velocity.x = 0;
velocity.y = 0;
});