diff options
| author | Federico Igne <git@federicoigne.com> | 2022-11-04 22:36:20 +0000 |
|---|---|---|
| committer | Federico Igne <git@federicoigne.com> | 2022-11-04 22:36:20 +0000 |
| commit | c3e8f1aa591acf96bbda8ea6aa66f66433ff3866 (patch) | |
| tree | dd29ba0b6a0e119b2e401cc24dc87d92fd88cf05 | |
| parent | a953273e8069251d43e1c9464792fb70bebe8f57 (diff) | |
| download | raccoon-c3e8f1aa591acf96bbda8ea6aa66f66433ff3866.tar.gz raccoon-c3e8f1aa591acf96bbda8ea6aa66f66433ff3866.zip | |
feat: add metadata component
| -rw-r--r-- | raccoon.lua | 14 |
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 |
| 317 | end | 317 | end |
| 318 | 318 | ||
| 319 | |||
| 320 | local Metadata = Component() | ||
| 321 | function Metadata:init(name) | ||
| 322 | self.name = name or "Unnamed" | ||
| 323 | return self | ||
| 324 | end | ||
| 319 | local InputSystem = System(Input) | 325 | local InputSystem = System(Input) |
| 320 | function InputSystem:exec(entity) | 326 | function 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) | |||
| 529 | end | 535 | end |
| 530 | 536 | ||
| 531 | local player = Entity() | 537 | local 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 | ||
| 547 | local level1_entities = { | 554 | local 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)) |
