Пример #1
0
def Eating(cells):
	for cell in cells:	
		for cell2 in cells:
			if cell!=cell2:
				min_d = cell.get_radius()+cell2.get_radius()
				d = ((cell.xcor()-cell2.xcor())**2+(cell.ycor()-cell2.ycor())**2)**0.5
				if d<min_d:
					if cell.get_radius()>cell2.get_radius():
						if cell2==user_cell:
							turtle.pensize(50)
							turtle.write("Game Over!")
							meet.mainloop()
						x=meet.get_random_x()
						y=meet.get_random_y()
						cell2.goto(x,y)
						r = cell.get_radius() + 0.2 * cell2.get_radius() 
						cell.set_radius(r)
					if cell2.get_radius()>cell.get_radius():
						if cell==user_cell:
							turtle.pensize(50)
							turtle.write("Game Over!")
							meet.mainloop()
						x=meet.get_random_x()
						y=meet.get_random_y()
						cell.goto(x,y)
						r = cell2.get_radius() + 0.2 * cell.get_radius()
						cell2.set_radius(r)
Пример #2
0
					i.set_radius(i.get_radius() + 2)
					x=meet.get_random_x()
					y=meet.get_random_y()
					j.goto(x,y)
				if i == user_cell1 and i.get_radius()<j.get_radius():
					turtle.write('Game Over',align='center',font=('ariel',50,'bold'))
					time.sleep(3)
					turtle.bye()

meet.move_cells(cells)
turtle.write('3',align='center',font=('ariel',70,'bold'))
time.sleep(1)
turtle.clear()
turtle.write('2',align='center',font=('ariel',70,'bold'))
time.sleep(1)
turtle.clear()
turtle.write('1',align='center',font=('ariel',70,'bold'))
time.sleep(1)
turtle.clear()

 
                                               
while playing:
	meet.move_cells(cells)
	borders(cells)
	collision(cells)
	xdir,ydir = meet.get_user_direction(user_cell1)
	user_cell1.set_dx(xdir)
	user_cell1.set_dy(ydir)
meet.mainloop()
Пример #3
0
			r1 = cell.get_radius()
			r2 = cell2.get_radius()
			min_d = r1 + r2
			if distance < min_d:
				if (r1 > r2):
					cell2.goto(meet.get_random_x(),meet.get_random_y())
					r1 = r1 + r2/10
					cell.set_radius(r1)
					if cell2 == user_cell:
						exit = False
						print("game over")
						turtle.write('Game Over' , align='center', font=('ariel',50,'bold'))
					if user_cell.radius > 75:
						exit = False
						print("You Win")
						turtle.write('You Win' , align='center', font=('ariel',50,'bold'))


while exit:
	x,y = meet.get_user_direction(user_cell)
	user_cell.set_dx(x)
	user_cell.set_dy(y)
	meet.move_cells(cells)

	check_x_border(cells)	
	check_y_border(cells)
	
	eat_cells(cells)

meet.mainloop()