Skip to content
Browse files

Allow absolute direction to be absolute forward if option amount is g…

…iven (e.g. north 4 - go four north)
  • Loading branch information...
1 parent f35e325 commit e393270f18f99b675b21012a70cd10d4f0bc25d5 @enebo committed Jun 18, 2012
Showing with 37 additions and 7 deletions.
  1. +37 −7 examples/purogo.rb
View
44 examples/purogo.rb
@@ -48,14 +48,44 @@ def turnup(degrees); add_command "pitch", -degrees; end
def turndown(degrees); add_command "pitch", degrees; end
# Absolute directions
+ def up(amount=nil)
+ add_command "pitch", 270, true
+ forward amount if amount
+ end
+
+ def down(amount=nil)
+ add_command "pitch", 90, true
+ forward amount if amount
+ end
+
+ def horizontal(amount=nil)
+ add_command "pitch", 0, true
+ forward amount if amount
+ end
+
+ def north(amount=nil)
+ horizontal
+ add_command "yaw", NORTH, true
+ forward amount if amount
+ end
+
+ def east(amount=nil)
+ horizontal
+ add_command "yaw", EAST, true
+ forward amount if amount
+ end
- def up; add_command "pitch", 270, true; end
- def down; add_command "pitch", 90, true; end
- def horizontal; add_command "pitch", 0, true; end
- def north; horizontal; add_command "yaw", NORTH, true; end
- def east; horizontal; add_command "yaw", EAST, true; end
- def south; horizontal; add_command "yaw", SOUTH, true; end
- def west; horizontal; add_command "yaw", WEST, true; end
+ def south(amount=nil)
+ horizontal
+ add_command "yaw", SOUTH, true
+ forward amount if amount
+ end
+
+ def west(amount=nil)
+ horizontal
+ add_command "yaw", WEST, true
+ forward amount if amount
+ end
def render(interface, args)
begin

0 comments on commit e393270

Please sign in to comment.
Something went wrong with that request. Please try again.