Added basic player movement

This commit is contained in:
2025-06-20 14:37:23 -07:00
parent 75502fe544
commit 8f7114431c
21 changed files with 282 additions and 328 deletions

View File

@ -1,4 +1,4 @@
import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera
import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera, TransformLinkAction
import "luxe: world/scene" for Scene
import "luxe: draw" for Draw, PathStyle
import "luxe: input" for Input, Key
@ -8,7 +8,9 @@ import "luxe: math" for Math
import "luxe: io" for IO
import "luxe: system/physics/box_collider3D.modifier" for BoxCollider3D
import "luxe: system/physics/character3D.modifier" for Character3D
import "camera: editor" for EditorCamera
import "camera: first_person" for FirstPersonCamera
import "outline/ready" for Ready
class Game is Ready {
@ -17,16 +19,24 @@ class Game is Ready {
super("ready! %(width) x %(height) @ %(scale)x")
// set_use_debug_camera(true)
// _debug_cam = EditorCamera.new(world, camera, "any")
// _debug_cam.speed = 1
Scene.create(world, Asset.scene("scene/arena01"))
Scene.create(world, Asset.scene("scene/player"))
_player = Entity.get_named(world, "Player")
_fpscam = FirstPersonCamera.new(world, camera, "game")
Transform.set_pos_y(_player, 0.75)
Camera.set3D(camera, 85, width/height, 0.01, 500)
Transform.set_pos(camera, 0, 1, 4)
Transform.set_euler_x(camera, -0.25)
set_use_debug_camera(true)
_debug_cam = EditorCamera.new(world, camera, "any")
_debug_cam.speed = 1
// Scene.create(world, Asset.scene("scene/arena01"))
Transform.link(camera, _player, TransformLinkAction.reset_local)
Transform.set_pos_y(camera, 0.6)
Input.set_mouse_capture(true)
Input.set_mouse_visible(false)
} //ready
@ -36,9 +46,22 @@ class Game is Ready {
IO.shutdown()
}
if (_using_debug_cam) {
_debug_cam.tick(delta)
}
// if (_using_debug_cam) {
// _debug_cam.tick(delta)
// }
if (Entity.valid(_player) && Character3D.has(_player)) {
var fore = Input.event_active("up", "game") ? -1 : 0
var back = Input.event_active("down", "game") ? 1 : 0
var left = Input.event_active("left", "game") ? -1 : 0
var right = Input.event_active("right", "game") ? 1 : 0
var input = Transform.local_vector_to_world(camera, right + left, 0, fore + back)
input.y = 0
Math.normalize(input)
Character3D.set.input(_player, input)
}
} //tick