Skip to content

Instantly share code, notes, and snippets.

@nasser
Created July 26, 2012 23:52
Show Gist options
  • Save nasser/3185292 to your computer and use it in GitHub Desktop.
Save nasser/3185292 to your computer and use it in GitHub Desktop.
ard = Arduino.new
setup do
ard.setup do
name_analog 0, "lr"
name_analog 2, "ud"
end
end
def joy_x; ard.lr - width/2 end
def joy_y; height - (ard.ud - height/2) end
pts = []
draw do
image "http://images5.fanpop.com/image/photos/31400000/Cow-cows-31450223-350-350.jpg", 0, 0
fill false
circle joy_x, joy_y, 10
line joy_x - 20, joy_y, joy_x + 20, joy_y
line joy_x, joy_y - 20, joy_x, joy_y + 20
pts.each_pair do |a, b|
fill true
circle a.first, a.last, 3
circle b.first, b.last, 3
line a.first, a.last, b.first, b.last
end
end
key_down do |key|
if key == 'a'
pts << [joy_x, joy_y]
else
pts = []
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment