A Good ‘Ol Fashioned Rumble! (Ten Liner)

Uh oh, looks like there’s a rumble! Use your cursor to either flee the scene, or stay and fight. When the circles get closer together, the screen flashes to give the effect of punches being thrown. The biggest challenge I faced for this assignment was getting each circle to move at a different rate. The method I ended up using allows the speed of a circle to be faster if it was drawn towards the end of the for loop.

 

##Will Taylor
## A Good 'Ol Fashioned Rumble (Ten Liner)
width, height = 400,400
radius = 10
circleXY = [[int(random(width)), int(random(height))],
[int(random(width)), int(random(height))],
[int(random(width)), int(random(height))],
[int(random(width)), int(random(height))],
[int(random(width)), int(random(height))],
[int(random(width)), int(random(height))],
[int(random(width)), int(random(height))],
[int(random(width)), int(random(height))],
[int(random(width)), int(random(height))],
[int(random(width)), int(random(height))]]
def setup():
size(width,height)
frameRate(32)

def draw():
background(255)
smooth()
strokeWeight(2)
stroke(0)


def checkMatch():
for i in xrange(len(circleXY)):
x = circleXY[i][0]
y = circleXY[i][1]
if (x == mouseX and y == mouseY):
background(0)
return True


def drawCircles():
rad = radius
for i in xrange(len(circleXY)):
if (i > len(circleXY)/2):
stroke(0)
fill(255)
else:
stroke(150)
fill(0)
ellipse(circleXY[i][0], circleXY[i][1], rad, rad);


def updateCircleX():
for i in xrange(len(circleXY)):
if (circleXY[i][0] > mouseX):
circleXY[i][0] -= int(2*(i+1)%4 + (i+1))
elif (circleXY[i][0] < mouseX):
circleXY[i][0] += int((i+2)%4 + (i+1))

def updateCircleY():
vChase = 1
for i in xrange(len(circleXY)):
if (circleXY[i][1] > mouseY):
circleXY[i][1] -= int(2*(i+1) - i)
elif (circleXY[i][1] < mouseY):
circleXY[i][1] += int(2*(i+1) - i)

def updateCircles():
updateCircleX()
updateCircleY()

drawCircles()

updateCircles()
checkMatch()

 

Comments are closed.