Created
January 15, 2012 01:04
-
-
Save darkf/1613682 to your computer and use it in GitHub Desktop.
mockup program 2
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
# mockup of a game-oriented behavior modeling language, v1 (1/14/2012) | |
# copyright (c) 2012 darkf | |
playership <- Sprite(Vec2(64, 64)) # 64x64 sprite | |
enemyship <- Sprite(Vec2(64, 64)) | |
projectiles <- List() # dynamic list | |
on playership:collide b do | |
if b is? enemyship do | |
# collided with enemy ship | |
end | |
end | |
on sys:load do | |
playership.loadImageFrom("player.png") | |
enemyship.loadImageFrom("enemy.png") | |
end | |
on screen:tick dt do | |
playership.pos += playership.vel * dt | |
enemyship.pos += enemyship.vel * dt | |
for p in projectiles do | |
p.pos += p.vel * dt | |
end | |
end | |
on input:keydown key do | |
if key is? KeySpace do | |
# shoot | |
p <- Projectile(mouse.getpos()) | |
projectiles.add(p) | |
end | |
if key is? KeyLeft do | |
playership.rotation -= 1 | |
end | |
if key is? KeyRight do | |
playership.rotation += 1 | |
end | |
if key is? KeyUp do | |
# too lazy to think about the math, but this is about right ;) | |
playership.vel.x += math.cos(playership.rotation) | |
playership.vel.y += math.sin(playership.rotation) | |
end | |
end | |
on screen:draw do | |
emit playership:draw | |
emit enemyship:draw | |
for p in projectiles do | |
emit p:draw | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment