diff --git a/Luxe/blocks/human.wren b/Luxe/blocks/human.wren index 660a565..3ea0c06 100644 --- a/Luxe/blocks/human.wren +++ b/Luxe/blocks/human.wren @@ -1,6 +1,9 @@ import "luxe: world" for Entity, Transform, Sprite -import "globals" for Globals import "luxe: containers" for Lists +import "luxe: assets" for Strings +import "luxe: input" for Input, MouseButton + +import "globals" for Globals import "math/observable" for Observable import "math/vector" for Vector import "math/util" for Util @@ -62,6 +65,29 @@ class Human{ dispose(){ active = false } + + static tick(){ + var mouse = Globals["GameMouse"] + __activeHumans.value.each(){|human| + var entity = human.entity + var over = Sprite.contains(entity, mouse.x, mouse.y) + if(over && __hoverEnt != entity){ + __hoverEnt = entity + Globals["Tooltip"].set(Strings.get(human.name), entity) + } + if(!over && __hoverEnt == entity){ + __hoverEnt = null + Globals["Tooltip"].clear(entity) + } + + if(Input.mouse_state_pressed(MouseButton.left)){ + var game = Globals["Game"] + if(__hoverEnt){ //remove if statement to allow clicking away (probably needs extra code to allow ui clicking) + game.focus.value = __hoverEnt + } + } + } + } } var PlayerStart:Vector = Vector.new(26, 89) diff --git a/Luxe/blocks/human/human.wren b/Luxe/blocks/human/human.wren index 84634b9..1b01391 100644 --- a/Luxe/blocks/human/human.wren +++ b/Luxe/blocks/human/human.wren @@ -1,10 +1,11 @@ import "luxe: io" for IO import "luxe: world" for World, Entity, Modifiers, ModifierSystem, Transform, Sprite +import "luxe: assets" for Strings +import "luxe: input" for Input, MouseButton + import "math/vector" for Vector import "math/util" for Util import "globals" for Globals -import "luxe: assets" for Strings -import "luxe: input" for Input, MouseButton //User facing API //This is what the user of your modifier will interact with diff --git a/Luxe/game.wren b/Luxe/game.wren index f291c37..d852919 100644 --- a/Luxe/game.wren +++ b/Luxe/game.wren @@ -57,6 +57,7 @@ class Game is Ready { DrawDebug.commit() _tooltip.tick() _adventures.tick() + Human.tick() app.tick(delta)