move to luxe 2020.3

This commit is contained in:
Ronja 2020-09-12 07:21:12 +02:00
parent 8645f7966a
commit 6e1db30a8b
13 changed files with 91 additions and 50 deletions

View file

@ -3,18 +3,18 @@ names = [
//make groups based on origin culture / meaning //make groups based on origin culture / meaning
//probably better to do when I have a procgen text engine //probably better to do when I have a procgen text engine
"Bob", "Bob"
"Steve", "Steve"
"Ronja", "Ronja"
"Amelia", "Amelia"
"Chloe", "Chloe"
"Lauren", "Lauren"
"Innes", "Innes"
"Rami", "Rami"
"Mao", "Mao"
"Richard", "Richard"
"Jules", "Jules"
"Mercedes", "Mercedes"
"Karl", "Karl"
"Lara" "Lara"
] ]

View file

@ -1,16 +1,19 @@
modifier = { modifier = {
description = "Moves to a point in space at a constant speed." description = "What is a man?"
field = "human" field = "human"
display = "Human" display = "Human"
class = "Human" class = "Human"
dependency = [] dependency = []
blocks = { blocks = {
data={ data = {
fields = [ fields = [
{ name="active" type="boolean" default=true } { name="active" type="boolean" default=true }
{ name="name" type="id32" default="unnamed" } { name="name" type="id32" default="unnamed" }
{ name="color" type="float4" default=[1, 0, 0, 1] } { name="color" type="float4" default=[1, 0, 0, 1] }
//todo: turn this into a implicit number via references from adventure list
//todo: make this int?
{ name="adventure_count" type="number" default=0 }
] ]
} }
} }

View file

@ -159,6 +159,7 @@ import "luxe: world" for Block
_active = true _active = true
_name = "unnamed" _name = "unnamed"
_color = [1, 0, 0, 1] _color = [1, 0, 0, 1]
_adventure_count = 0
} //new } //new
active { _active } active { _active }
@ -170,6 +171,9 @@ import "luxe: world" for Block
color { _color } color { _color }
color=(vvv) { _color = vvv } color=(vvv) { _color = vvv }
adventure_count { _adventure_count }
adventure_count=(vvv) { _adventure_count = vvv }
} //ModifierData } //ModifierData
//`blocks/human/human > data` compilers //`blocks/human/human > data` compilers
@ -189,6 +193,8 @@ import "luxe: world" for Block
size = size + 16 // color size = size + 16 // color
size = size + 8 // adventure_count
size = size + 0 size = size + 0
return size return size
@ -204,6 +210,7 @@ import "luxe: world" for Block
"active": false, "active": false,
"name": false, "name": false,
"color": false, "color": false,
"adventure_count": false,
} }
for(element in elements) { for(element in elements) {
var instance = element.value var instance = element.value
@ -245,13 +252,18 @@ import "luxe: world" for Block
out.write_float32(color[3]) out.write_float32(color[3])
var adventure_count = instance["adventure_count"]
if(adventure_count == null) adventure_count = 0
out.write_float64(adventure_count)
return out return out
} //write } //write
bytes_count_block() { bytes_count_block() {
return 56 return 72
} //bytes_count_block } //bytes_count_block
@ -261,7 +273,7 @@ import "luxe: world" for Block
out.write_uint32(compiler.string.hash("blocks/human/human > data")) out.write_uint32(compiler.string.hash("blocks/human/human > data"))
//fields count //fields count
out.write_int32(3) out.write_int32(4)
// active // active
out.write_uint32(compiler.string.hash("active")) out.write_uint32(compiler.string.hash("active"))
@ -287,6 +299,13 @@ import "luxe: world" for Block
out.write_float32(color_default[3]) out.write_float32(color_default[3])
// adventure_count
out.write_uint32(compiler.string.hash("adventure_count"))
out.write_uint32(467038368) //type number
var adventure_count_default = 0
out.write_float64(adventure_count_default)
} //write_block } //write_block
write(instance) { write(instance) {
@ -324,6 +343,7 @@ import "luxe: world" for Block
Block.add(_block, "active", "boolean", true) Block.add(_block, "active", "boolean", true)
Block.add(_block, "name", "id32", "unnamed") Block.add(_block, "name", "id32", "unnamed")
Block.add(_block, "color", "float4", [1, 0, 0, 1]) Block.add(_block, "color", "float4", [1, 0, 0, 1])
Block.add(_block, "adventure_count", "number", 0)
Block.set_type(_block, "blocks/human/human > data") Block.set_type(_block, "blocks/human/human > data")
} //new } //new
@ -336,6 +356,8 @@ import "luxe: world" for Block
name=(v) { Block.set(_block, "name", _slot, v) } name=(v) { Block.set(_block, "name", _slot, v) }
color { Block.get(_block, "color", _slot) } color { Block.get(_block, "color", _slot) }
color=(v) { Block.set(_block, "color", _slot, v) } color=(v) { Block.set(_block, "color", _slot, v) }
adventure_count { Block.get(_block, "adventure_count", _slot) }
adventure_count=(v) { Block.set(_block, "adventure_count", _slot, v) }
slot { _slot } slot { _slot }
entity { Block.get_handle(_block, _slot) } entity { Block.get_handle(_block, _slot) }
block_set_slot(value) { block_set_slot(value) {

View file

@ -39,6 +39,17 @@ class Human {
return data.color return data.color
} }
static get_adventure_count(entity){
if(entity == 0 || !entity) return null
var data = Modifiers.get(This, entity)
return data.adventure_count
}
static increase_adventure_count(entity){
var data = Modifiers.get(This, entity)
data.adventure_count = data.adventure_count + 1
}
} //Human } //Human
//Your modifier system implementation. //Your modifier system implementation.

View file

@ -1,5 +1,6 @@
import "luxe: world" for Entity, Text, Transform import "luxe: world" for Entity, Text, Transform
import "luxe: assets" for Assets import "luxe: assets" for Assets
import "luxe: render" for Material
import "globals" for Globals import "globals" for Globals
import "math/vector" for Vector import "math/vector" for Vector
@ -7,9 +8,9 @@ import "math/vector" for Vector
class Tooltip{ class Tooltip{
depth{100} depth{100}
color{[1, 1, 1, 1]} color{[1, 1, 1, 1]}
background{[1, 0, 1, 1]} background{[0, 0, 0, 1]}
shadowOffsets{[[1, 0],[0, 1],[-1, 0],[0, -1]]} shadowOffsets{[[1, 0],[0, 1],[-1, 0],[0, -1],[1, 1],[1, -1],[-1, -1],[-1, 1]]}
construct new(app){ construct new(app){
_text = Entity.create(app.ui) _text = Entity.create(app.ui)
@ -23,9 +24,9 @@ class Tooltip{
_shadows = [] _shadows = []
for(i in offsets){ for(i in offsets){
var shadow = Entity.create(app.ui) var shadow = Entity.create(app.ui)
Text.create(shadow, mat, 8, "assets/fonts/BabyBlocks", background) Text.create(shadow, Material.clone(mat), 8, "assets/fonts/BabyBlocks", background)
Transform.create(shadow) Transform.create(shadow)
Transform.set_snap(_text, 1, 1, 0) Transform.set_snap(shadow, 1, 1, 0)
_shadows.add(shadow) _shadows.add(shadow)
} }
@ -63,12 +64,12 @@ class Tooltip{
} }
set(text, source){ set(text, source){
Text.set_text_buffer(_text, text)
Text.commit(_text)
for(shadow in _shadows){ for(shadow in _shadows){
Text.set_text_buffer(shadow, text) Text.set_text_buffer(shadow, text)
Text.commit(shadow) Text.commit(shadow)
} }
Text.set_text_buffer(_text, text)
Text.commit(_text)
_active = true _active = true
_source = source _source = source
_x = null _x = null

View file

@ -81,6 +81,7 @@ class Ui{
ImageButton.set_tooltip(button, "Adventure!") ImageButton.set_tooltip(button, "Adventure!")
ImageButton.set_tile_uv(button, tiles, [1, 0]) ImageButton.set_tile_uv(button, tiles, [1, 0])
ImageButton.set_state_change(button) { |data| ImageButton.set_state_change(button) { |data|
System.print("adventure button: %(data)")
if(data["press"]){ if(data["press"]){
ui_mode = Ui.Planning ui_mode = Ui.Planning
} }
@ -128,11 +129,20 @@ class Ui{
var name = UISimpleText.create(_ui) var name = UISimpleText.create(_ui)
Control.set_pos(name, 33, 1) Control.set_pos(name, 33, 1)
Control.child_add(root, name) Control.child_add(root, name)
Control.set_allow_input(name, true)
Control.set_id(name, "human name info") Control.set_id(name, "human name info")
Globals["Game"].Focus.on_change(true) {|val| Globals["Game"].Focus.on_change(true) {|val|
var name_string = Human.get_name(val) || "-" var name_string = Human.get_name(val) || "-"
UISimpleText.set_text(name, name_string + "\n" + name_string) UISimpleText.set_text(name, name_string)
}
var adventures = UISimpleText.create(_ui)
Control.set_pos(adventures, 33, 10)
Control.child_add(root, adventures)
Control.set_id(name, "human adventure count")
Globals["Game"].Focus.on_change(true) {|val|
var count = Human.get_adventure_count(val)
var text = count ? "Adventures: %(count)" : ""
UISimpleText.set_text(adventures, text)
} }
} }
@ -158,7 +168,8 @@ class Ui{
UIImage.set_image(button, adventureButtons) UIImage.set_image(button, adventureButtons)
ImageButton.set_tooltip(button, "Info") ImageButton.set_tooltip(button, "Info")
ImageButton.set_tile_uv(button, tiles, [1, 0]) ImageButton.set_tile_uv(button, tiles, [1, 0])
ImageButton.set_state_change(button) { |data| ImageButton.set_state_change(button) { |data|
System.print("info button: %(data)")
if(data["press"]){ if(data["press"]){
ui_mode = Ui.Info ui_mode = Ui.Info
} }
@ -205,10 +216,6 @@ class Ui{
Control.set_pos(button, i*16, 0) //let list handle this in future Control.set_pos(button, i*16, 0) //let list handle this in future
return button return button
} }
test(){
ImageButton.get_data(_test)
}
} }
//this is behind the class def to make cyclic dependency happy lol //this is behind the class def to make cyclic dependency happy lol

View file

@ -1,4 +1,4 @@
import "luxe: game" for Game import "luxe: game" for Ready
import "luxe: input" for Input, Key import "luxe: input" for Input, Key
import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera import "luxe: world" for World, Entity, Transform, Sprite, Values, Tags, Camera
import "luxe: math" for Math import "luxe: math" for Math
@ -19,8 +19,9 @@ import "math/observable" for Observable
import "blocks/tooltip" for Tooltip import "blocks/tooltip" for Tooltip
import "blocks/human/human" for Human import "blocks/human/human" for Human
class game is Game { class Game is Ready {
construct ready() { construct ready() {
super("Cabin Game")
Globals["Game"] = this Globals["Game"] = this
_focus = Observable.new() _focus = Observable.new()
@ -53,8 +54,6 @@ class game is Game {
if(Input.key_state_pressed(Key.key_q)) { if(Input.key_state_pressed(Key.key_q)) {
_tooltip.cycle_size() _tooltip.cycle_size()
} }
_ui.test()
DrawDebug.commit() DrawDebug.commit()

View file

@ -11,7 +11,7 @@ class Util{
static material_from_image(image){ static material_from_image(image){
var material = Material.create("luxe: material_basis/sprite_pixelated") var material = Material.create("luxe: material_basis/sprite_pixelated")
Material.set_image(material, 0, image) Material.set_input(material, "sprite.image", image)
return material return material
} }

View file

@ -73,11 +73,8 @@ class App {
//update worlds //update worlds
World.tick_systems(_world, delta) World.tick(_world, delta)
World.tick_systems(_ui_world, delta) World.tick(_ui_world, delta)
World.tick_world(_world, delta)
World.tick_world(_ui_world, delta)
//render worlds //render worlds
render_empty("clear") render_empty("clear")

View file

@ -136,9 +136,10 @@ class Renderer {
} //ui_render_path } //ui_render_path
target_to_screen(ctx){ target_to_screen(ctx){
//{ library="luxe: shaders" function="vert_color_uv" }
var out_pass = PassLayerDesc.new() var out_pass = PassLayerDesc.new()
out_pass.library = "shaders/upscale" out_pass.fragment.library = "shaders/upscale"
out_pass.function = "upscale_top_center" out_pass.fragment.function = "upscale_top_center"
out_pass.targets = ["screen"] out_pass.targets = ["screen"]
out_pass.inputs = { out_pass.inputs = {
"pass.flipy" : true, "pass.flipy" : true,

View file

@ -3,7 +3,7 @@ engine = {
window = { window = {
width = 512 width = 512
height = 768 height = 768
resizable = true resizable = false
fullscreen = false fullscreen = false
} }
} }

View file

@ -1,8 +1,8 @@
import "luxe: project" for Project import "luxe: project" for Entry
class project is Project { class Project is Entry {
construct new(target) { construct entry(target) {
name = "Cabin Game" name = "Cabin Game"
version = "0.0.0" version = "0.0.0"

View file

@ -1,3 +1,3 @@
modules = { modules = {
luxe = "2020.2.0" luxe = "2020.3.0"
} //modules } //modules