Files
QuenchTreeArboretum/game.wren

69 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: world/prototype" for Prototype
import "luxe: draw" for Draw, PathStyle
import "luxe: input" for Input, Key, InputType, Scan
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")
// Load both the Arena scene and the Player scene
Scene.create(world, Asset.scene("scene/arena01"))
Scene.create(world, Asset.scene("scene/player"))
// Get a reference to the Player entity
_player = Entity.get_named(world, "Player")
// And create the first-person camera
_fpscam = FirstPersonCamera.new(world, camera, "game")
// Put player above the floor
Transform.set_pos_y(_player, 0.75)
// And link the camera to the Player entity
// (linking is how you "parent" one Transform to another in luxe)
Camera.set3D(camera, 85, width/height, 0.01, 500)
Transform.link(camera, _player, TransformLinkAction.reset_local)
Transform.set_pos_y(camera, 1.7)
// The mouse now belongs to me
Input.set_mouse_capture(true)
Input.set_mouse_visible(false)
// Pressing ~ will toggle the mouse cursor active/inactive
Input.listen_for(InputType.key_down) {|key, scan, repeat, mod|
if(scan == Scan.grave) {
_fpscam.enabled = !_fpscam.enabled
Input.set_mouse_visible(_fpscam.enabled)
}
}
} //ready
tick(delta: Num) {
if(Input.key_state_released(Key.escape)) {
IO.shutdown()
}
// What? Where's the frickin' game code?
// Look in the system directory.
// The player is handled in player_input
} //tick
} //Game