75 lines
2.1 KiB
Plaintext
75 lines
2.1 KiB
Plaintext
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
|
|
import "luxe: assets" for Assets
|
|
import "luxe: asset" for Asset
|
|
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 {
|
|
|
|
construct 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.link(camera, _player, TransformLinkAction.reset_local)
|
|
Transform.set_pos_y(camera, 0.6)
|
|
Input.set_mouse_capture(true)
|
|
Input.set_mouse_visible(false)
|
|
|
|
} //ready
|
|
|
|
tick(delta: Num) {
|
|
|
|
if(Input.key_state_released(Key.escape)) {
|
|
IO.shutdown()
|
|
}
|
|
|
|
// 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
|
|
|
|
set_use_debug_camera(use_debug: Bool) {
|
|
_using_debug_cam = use_debug
|
|
Input.set_mouse_capture(!use_debug)
|
|
Input.set_mouse_visible(use_debug)
|
|
}
|
|
|
|
} //Game
|