Skip to content

Instantly share code, notes, and snippets.

@SpaceVoyager
Created July 18, 2015 19:54
Show Gist options
  • Save SpaceVoyager/70ca15fec61d962b9048 to your computer and use it in GitHub Desktop.
Save SpaceVoyager/70ca15fec61d962b9048 to your computer and use it in GitHub Desktop.
draw-animals.py
from scene import *
class MyScene (Scene):
rabbit_centers = []
wolf_centers = []
def setup(self):
# This will be called before the first frame is drawn.
pass
def draw(self):
print self.bounds.w
# This will be called for every frame (typically 60 times per second).
background(1,1,1)
# Draw a red circle for every finger that touches the screen:
fill(1, 0, 0)
stroke_weight(2)
stroke(0,0,0)
line(self.bounds.w/2, 0, self.bounds.w/2, self.bounds.h)
for location in self.rabbit_centers:
image('Rabbit_Face', location.x - 64, location.y - 64)
for location in self.wolf_centers:
image('Pig_Face', location.x - 64, location.y - 64)
def touch_began(self, touch):
if touch.location.x < 512-64:
self.rabbit_centers.append(touch.location)
if touch.location.x > 512+64:
self.wolf_centers.append(touch.location)
def touch_moved(self, touch):
pass
def touch_ended(self, touch):
pass
run(MyScene())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment