Skip to content

Instantly share code, notes, and snippets.

@darkf
Created May 17, 2012 02:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save darkf/2715825 to your computer and use it in GitHub Desktop.
Another terrible game object DSL
# 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