Skip to content

Instantly share code, notes, and snippets.

@PhilipWitte
Last active December 21, 2015 16:59
Show Gist options
  • Save PhilipWitte/6336992 to your computer and use it in GitHub Desktop.
Save PhilipWitte/6336992 to your computer and use it in GitHub Desktop.
# syntax:
# [key] <name> [attributes] [types]
type Sprite
{
var pos Vector
var rot Rotation
}
type Ship Sprite
{
def speed = 4.3
var damage = 0.0
init(.pos)
func update() important {
# keyboard controls...
case Keyboard.key(A).isPressed: pos.moveLeft(speed)
case Keyboard.key(D).isPressed: pos.moveRight(speed)
case Keyboard.key(W).isPressed: pos.moveForward(speed)
case Keyboard.key(S).isPressed: pos.moveBackward(speed)
}
}
type Hover Sprite
{
var distance = 1.3
init(.distance)
func update() after(important) {
# keep above ground...
...
}
}
init { # main
var basicShip = Ship(Vector.random(-5..5))
var hoverShip = Hover(2.2) Ship(Vector.zero)
basicShip.update() # just the keyboard controls
hoverShip.update() # keyboard controls + keep above ground
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment