rainbow friends
This commit is contained in:
parent
42ecec5e7f
commit
853d153fb6
7 changed files with 48 additions and 28 deletions
|
|
@ -27,7 +27,7 @@ class Human {
|
|||
//in the world and respond to them here.
|
||||
class HumanSystem is ModifierSystem {
|
||||
|
||||
player_start{[26, 90]}
|
||||
player_start{[26, 89]}
|
||||
player_size{[10, 12]}
|
||||
|
||||
construct new() {
|
||||
|
|
@ -59,7 +59,7 @@ class HumanSystem is ModifierSystem {
|
|||
//called usually once every frame.
|
||||
//called when the world that this modifier lives in, is ticked
|
||||
each {|entity, data|
|
||||
System.print("%(Transform.get_pos(entity))")
|
||||
|
||||
}
|
||||
} //tick
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ class HumanSystem is ModifierSystem {
|
|||
Sprite.destroy(entity)
|
||||
return
|
||||
}
|
||||
var pos = start
|
||||
var pos = Vector.new(start)
|
||||
pos.x = pos.x + size.x * i
|
||||
if(!Transform.has(entity)){
|
||||
Transform.create(entity)
|
||||
|
|
|
|||
|
|
@ -11,13 +11,12 @@ import "outline/app" for App
|
|||
import "outline/Renderer" for Renderer
|
||||
import "blocks/ui" for Ui
|
||||
import "blocks/debug" for DrawDebug, Holder
|
||||
import "globals" for Globals
|
||||
import "globals" for Globals, RandomInst
|
||||
import "math/vector" for Vector
|
||||
import "math/rect" for AABB
|
||||
import "math/util" for Util
|
||||
import "blocks/tooltip" for Tooltip
|
||||
import "blocks/human/human" for Human
|
||||
import "random" for Random
|
||||
|
||||
class game is Game {
|
||||
construct ready() {
|
||||
|
|
@ -39,9 +38,9 @@ class game is Game {
|
|||
|
||||
tick(delta) {
|
||||
var mouse_pos = Vector.new(Input.mouse_x(), Input.mouse_y())
|
||||
var game_mouse = Globals["Renderer"].game_mouse(mouse_pos)
|
||||
var game_mouse = [0, 0]//Globals["Renderer"].game_mouse(mouse_pos)
|
||||
Globals["GameMouse"] = Camera.screen_point_to_world(app.camera, game_mouse.x, game_mouse.y)
|
||||
var ui_mouse = Globals["Renderer"].ui_mouse(mouse_pos)
|
||||
var ui_mouse = [0, 0]//Globals["Renderer"].ui_mouse(mouse_pos)
|
||||
Globals["UiMouse"] = Camera.screen_point_to_world(app.ui_camera, ui_mouse.x, ui_mouse.y)
|
||||
|
||||
if(Input.key_state_released(Key.escape)) {
|
||||
|
|
@ -58,6 +57,7 @@ class game is Game {
|
|||
_tooltip.tick()
|
||||
|
||||
app.tick(delta)
|
||||
|
||||
} //tick
|
||||
|
||||
destroy() {
|
||||
|
|
@ -79,15 +79,15 @@ class game is Game {
|
|||
|
||||
create_human()
|
||||
create_human()
|
||||
create_human()
|
||||
create_human()
|
||||
}
|
||||
|
||||
create_human(){
|
||||
var human = Entity.create(app.world, "human")
|
||||
var humanMat = Util.material_from_image_path("assets/wip/Human")
|
||||
Human.create(human)
|
||||
System.print(Util.hsv(Random.new().float(), 1, 1))
|
||||
//var rand = Random.new().float()
|
||||
//Human.set_color(human, Util.hsv(rand, 1, 1))
|
||||
Human.set_color(human, Util.hsv(RandomInst.float(), 0.5, 1))
|
||||
}
|
||||
|
||||
app { _app }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import "random" for Random
|
||||
|
||||
|
||||
var RandomInst = Random.new()
|
||||
var Globals = {}
|
||||
|
|
@ -1,30 +1,49 @@
|
|||
import "math/vector" for Vector
|
||||
import "luxe: math" for Math
|
||||
import "math/repNum" for RepNum
|
||||
import "math/repVal" for RepVal
|
||||
import "math/Util" for Util
|
||||
|
||||
class M{
|
||||
static inv_lerp(from, to, inter){
|
||||
return (inter - from) / (to - from)
|
||||
static inv_lerp(from, to, value){
|
||||
//if the range are numbers, we assume the interpolation value is too
|
||||
if(from is Num && to is Num) return (value - from) / (to - from)
|
||||
//if only one of the range qualifiers is a sequence, we make the other one a endless sequence of itself
|
||||
//(will do a union to take the shortest length anyways)
|
||||
if(from is Sequence != to is Sequence) {
|
||||
if(from is Sequence){
|
||||
to = RepVal.new(to)
|
||||
} else {
|
||||
from = RepVal.new(from)
|
||||
}
|
||||
}
|
||||
//if the interpolation value is a number, make it infinite
|
||||
if(value is Num) value = RepVal.new(value)
|
||||
|
||||
var result = []
|
||||
Util.for_all([from, to, value]) { |v|
|
||||
result.add(lerp(v[0], v[1], v[2]))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
static lerp(from, to, value){
|
||||
//if the range are numbers, we assume the interpolation value is too
|
||||
if(from is Num && to is Num) return from + (to - from) * value
|
||||
//if only one of the range qualifiers is a sequence, we make the other one a endless sequence of itself
|
||||
//(will do a union to take the shortest length anyways)
|
||||
if(from is Sequence != to is Sequence) {
|
||||
if(from is Sequence){
|
||||
to = RepNum.new(to, from.count)
|
||||
to = RepVal.new(to)
|
||||
} else {
|
||||
from = RepNum.new(from, to.count)
|
||||
from = RepVal.new(from)
|
||||
}
|
||||
}
|
||||
if(value is Num) value = RepNum.new(value)
|
||||
|
||||
System.print("%(from.toList) %(to.toList)")
|
||||
//if the interpolation value is a number, make it infinite
|
||||
if(value is Num) value = RepVal.new(value)
|
||||
|
||||
var result = []
|
||||
Util.for_all([from, to, value]) { |from, to, value|
|
||||
System.print(from)
|
||||
result.add(lerp(from, to, value))
|
||||
Util.for_all([from, to, value]) { |v|
|
||||
result.add(lerp(v[0], v[1], v[2]))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
@ -47,8 +66,8 @@ class M{
|
|||
}
|
||||
if(min is Sequence && max is Sequence){
|
||||
var result = []
|
||||
Util.for_all([value, min, max]) { |value, min, max|
|
||||
result.add(clamp(value, min, max))
|
||||
Util.for_all([value, min, max]) { |v|
|
||||
result.add(clamp(v[0], v[1], v[2]))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
class RepNum is Sequence{
|
||||
class RepVal is Sequence{
|
||||
static new(value){
|
||||
return new(value, -1)
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ class Util{
|
|||
var iterators = List.filled(count, null)
|
||||
counter.each{|i| iterators[i] = sequences[i].iterate(iterators[i])}
|
||||
while(iterators.all{|iter| iter}){
|
||||
var values = (0...count).map{|i| sequences[i].iteratorValue(iterators[i])}
|
||||
var values = (0...count).map{|i| sequences[i].iteratorValue(iterators[i])}.toList
|
||||
fn.call(values)
|
||||
counter.each{|i| iterators[i] = sequences[i].iterate(iterators[i])}
|
||||
}
|
||||
|
|
@ -48,6 +48,6 @@ class Util{
|
|||
//and value
|
||||
col = col.map{|comp| comp * v}
|
||||
|
||||
return col.toList + [1] //poor womans add
|
||||
return col.toList + [1]
|
||||
}
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ class Vector is Sequence{
|
|||
|
||||
iterate(iter){
|
||||
if(!iter) return 0
|
||||
if(iter > 1) return null
|
||||
if(iter > 1) return false
|
||||
return iter + 1
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue