Beispiel #1
0
def check_collision(cells):
	global running
	for c1 in cells:
		for c2 in cells:
			if (c1 != c2 and collide(c1, c2)):
				print("collided")
				if(c1.get_radius()>c2.get_radius()):
					c2.goto(meet.get_random_x(),meet.get_random_y())
					c1.set_radius(c1.get_radius()+c2.get_radius()*0.1)
					if(c2 == user_cell):
						running = False
					elif(c1 == user_cell):
						meet.clear()
						meet.goto(-meet.get_screen_width(),meet.get_screen_height()-10);
						meet.write(user_cell.get_radius())
				elif(c1.get_radius()<c2.get_radius()):
					c1.goto(meet.get_random_x(),meet.get_random_y())
					c2.set_radius(c2.get_radius()+c1.get_radius()*0.1)
					if(c1 == user_cell):
						running = False
Beispiel #2
0
def eat(cells):
	global playing
	for i in cells:
		x=i.xcor()
		y=i.ycor()
		r=i.get_radius()

		for g in cells:
			x2=g.xcor()
			y2=g.ycor()
			r2=g.get_radius()
			if math.sqrt((x-x2)**2+(y-y2)**2)<=(r+r2):
				if r>r2:
					x3=meet.get_random_x()
					y3=meet.get_random_y()
					g.goto(x3, y3)
					i.set_radius(r+(r2/10))
					if g==user_cell:
						meet.write('you lose!', align="center", font=('Ariel',50,'bold'))
						meet.goto(0, -100)
						meet.write('click space to restart', align="center", font=('Ariel',40,'bold'))
						playing = False
						meet.goto(0, 200)
						while playing == False:
                                                        key = getch()
                                                        if key == Space:
                                                                playing = True 
						meet.onkeypress('Space')
						meet.listen()
		

				elif r<r2:
					x3=meet.get_random_x()
					y3=meet.get_random_y()
					i.goto(x3, y3)
					g.set_radius(r2+(r/10))
					if i==user_cell:
						meet.write('you lose!', align="center", font=('Ariel',50,'bold'))
						meet.goto(0, -100)
						meet.write('click space to restart', align="center", font=('Ariel',40,'bold'))
						playing = False
						meet.goto(0, 200)
						while playing == False:
                                                        key = getch()
                                                        if key == Space:
                                                                playing = True
						meet.onkeypress('Space')						
						meet.listen()