Skip to content

Instantly share code, notes, and snippets.



Created Jan 13, 2012
What would you like to do?
Mockup of a game-oriented behavior modeling language
# mockup of a game-oriented behavior modeling language, v6 (1/13/2012)
# copyright (c) 2012 darkf
# define player as an object that is both movable, drawable and a rigid body (via tags)
player <- Object()
player is Movable, RigidBody, Drawable # three tags
tiles <- Array2D(64, 64) # 2-dimensional array of size 64x64 for holding map tiles
# Array2D is by default tagged with Iterable, Indexable
tiles is Drawable # add a Drawable tag so we can treat it as a game object
on sys:load do
tiles = magic.loadMapFromFile("") # this isn't important
on player:draw do
# we could simply define player with a tag of Circle, but that's not fun
c <- Circle(30) # circle object with radius of 30
c.pos = Vec2(20, 50) # center
c.color = Color(255, 0, 0) # red
emit c:draw
on screen:tick dt do
# update game logic (e.g. physics here)
player.pos += player.vel * dt
player.vel *= player.friction * dt
on tiles:draw do
# draw tiles
for y,x in tiles do
emit tiles[y][x]:draw
on screen:draw do
# draw game world
emit player:draw
emit tiles:draw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.