Beispiel #1
0
def draw_objects():
	for f in food:
		palgame.draw_circle(palgame.get_x(f), palgame.get_y(f), palgame.get_radius(f), BLUE)
	for i, b in enumerate(cells):
		if i == 0:
			color = GREEN
		else:
			color = RED
		palgame.draw_circle(palgame.get_x(b), palgame.get_y(b), palgame.get_radius(b), color)
Beispiel #2
0
def update_cell_position(cell, speed):
	x = palgame.get_x(cell)
	y = palgame.get_y(cell)
	xdir = palgame.get_xdir(cell)
	ydir = palgame.get_ydir(cell)

	if x > SCREEN_WIDTH or x < 0:
		xdir = -1 * xdir
	if y > SCREEN_HEIGHT or y < 0:
		ydir = -1 * ydir
	x = x + xdir * speed
	y = y + ydir * speed

	palgame.set_x(cell, x)
	palgame.set_y(cell, y)
	palgame.set_xdir(cell, xdir)
	palgame.set_ydir(cell, ydir)
Beispiel #3
0
def cells_collide(cell1, cell2):
	if ( abs(palgame.get_x(cell2) - palgame.get_x(cell1)) < (palgame.get_radius(cell2) + palgame.get_radius(cell1))
		and abs(palgame.get_y(cell2) - palgame.get_y(cell1)) < (palgame.get_radius(cell2) + palgame.get_radius(cell1)) ):
		return True
	else:
		return False
Beispiel #4
0
def update_user_cell_position(cell):
	vx, vy = palgame.get_user_direction(palgame.get_x(cell), palgame.get_y(cell), palgame.get_radius(cell))
	new_x = palgame.get_x(cell) + vx
	palgame.set_x(cell, new_x)
	new_y = palgame.get_y(cell) + vy
	palgame.set_y(cell, new_y)