def Edge(cells): x,y=meet.get_user_direction(user_cell) user_cell.set_dx(x) user_cell.set_dy(y) for cell in cells: w=meet.get_screen_width() h=meet.get_screen_height() x=cell.xcor() y=cell.ycor() if (cell.xcor()>w): cell.set_dx(-cell.get_dx()) elif (cell.xcor()<-w): cell.set_dx(-cell.get_dx()) if (cell.ycor()>h): cell.set_dy(-cell.get_dy()) elif (cell.ycor()<-h): cell.set_dy(-cell.get_dy())
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()
import meet cells =[] x = 0 while x <10: a = {"radius":13 , "x":meet.get_random_x() , "y":meet.get_random_y() , "dx": 0.11 , "dy": 1 , "color": "black"} c= meet.create_cell(a) cells.append(c) x+=1 a = {"radius":13 , "x":0 , "y":0 , "dx": 0, "dy": 0 , "color": "black"} user= meet.create_cell(a) cells.append(user) while True : meet.move_cells(cells) for cell in cells: x=cell.xcor() y=cell.ycor() h= meet.get_screen_height() w = meet.get_screen_width() if (x>w or x<-w): cell.set_dx(-cell.get_dx()) if (y>h or y<-h): cell.set_dy(-cell.get_dy()) dx,dy = meet.get_user_direction(user) user.set_dx(dx) user.set_dy(dy)
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) while True: x, y = meet.get_user_direction(user_cell) user_cell.set_dx(x) user_cell.set_dy(y) meet.move_cells(cells) Edge(cells) Eating(cells) meet.mainloop()
if (y > sh): cell.set_dy(-cell.get_dy()) if (x < -sw): cell.set_dx(-cell.get_dx()) if (y < -sh): cell.set_dy(-cell.get_dy()) score=0 game=True while game: x,y = meet.get_user_direction(myCircle) myCircle.set_dx(x) myCircle.set_dy(y) borders(cells) meet.move_cells(cells) for cell2 in cells: if(cell2 != myCircle): myX=myCircle.xcor() myY=myCircle.ycor() myR=myCircle.radius x=cell2.xcor() y=cell2.ycor() r=cell2.get_radius() dist = ((myX - x)**2 + (myY - y)**2)**0.5 if dist <= (myR+r):
sw=meet.get_screen_width() sh=meet.get_screen_height() x=cell.xcor() y=cell.ycor() if (x > sw): cell.set_dx(-cell.get_dx()) if (y > sh): cell.set_dy(-cell.get_dy()) if (x < -sw): cell.set_dx(-cell.get_dx()) if (y < -sh): cell.set_dy(-cell.get_dy()) while True: x,y = meet.get_user_direction(circle1) circle1.set_dx(x) circle1.set_dy(y) borders(cells) meet.move_cells(cells) for cell2 in cells: if(cell2 != circle1): a=circle1.xcor() b=circle1.ycor() r=circle1.radius c=cell2.xcor() d=cell2.ycor() r2=cell2.get_radius() if((a-c)**2 + (b-d)**2)**0.5 <= (r+r2) : if(r>r2): cell2.goto(meet.get_random_x(),meet.get_random_y())
distance = ((x1 - x2)**2 + (y1 - y2)**2)**0.5 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()
for i in range(0, 10): cell1 = {"x":meet.get_random_x(), "y":meet.get_random_y(), "radius":meet.random.randint(2,50), "dy":random.random() , "dx":random.random(), "color":"pink"} z= create_cell(cell1) cells.append(z) agario1= {"x": meet.get_x_mouse(), "y": meet.get_y_mouse(), "radius": 50, "dy":0, "dx":0} agario = create_cell(agario1) agarios=[agario] def border(): right = meet.get_screen_width() left = -meet.get_screen_width() up = meet.get_screen_height() down = -meet.get_screen_height() for cell in cells: if cell.ycor()+cell.get_radius() >= up or cell.ycor()-cell.get_radius() <= down or cell.xcor()+cell.get_radius() >= right or cell.xcor()-cell.get_radius() <= left: cell.set_dx(-cell.get_dx()) cell.set_dy(-cell.get_dy()) while True : meet.move_cells(cells) meet.move_cells(agarios) dx,dy=meet.get_user_direction(agario) agario.set_dx(dx) agario.set_dy(dy) border() for c in cells: if agario.distance(c) < 20: turtle.bye()
def move_user_cell(user_cell): xdir,ydir = meet.get_user_direction(user_cell) user_cell.set_dy(ydir) user_cell.set_dx(xdir)