CabinGame/Luxe/game.wren

64 lines
1.4 KiB
Text
Raw Normal View History

2020-08-16 13:59:43 +00:00
import "luxe: game" for Game
import "luxe: assets" for Assets
import "luxe: input" for Input, Key
import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera
import "luxe: math" for Math
import "luxe: draw" for Draw
import "luxe: io" for IO
import "outline/app" for App
import "blocks/ui" for Ui
import "blocks/debug" for DrawDebug, Holder
import "globals" for ActiveRenderer
import "math/vector" for Vector
class game is Game {
construct ready() {
System.print("ready!")
app = App.new()
Ui.setup(app)
System.print("render size: %(app.width) x %(app.height) @ %(app.scale)x")
DrawDebug.setup(app.world)
_logo = Entity.create(app.world, "sprite")
Transform.create(_logo)
Transform.set_pos(_logo, app.width/2, app.height/2, 0)
Sprite.create(_logo, Assets.material("luxe: material/logo"), 16, 16)
} //ready
tick(delta) {
var mouse_pos = Vector.new(Input.mouse_x(), Input.mouse_y())
mouse_pos = ActiveRenderer.x.game_mouse(mouse_pos)
var pos = Camera.screen_point_to_world(app.camera, mouse_pos.x, mouse_pos.y)
Transform.set_pos(_logo, pos.x + 5, pos.y-8, 0)
if(Input.key_state_released(Key.escape)) {
IO.shutdown()
}
app.tick(delta)
DrawDebug.commit()
} //tick
destroy() {
System.print("unready!")
app.destroy()
} //destroy
app { _app }
app=(v) { _app=v }
} //Game