Added pixel texture element
This commit is contained in:
+6
-4
@@ -96,7 +96,7 @@ end
|
||||
# for entities it does similarly
|
||||
# mouse state can be read in systems always
|
||||
|
||||
query = tag(:enemy) & component(:health, true) & anti(name("Trap Preview", true))
|
||||
query = Query.from(tag(:enemy) & component(:health, true) & anti(name("Trap Preview", true)))
|
||||
# in the match name will return just the one entity
|
||||
# tag and componet return list-like tables but they will be parallel and in order
|
||||
# empty columns will be filled with nil (not possible if only & is used)
|
||||
@@ -105,7 +105,7 @@ query = tag(:enemy) & component(:health, true) & anti(name("Trap Preview", true)
|
||||
|
||||
world.system :health_regen, for: query do |match, dt| # no trigger means always
|
||||
# example of a simple health regeneration system that regenerates health for all entities with a health component
|
||||
healths = match[0]
|
||||
healths = query.get[0] # get the first component in the query, in this case health, this will be a list of all health components for entities that match the query
|
||||
healths.add_scalar! :health, 1 * dt
|
||||
healths.clamp! :health, 0, 100
|
||||
end
|
||||
@@ -136,12 +136,14 @@ world.system :trap_placement, trigger: trigger do |dt|
|
||||
end
|
||||
end
|
||||
|
||||
name_query = Query.from(name("Trap Preview", true) & component(:sprite, true))
|
||||
|
||||
# could be done as so or
|
||||
world.system :trap_preview, for: name("Trap Preview", true) do |match, dt| # example from teh game mist trying to be made with this engine
|
||||
world.system :trap_preview do |match, dt| # example from teh game mist trying to be made with this engine
|
||||
# do trap placement logic when a trap is held
|
||||
return unless world.holding_trap?
|
||||
# show a preview of the trap at the mouse position, you can use the mouse position relative to the world for this
|
||||
e = match.first
|
||||
e = name_query.get[0] # get the first entity that matches the name query, in this case the trap preview entity, this will be nil if no entity matches
|
||||
e.position = world.mouse_position_world
|
||||
e.active = true # enable the trap preview entity to show it at the mouse position
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user