Example #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)
Example #2
0
def collison():
	for cell in cells:
		for cell2 in cells:
			if(((cell.xcor()-cell2.xcor())**2+(cell.ycor()-cell2.ycor())**2)**0.5 ) < cell.get_radius() + cell2.get_radius():
				if (cell.get_radius() < cell2.get_radius()):
					cell.goto(meet.get_random_x(),meet.get_random_y())
					cell2.set_radius(cell2.get_radius()+1)
					if cell==user_cell:
						exit()
				if (cell.get_radius() > cell2.get_radius()):
					cell2.goto(meet.get_random_x(),meet.get_random_y())
					cell.set_radius(cell.get_radius()+1)
					if cell2==user_cell:
						exit()
Example #3
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()
Example #4
0
def eat_cells(cell):
	global exit
	for cell in cells:
		for cell2 in cells:
			x1 = cell.xcor()
			x2 = cell2.xcor()
			y1 = cell.ycor()
			y2 = cell2.ycor()
			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'))
Example #5
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.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
Example #6
0
def user_collision(cells):
	global user_cell, PLAYING
	for cell in cells:
		if user_cell.distance(cell) <= user_cell.get_radius() + cell.get_radius():
			if user_cell.get_radius() > cell.get_radius():
				user_cell.set_radius(user_cell.get_radius()+cell.get_radius()/6)
				cell.goto(meet.get_random_x(), meet.get_random_y())
				cell.set_radius(meet.random.randint(2,40))
			elif cell.get_radius() > user_cell.get_radius():
				PLAYING = False
				print("game over! :(")
Example #7
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
Example #8
0
def collision(cells):
	global user_cell, PLAYING
	for cell in cells:
		
		for boy in cells:

			if cell.distance(boy) <= cell.get_radius() + boy.get_radius():
				if cell.get_radius() > boy.get_radius():
					cell.set_radius(cell.get_radius()+boy.get_radius()/6)
					boy.goto(meet.get_random_x(), meet.get_random_y())
					boy.set_radius(meet.random.randint(2,40))
					if boy == user_cell:
						PLAYING= False
						print("game over, loser!")
				elif boy.get_radius() > cell.get_radius():
					boy.set_radius(boy.get_radius()+cell.get_radius()/6)
					cell.goto(meet.get_random_x(), meet.get_random_y())
					cell.set_radius(meet.random.randint(2,40))
					if cell == user_cell:
						PLAYING= False
						print("game over, loser!")
Example #9
0
def Collision(cells):
	for i in cells:
		for j in cells:
			if(abs(j.ycor()-i.ycor())<i.get_radius()/2):
				if(abs(j.xcor()-i.xcor())<i.get_radius()/2):
					if (i.get_radius()>j.get_radius()):
						if j == user_cell:
							exit()
						i.set_radius(j.get_radius()/2+i.get_radius())
						j.set_radius(random.uniform(3,10))
						j.goto(meet.get_random_x(),meet.get_random_y())
						j.set_dy(random.uniform(-1.00,2.00))
						j.set_dx(random.uniform(-1.00,2.00))
						meet.move_cell(j)
						
					elif(j.get_radius()>i.get_radius()):
						if i == user_cell:
							exit()
						j.set_radius(i.get_radius()/2+j.get_radius())
						i.set_radius(random.uniform(3,10))
						i.goto(meet.get_random_x(),meet.get_random_y())
						i.set_dy(random.uniform(-1.00,2.00))
						i.set_dx(random.uniform(-1.00,2.00))
						meet.move_cell(i)
Example #10
0
def collision(cells):
	global playing
	for i in cells:
		for j in cells:
			distance=((i.xcor()-j.xcor())**2 + (i.ycor()-j.ycor())**2)**0.5
			if distance<=i.get_radius() + j.get_radius():
				if i.get_radius()>j.get_radius():
					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()
Example #11
0
	move_cells(cells)
	limits(cells)
	dx,dy = get_user_direction(t)
	t.set_dx(dx)
	t.set_dy(dy)
	for i in cells:
		r=i.get_radius()
		x=i.xcor()
		y=i.ycor()
		for g in cells:
			r2=g.get_radius()
			x2=g.xcor()
			y2=g.ycor()
			if((x-x2)**2+ (y-y2)**2)**0.5 <= (r-r2):
				if(r > r2):
					g.goto(get_random_x(),meet.get_random_y())
					i.set_radius(r + r2*0.3)
				else: 
					pass#exit()	

						
					
				#else :
					#g.bye()		 

meet.mainloop()




	
Example #12
0
from meet import *
import meet
cells = []
i = 0
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.randint(-250,250) , "dx":random.randint(-400,400)}
	z= create_cell(cell1)
	cells.append(z)

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 :			
	border()
	move_cells(cells)
Example #13
0
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)
Example #14
0
                        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):
                            if (cell2 == badCircle):
                                score -=2
                                turtle.clear()
                                turtle.color("black")
                                turtle.penup()
                                turtle.goto(-270.0,250.0)
                                turtle.write("score:"+ str(score), align='center',font=('ariel',25,'bold'))
                                turtle.hideturtle()
                                badCircle.goto(meet.get_random_x(),meet.get_random_y())

                            elif (myR > r):
                                 cell2.goto(meet.get_random_x(),meet.get_random_y())
                                 myCircle.set_radius(myR+(r/39))
                                 if (cell2 != badCircle):
                                     score+=1
                                     turtle.clear()
                                     turtle.color("black")
                                     turtle.penup()
                                     turtle.goto(-270.0,250.0)
                                     turtle.write("score:"+ str(score), align='center',font=('ariel',25,'bold'))
                                     turtle.hideturtle()

                            else:
                                  turtle.color("red")                                       
Example #15
0
import meet
import random

PLAYING = True

cells=[]

user_cell={'radius':10, 'x':0, 'y':0, 'dx':0, 'dy':0, 'color': 'blue'}

for i in range(0,20):

	cells1= {'radius':meet.random.randint(2,20), 'x':meet.get_random_x(), 'y':meet.get_random_y(), 'dx':random.randint(-30,30)/100.0, 'dy':random.randint(-30,30)/100.0}
	cells1=meet.create_cell(cells1)
	cells.append(cells1)

user_cell=meet.create_cell(user_cell)
cells.append(user_cell)

def border(cells):
	for cell in cells:
		if cell.ycor() > meet.get_screen_height() or cell.ycor() < -meet.get_screen_height():
			cell.set_dy(-cell.get_dy()*1.01)
		if cell.xcor() > meet.get_screen_width() or cell.xcor() < -meet.get_screen_width():
			cell.set_dx(-cell.get_dx()*1.01)

def collision(cells):
	global user_cell, PLAYING
	for cell in cells:
		
		for boy in cells:
Example #16
0
from meet import *
import meet

cells=[]
colors=['red','green','yellow','black','pink','orange']
for i in range(0,20):
	cell= {'x':meet.get_random_x(), 'y':meet.get_random_y(), 'radius':random.randint(5,50), 'dx':random.uniform(0.1,2), 'dy':random.uniform(0.1,2),'color':random.choice(colors)}
	a=create_cell(cell)
	cells.append(a)
user_cell={'x': meet.get_x_mouse(),'y': meet.get_y_mouse(),'radius': 20,'dx': 0,'dy': 0,'color':'blue'}
user=create_cell(user_cell)
users=[user]

def borders():
	w1=meet.get_screen_width()
	w2=-meet.get_screen_width()
	h1=meet.get_screen_height()
	h2=-meet.get_screen_height()
	for cell in cells:
		if cell.ycor()+cell.get_radius()>=h1 or cell.ycor()<=h2:
			cell.set_dy(-cell.get_dy())
		if cell.xcor()+cell.get_radius()>=w1 or cell.xcor()<=w2:
			cell.set_dx(-cell.get_dx())


while True:
	meet.move_cells(cells)
	meet.move_cells(users)
	dx,dy=meet.get_user_direction(user)
	user.set_dx(dx)
	user.set_dy(dy)
Example #17
0
    random_color = (r,g,b)
    radius= random.randint(10,40)
    xdirection= random.randint(0,1)
    ydirection= random.randint(2,3)
    speed = 25
    if xdirection== 0:
        _dx= -radius/ speed
    if xdirection==1:
        _dx= radius/ speed
    if ydirection==2:
        _dy= radius/ speed
    if ydirection==3:
        _dy= -radius/ speed

        
    cell1={'x':meet.get_random_x(),'y':meet.get_random_y(),'radius':radius,'dx':_dx,'dy':_dy, 'color':random_color}
    a= create_cell(cell1)
    cells.append(a)
user= {"x":meet.get_x_mouse(), "y":meet.get_y_mouse(),"radius":25, "dx":_dx,"dy":_dy}
user= create_cell(user)
cells.append(user)
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.xcor() + cell.get_radius() >= right:
            cell.set_dx(-cell.get_dx())
        if cell.xcor() - cell.get_radius() <= left:
            cell.set_dx(-cell.get_dx())
Example #18
0
import meet
import random
user_cell_dictionary={"radius":30,"x":6,"y":6,"dy":1,"dx":1,"color":"yellow"}

cells=[]


x=0
while x<24:
	x+=1
	ball3={"radius":random.randint(3,10),"x":meet.get_random_x(),"y":meet.get_random_y(),"dy":1,"dx":1}

	circle3 = meet.create_cell(ball3)
	cells.append(circle3)
	


user_cell=meet.create_cell(user_cell_dictionary)
cells.append(user_cell)





def Edge(cells):
	h=meet.get_screen_width() 
	w=meet.get_screen_height() 
	for cell in cells:
		if cell.xcor() + cell.get_radius() >= h:
			x=cell.get_dx()
			cell.set_dx(-x)
Example #19
0
from meet import *
import meet
import math
import random
cells = []
i = 0
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)
Example #20
0
		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())
					circle1.set_radius(r+0.25*r2)
				else:
					exit()



meet.mainloop()