luxe-colorpicker/game.wren
2021-11-11 21:49:18 +01:00

59 lines
1.4 KiB
Text

import "luxe: game" for Ready
import "luxe: assets" for Assets
import "luxe: input" for Input, Key
import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera, UI, UILayoutMode
import "luxe: math" for Math
import "luxe: draw" for Draw
import "luxe: io" for IO
import "luxe: ui/control" for Control
import "outline/app" for App
import "colorpicker" for ColorPicker
class Game is Ready {
construct ready() {
super("ready!")
app = App.new()
app.color.r = app.color.g = app.color.b = 0.7
System.print("render size: %(app.width) x %(app.height) @ %(app.scale)x")
_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"), 128, 128)
var ui = Entity.create(app.ui, "ui")
UI.create(ui, 0, 0, app.width, app.height, 0, app.ui_camera)
UI.set_layout_mode(ui, UILayoutMode.flex)
var picker = ColorPicker.create(ui)
Control.set_pos(picker, 100, 100)
} //ready
tick(delta) {
var pos = Camera.screen_point_to_world(app.camera, Input.mouse_x(), Input.mouse_y())
Transform.set_pos(_logo, pos.x, pos.y, 0)
if(Input.key_state_released(Key.escape)) {
IO.shutdown()
}
//app.color.r = app.color.g = app.color.b = (IO.timestamp()/20 % 1)
} //tick
destroy() {
System.print("unready!")
app.destroy()
} //destroy
app { _app }
app=(v) { _app=v }
} //Game