aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Igne <git@federicoigne.com>2022-11-04 22:36:20 +0000
committerFederico Igne <git@federicoigne.com>2022-11-04 22:36:20 +0000
commitc3e8f1aa591acf96bbda8ea6aa66f66433ff3866 (patch)
treedd29ba0b6a0e119b2e401cc24dc87d92fd88cf05
parenta953273e8069251d43e1c9464792fb70bebe8f57 (diff)
downloadraccoon-c3e8f1aa591acf96bbda8ea6aa66f66433ff3866.tar.gz
raccoon-c3e8f1aa591acf96bbda8ea6aa66f66433ff3866.zip
feat: add metadata component
-rw-r--r--raccoon.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/raccoon.lua b/raccoon.lua
index c777c1d..ed0eaa2 100644
--- a/raccoon.lua
+++ b/raccoon.lua
@@ -316,6 +316,12 @@ function Particles:spawn(pos, entities)
316 end 316 end
317end 317end
318 318
319
320local Metadata = Component()
321function Metadata:init(name)
322 self.name = name or "Unnamed"
323 return self
324end
319local InputSystem = System(Input) 325local InputSystem = System(Input)
320function InputSystem:exec(entity) 326function InputSystem:exec(entity)
321 local input = entity.get_component[Input] 327 local input = entity.get_component[Input]
@@ -529,6 +535,7 @@ function ParticlesSystem:exec(entity, game)
529end 535end
530 536
531local player = Entity() 537local player = Entity()
538 :with_component(Metadata("Giulia"))
532 :with_component(Pos(100,10)) 539 :with_component(Pos(100,10))
533 :with_component(Movement()) 540 :with_component(Movement())
534 :with_component(Jump(10)) 541 :with_component(Jump(10))
@@ -545,9 +552,10 @@ local player = Entity()
545 nil)) 552 nil))
546 553
547local level1_entities = { 554local level1_entities = {
548 Entity():with_component(Pos(16*8,11*8)):with_component(Sprite(272)), 555 -- Turists
549 Entity():with_component(Pos(47*8, 8*8)):with_component(Sprite(272)), 556 Entity():with_component(Metadata("Tourist1")):with_component(Pos(16*8,11*8)):with_component(Sprite(272)):with_component(Movement()),
550 Entity():with_component(Pos(85*8, 7*8)):with_component(Sprite(272)), 557 Entity():with_component(Metadata("Tourist2")):with_component(Pos(47*8, 8*8)):with_component(Sprite(272)):with_component(Movement()),
558 Entity():with_component(Metadata("Tourist3")):with_component(Pos(85*8, 7*8)):with_component(Sprite(272)):with_component(Movement()),
551 -- Waypoints 559 -- Waypoints
552 Entity():with_component(Pos(15*8,11*8)):with_component(Sprite(288)) 560 Entity():with_component(Pos(15*8,11*8)):with_component(Sprite(288))
553 :with_component(PosAnim(function(t,p) p.y = p.y - math.sin(t/6)/3 end)) 561 :with_component(PosAnim(function(t,p) p.y = p.y - math.sin(t/6)/3 end))