Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@darkf
Created January 13, 2012 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkf/1609389 to your computer and use it in GitHub Desktop.
Save darkf/1609389 to your computer and use it in GitHub Desktop.
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("magic.map") # this isn't important
end
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
end
on screen:tick dt do
# update game logic (e.g. physics here)
player.pos += player.vel * dt
player.vel *= player.friction * dt
end
on tiles:draw do
# draw tiles
for y,x in tiles do
emit tiles[y][x]:draw
end
end
on screen:draw do
# draw game world
emit player:draw
emit tiles:draw
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment