Last active
December 21, 2015 16:59
-
-
Save PhilipWitte/6336992 to your computer and use it in GitHub Desktop.
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
# 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