Skip to content

Instantly share code, notes, and snippets.

@dgellow
Last active August 29, 2015 14:24
Show Gist options
  • Save dgellow/c0d7a1a172ebe6ddbeff to your computer and use it in GitHub Desktop.
Save dgellow/c0d7a1a172ebe6ddbeff to your computer and use it in GitHub Desktop.
proc makeJumpPlayerCommand(player: var Player,
platform: Platform): Command =
var
moveActorCommand = makeMoveActorCommand(player, platform.x,
platform.y)
if not isStrongEnough(player.jumpStrength, platform.altitude):
echo("$1 is not strong enough to jump to the platform" % [player.name])
return nil # <== Error: type mismatch: got (nil) but expected 'Command'
result.execute = proc =
moveActorCommand.execute()
result.undo = proc =
moveActorCommand.undo()
var
player = getPlayer()
player = getPlatform()
command = makeJumpPlayerCommand(player, platform)
if command:
command.execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment