repro
This commit is contained in:
commit
acdbddef2f
9 changed files with 305 additions and 0 deletions
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
*/.DS_Store
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
*/thumbs.db
|
||||
thumbs.db
|
||||
.thumbs.db?
|
||||
.luxe/
|
||||
_luxe.data/
|
||||
_luxe.deploy/
|
||||
log*.txt
|
||||
1
.luxeignore
Normal file
1
.luxeignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
preview.png
|
||||
110
game.wren
Normal file
110
game.wren
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
import "luxe: game" for Ready
|
||||
import "luxe: assets" for Assets
|
||||
import "luxe: input" for Input, Key, MouseButton
|
||||
import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera, UIEventData
|
||||
import "luxe: math" for Math
|
||||
import "luxe: draw" for Draw
|
||||
import "luxe: io" for IO
|
||||
import "luxe: ui" for UI, UIPanel, UILabel, Control, UIEvent
|
||||
import "luxe: color" for Color
|
||||
|
||||
import "outline/app" for App
|
||||
|
||||
class Game is Ready {
|
||||
|
||||
construct ready() {
|
||||
|
||||
super("ready!")
|
||||
|
||||
app = App.new()
|
||||
app.color = Color.black
|
||||
|
||||
System.print("render size: %(app.width) x %(app.height) @ %(app.scale)x")
|
||||
|
||||
var ui = Entity.create(app.ui)
|
||||
UI.create(ui, 0, 0, app.width, app.height, 0, app.ui_camera)
|
||||
|
||||
{ //cross-control events dont work properly
|
||||
var event_reciever = UIPanel.create(ui)
|
||||
UIPanel.set_color(event_reciever, [1, 0, 0, 1])
|
||||
Control.set_allow_input(event_reciever, true)
|
||||
Control.set_pos(event_reciever, 100, 100)
|
||||
Control.set_process(event_reciever){|control: Control, state: Any, event: UIEventData, x: Num, y: Num, w: Num, h: Num|
|
||||
if(event.control != control) return //required
|
||||
if(event.type == UIEvent.change){
|
||||
System.print("receive")
|
||||
UIPanel.set_color(event_reciever, [0, 0, 1, 1])
|
||||
}
|
||||
}
|
||||
|
||||
var event_sender = UILabel.create(ui)
|
||||
UILabel.set_text(event_sender, "click to change panel.")
|
||||
Control.set_pos(event_sender, 200, 100)
|
||||
Control.set_allow_input(event_sender, true)
|
||||
Control.set_process(event_sender){|control: Control, state: Any, event: UIEventData, x: Num, y: Num, w: Num, h: Num|
|
||||
if(event.control != control) return //required
|
||||
if(event.type == UIEvent.press){
|
||||
System.print("send")
|
||||
UI.events_emit(event_reciever, UIEvent.change)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{ //cross-control capture doesnt work properly (clicking left control should capture right, but actually captures left with wrong debug vis)
|
||||
var captured = UIPanel.create(ui)
|
||||
Control.set_id(captured, "captured")
|
||||
UIPanel.set_color(captured, [1, 0, 0, 1])
|
||||
Control.set_allow_input(captured, true)
|
||||
Control.set_pos(captured, 200, 200)
|
||||
Control.set_process(captured){|control: Control, state: Any, event: UIEventData, x: Num, y: Num, w: Num, h: Num|
|
||||
if(event.control != control) return //required
|
||||
if(event.type == UIEvent.move){
|
||||
System.print("move")
|
||||
var rel_pos = inv_lerp(y, y+h, event.y)
|
||||
var col = Color.lerp([1, 0, 0, 1], [0, 0, 1, 1], rel_pos)
|
||||
UIPanel.set_color(captured, col)
|
||||
}
|
||||
}
|
||||
|
||||
var capturing = UIPanel.create(ui)
|
||||
Control.set_id(capturing, "capturing")
|
||||
UIPanel.set_color(capturing, [1, 0, 0, 1])
|
||||
Control.set_allow_input(capturing, true)
|
||||
Control.set_pos(capturing, 100, 200)
|
||||
Control.set_process(capturing){|control: Control, state: Any, event: UIEventData, x: Num, y: Num, w: Num, h: Num|
|
||||
if(event.control != control) return //required
|
||||
if(event.type == UIEvent.move){
|
||||
System.print("move")
|
||||
var rel_pos = inv_lerp(y, y+h, event.y)
|
||||
var col = Color.lerp([1, 0, 0, 1], [0, 0, 1, 1], rel_pos)
|
||||
UIPanel.set_color(capturing, col)
|
||||
}
|
||||
if(event.type == UIEvent.press){
|
||||
System.print("capture other")
|
||||
UI.capture(captured)
|
||||
}
|
||||
}
|
||||
}
|
||||
} //ready
|
||||
|
||||
inv_lerp(from, to, x){
|
||||
return (x - from) / (to - from)
|
||||
}
|
||||
|
||||
tick(delta) {
|
||||
if(Input.key_state_released(Key.escape)) {
|
||||
IO.shutdown()
|
||||
}
|
||||
} //tick
|
||||
|
||||
destroy() {
|
||||
|
||||
System.print("unready!")
|
||||
app.destroy()
|
||||
|
||||
} //destroy
|
||||
|
||||
app:App { _app }
|
||||
app=(v) { _app=v }
|
||||
|
||||
} //Game
|
||||
74
outline/app.wren
Normal file
74
outline/app.wren
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import "luxe: world" for World, Camera, Entity, Transform
|
||||
import "luxe: render" for Render
|
||||
import "luxe: game" for Frame
|
||||
|
||||
class App {
|
||||
|
||||
world { _world }
|
||||
ui { _ui_world }
|
||||
|
||||
camera { _camera }
|
||||
ui_camera { _ui_camera }
|
||||
|
||||
color { _color }
|
||||
color=(v) { _color = v }
|
||||
|
||||
width { Render.window_w() }
|
||||
height { Render.window_h() }
|
||||
scale { Render.drawable_ratio() }
|
||||
|
||||
construct new() {
|
||||
|
||||
_color = [1,1,1,1]
|
||||
|
||||
//create worlds
|
||||
|
||||
_world = World.create("game")
|
||||
_ui_world = World.create("ui")
|
||||
|
||||
//create cameras
|
||||
|
||||
_camera = Entity.create(_world, "app.camera")
|
||||
Transform.create(_camera)
|
||||
Camera.create(_camera)
|
||||
Camera.set_default(_world, _camera)
|
||||
|
||||
_ui_camera = Entity.create(_ui_world, "app.ui_camera")
|
||||
Transform.create(_ui_camera)
|
||||
Camera.create(_ui_camera)
|
||||
Camera.set_default(_ui_world, _ui_camera)
|
||||
|
||||
//update our worlds
|
||||
|
||||
Frame.on(Frame.sim) {|delta|
|
||||
World.tick(_world, delta)
|
||||
World.tick(_ui_world, delta)
|
||||
}
|
||||
|
||||
//render our worlds
|
||||
|
||||
Frame.on(Frame.visual) {|delta|
|
||||
World.render(_world, _camera, "game", {"clear_color":_color})
|
||||
World.render(_ui_world, _ui_camera, "ui")
|
||||
}
|
||||
|
||||
} //new
|
||||
|
||||
destroy() {
|
||||
|
||||
//destroy cameras
|
||||
|
||||
Camera.destroy(_camera)
|
||||
Camera.destroy(_ui_camera)
|
||||
|
||||
Entity.destroy(_camera)
|
||||
Entity.destroy(_ui_camera)
|
||||
|
||||
//destroy worlds
|
||||
|
||||
World.destroy(_ui_world)
|
||||
World.destroy(_world)
|
||||
|
||||
} //destroy
|
||||
|
||||
} //
|
||||
23
outline/inputs.input.lx
Normal file
23
outline/inputs.input.lx
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
input = {
|
||||
nodes = [
|
||||
{ name = "ui" where = "front" channels = ["c01"] }
|
||||
{ name = "game" where = "after: ui" channels = ["c02"] }
|
||||
]
|
||||
|
||||
map = {
|
||||
left = { keys = ["key_a", "left"] }
|
||||
right = { keys = ["key_d", "right"] }
|
||||
up = { keys = ["key_w", "up"] }
|
||||
down = { keys = ["key_s", "down"] }
|
||||
jump = {
|
||||
keys = ["key_x", "up", "key_w", "space"]
|
||||
mouse = ["left"]
|
||||
gamepad = [0]
|
||||
}
|
||||
|
||||
next = {
|
||||
keys = ["key_x", "up", "key_w", "space", "enter", "escape"]
|
||||
mouse = ["left", "right"]
|
||||
}
|
||||
}
|
||||
}
|
||||
51
outline/renderer.wren
Normal file
51
outline/renderer.wren
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import "luxe: render" for Render, RenderLayerDesc, PassLayerDesc, LoadAction
|
||||
import "luxe: render" for SortType, ImageDesc, ImageType, PixelFormat
|
||||
|
||||
class Renderer {
|
||||
|
||||
construct new() {
|
||||
|
||||
System.print("game / render / init / ok")
|
||||
|
||||
} //new
|
||||
|
||||
ready() {
|
||||
|
||||
}
|
||||
|
||||
tick(delta) {
|
||||
|
||||
}
|
||||
|
||||
render_path(ctx) {
|
||||
|
||||
if(ctx.path == "game") {
|
||||
game_render_path(ctx)
|
||||
} else if(ctx.path == "ui") {
|
||||
ui_render_path(ctx)
|
||||
}
|
||||
|
||||
} //render_path
|
||||
|
||||
game_render_path(ctx) {
|
||||
|
||||
var layer = RenderLayerDesc.new()
|
||||
layer.dest.color[0].clear_color = ctx.get("clear_color", [1,1,1,1])
|
||||
layer.dest.color[0].load_action = LoadAction.clear
|
||||
layer.dest.depth.load_action = LoadAction.clear
|
||||
|
||||
ctx.layer_render("default", layer)
|
||||
|
||||
} //game_render_path
|
||||
|
||||
ui_render_path(ctx) {
|
||||
|
||||
var layer = RenderLayerDesc.new()
|
||||
layer.dest.color[0].load_action = LoadAction.dont_care
|
||||
layer.dest.depth.load_action = LoadAction.clear
|
||||
|
||||
ctx.layer_render("default", layer)
|
||||
|
||||
} //ui_render_path
|
||||
|
||||
} //Renderer
|
||||
19
outline/settings.settings.lx
Normal file
19
outline/settings.settings.lx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
engine = {
|
||||
input.entry = "outline/inputs"
|
||||
runtime = {
|
||||
window = {
|
||||
width = 960
|
||||
height = 640
|
||||
resizable = false
|
||||
fullscreen = false
|
||||
}
|
||||
}
|
||||
|
||||
render = {
|
||||
antialiasing = 2
|
||||
stencil = 8
|
||||
depth = 24
|
||||
}
|
||||
|
||||
ui.debug_vis = true
|
||||
}
|
||||
14
project.luxe
Normal file
14
project.luxe
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import "luxe: project" for Entry
|
||||
|
||||
class Project is Entry {
|
||||
|
||||
construct entry(target) {
|
||||
|
||||
name = "game"
|
||||
version = "0.0.0"
|
||||
renderer = "outline/renderer"
|
||||
settings = "outline/settings"
|
||||
|
||||
} //new
|
||||
|
||||
} //Project
|
||||
3
project.modules.lx
Normal file
3
project.modules.lx
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
modules = {
|
||||
luxe = "2022.0.5"
|
||||
} //modules
|
||||
Loading…
Reference in a new issue