Created
October 4, 2019 20:39
-
-
Save starikcetin/de935cfc3b4180eef1f55cab596a5457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// container component | |
// a constructor is automatically generated for a component that has the same order with field declaration | |
// for example, for position component following ctor is generated: (x, y, z) | |
component position | |
float x | |
float y | |
float z | |
// component with single field | |
component float health | |
// tag component | |
tag component destroyed | |
// event definition | |
event damageTaken | |
float damage | |
// entity generation | |
entity newSpaceship | |
postion = (10, 5, 6) | |
health = 100 | |
// regular system | |
system positionSystem | |
// entity signature filters | |
all: position | |
any: x, y | |
none: z | |
// read component | |
pos = entity.position | |
// write component | |
entity.position = new pos | |
x: 5 | |
y: 4 | |
z: 3 | |
entity.position = pos + (1, 2, 3) | |
// this is also possible | |
entity.position.x = 10 | |
// this too | |
// if entity doesn't have a health, it will be added and then set | |
entity.health = 5 | |
// add component | |
add destroyed to entity | |
add foo to entity | |
bar: baz | |
// remove component | |
remove position from entity | |
// raise an event | |
raise damageTaken | |
// sender -> target | |
fooEntity -> barEntity | |
// values | |
damage: 5 | |
// reactive system | |
reactive system positionChangeSystem | |
// define which component this system reacts to | |
reacts to position | |
// entity signature filters | |
all: position | |
any: foo, bar | |
none: baz | |
oldPos = reaction.old | |
newPos = reaction.new | |
// event listener system | |
listener system damageTakenSystem | |
// define which event this system listens for | |
listens to damageTaken | |
// entity signature filters for the sender entity | |
sender: | |
all: position | |
// entity signature filters for the target entity | |
target: | |
all: position | |
// get the sender entity | |
sender = event.sender | |
// get the target entity | |
target = event.target | |
// read and operate on event values | |
origin.health -= event.damage | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, the gameplay semantics are way off, this is more of a primer for how such a language would look like.