Example #1
0
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())	
Example #2
0
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())
Example #3
0
def Edge(cells):
	for cell in cells:
		if cell.xcor() + cell.get_radius()>meet.get_screen_width():
			cell.set_dx(-cell.get_dx())
		if cell.xcor() + cell.get_radius()<-meet.get_screen_width():
			cell.set_dx(-cell.get_dx())
		if cell.ycor() + cell.get_radius()>meet.get_screen_height():
			cell.set_dy(-cell.get_dy())
		if cell.ycor() + cell.get_radius()<-meet.get_screen_height():
			cell.set_dy(-cell.get_dy())
Example #4
0
def check_walls(cells):
    for cell in cells:
        # print (str(cell.xcor()) + ", " +str(cell.ycor()) + " " + str(meet.get_screen_width()) + " " + str(meet.get_screen_height()))
        # if(cell != user_cell):
        if (
            cell.xcor() + cell.get_radius() > meet.get_screen_width()
            or cell.xcor() - cell.get_radius() < -meet.get_screen_width()
        ):
            cell.set_dx(-cell.get_dx())

        if (
            cell.ycor() + cell.get_radius() > meet.get_screen_height()
            or cell.ycor() - cell.get_radius() < -meet.get_screen_height()
        ):
            cell.set_dy(-cell.get_dy())
Example #5
0
def check_border(cells):
	for cell in cells:
		width = meet.get_screen_width()
		height=meet.get_screen_height()
		if cell.xcor() > width or cell.xcor() < -width:
			h1 = cell.get_dx()
			cell.set_dx(-h1)
		if cell.ycor() > height or cell.ycor() < -height:
			h2 = cell.get_dy()
			cell.set_dy(-h2)
Example #6
0
def borders(cells):
	for cell in cells:
		width = meet.get_screen_width()
		height = meet.get_screen_height()
		x = cell.xcor()
		y = cell.ycor()
		if (x > width):
			cell.set_dx(-cell.get_dx())
		if (x < -width):
			cell.set_dx(-cell.get_dx())
		if (y > height):
			cell.set_dy(-cell.get_dy())
		if (y < -height):
			cell.set_dy(-cell.get_dy())
Example #7
0
def borders(cells):
	for cell in cells:		
		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())
Example #8
0
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)
		elif cell.xcor() - cell.get_radius()<= -h:
			x=cell.get_dx()
			cell.set_dx(-x)
		if cell.ycor() + cell.get_radius() >= w:
			y=cell.get_dy()
			cell.set_dy(-y)
		elif cell.ycor() - cell.get_radius() <= -w:
			y=cell.get_dy()
			cell.set_dy(-y)
Example #9
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 #10
0
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())
Example #11
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 #12
0
def check_x_border(cells):
	width = meet.get_screen_width()
	for cell in cells:
		if cell.xcor() > width or cell.xcor() < -width:
			h1 = cell.get_dx()
			cell.set_dx(-h1)
Example #13
0
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)
Example #14
0
	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! :(")
				
#if (int(boy.xcor()+boy.get_radius())>=int(cell.xcor()-cell.get_radius()) and int(boy.xcor()-boy.get_radius())<=int(cell.xcor()+cell.get_radius())) and (int(boy.ycor()+boy.get_radius())>=int(cell.ycor()-cell.get_radius()) and int(boy.ycor()-boy.get_radius())<=int(cell.ycor()+cell.get_radius())):




while PLAYING:
	meet.move_cells(cells)
	x,y=meet.get_user_direction(user_cell)
	if user_cell.ycor() > meet.get_screen_height() or user_cell.ycor() < -meet.get_screen_height():
		print("")
	elif user_cell.xcor() > meet.get_screen_width() or user_cell.xcor() < -meet.get_screen_width():
		print("")
	else:
		user_cell.set_dx(x)
		user_cell.set_dy(y)
	border(cells)
	collision(cells)
	#user_collision(cells)