Another terrible game object DSL
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
# Objects are values with at least the methods {init, update, draw}. | |
# state describes properties shared by all game states. | |
# game states can transition into others, or call methods by others. | |
# there is a global event system that can emit (dispatch) events (by string), and catch (observe) them. | |
state { | |
player : player | |
objects : [Object] | |
} | |
gamestate Main { | |
init { transition Null } | |
} | |
gamestate Null { | |
init {} | |
update {} | |
draw {} | |
} | |
object Background { | |
im : image; | |
init { @im = Image.load("der.png") } | |
draw { @im.draw(); emit "bgdraw" } | |
on "npcdie" npc { text.draw("npc dead: " + npc.name) } | |
} | |
object NPC { | |
name : string; | |
init { @name = "foo"; } | |
update { | |
if @hp < 0 | |
emit "npcdie", self | |
@dead = true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment