Esempio n. 1
0
def display_side_panel(timer = None):
	"""
	Display the game side panel next to the board.
	"""
	pawns = gs.pawns

	display_timer(timer)
	timer_height = 80 + hauteur_texte()
	telekinesis_stock_height = timer_height

	for i, color in enumerate(pawns):
		if color.startswith("fake"):
			img = "guard"
		else:
			img = color

		y = timer_height + (i + 0.5) * (((gs.window_height - telekinesis_stock_height) - timer_height) / len(pawns))
		divs = gs.players_count + 2

		image(gs.game_width + ((gs.window_width - gs.game_width) / divs * (divs - 1)), y, f"./res/img/big_players/{img}.png", ancrage = "center")

		for j in range(gs.players_count):
			if gs.selected_colors[j] == color:
				image(gs.game_width + ((gs.window_width - gs.game_width) / divs * (j + 1)), y, f"./res/img/side_panel_selectors/selector{j + 1}.png", ancrage = "center")

		display_telekinesis_stock()
Esempio n. 2
0
def display_selected_vortex(coords):
	"""
	Display a circle at the given coordinates to show a selected cell.
	"""
	x = coords[1] * gs.game_width / len(gs.board[0])
	y = coords[0] * gs.game_height / len(gs.board)

	image(x, y, "./res/img/misc/circle.png", ancrage = "nw")
Esempio n. 3
0
def display_players():
	"""
	Display the players pawns and the guards on the board.
	"""
	for color in gs.pawns.keys():
		if color.startswith("fake"):
			img = "guard"
		else:
			img = color
		image(gs.pawns[color][1] * gs.cell_width, gs.pawns[color][0] * gs.cell_height, f"./res/img/players/{img}.png", ancrage = "nw")
Esempio n. 4
0
def display_escalators():
	"""
	Display the escalators on the board.
	"""
	offset_x, offset_y, ladder = None, None, None

	for (i1, j1), (i2, j2) in gs.escalators:
		# offset_x and offset_y are used to display the escalator in the right position
		for diff1, diff2, off_x, off_y, lad in {(2, 1, 1, -0.5, 1), (1, 2, 1.5, 0, 3), (-2, 1, 1, 1.5, 2), (2, -1, 0, -0.5, 2), (-1, -2, -0.5, 1, 3), (-2, -1, 0, 1.5, 1), (1, -2, -0.5, 0, 4), (-1, 2, 1.5, 1, 4), (1, 1, 1, 0, 0), (1, -1, 0, 0, 5), (-1, -1, 0, 1, 0), (-1, 1, 1, 1, 5)}:
			if i1 - i2 == diff1 and j2 - j1 == diff2:
				offset_x, offset_y, ladder = off_x, off_y, lad
				break

		image((j1 + offset_x) * gs.cell_width, (i1 + offset_y) * gs.cell_height, f"./res/img/ladders/{ladder}.png", ancrage = "center")
Esempio n. 5
0
def display_game_end(victory):
	"""
	Display a victory message in the middle of the screen if the victory parameter is set to True. Otherwise, display a defeat message.
	"""
	efface_tout()
	if victory:
		image(0, 0, "./res/img/misc/success_background.png", ancrage = "nw")
		color = "green"
		game_state = "gagné"
	else:
		color = "red"
		game_state = "perdu"
	texte(gs.window_width / 2, gs.window_height / 2, f"Vous avez {game_state} !", ancrage = "center", taille = 34, couleur = color)
	mise_a_jour()
	attente_clic()
Esempio n. 6
0
def display_save_loading_menu():
	"""
	Display the menu that allow to choose between starting a new game or loading a previously saved game. Return a list of coordinates as tuples that represent the clickable areas of the menu.
	"""
	efface_tout()
	image(gs.window_width / 2, gs.window_height / 3, "./res/img/misc/magic-maze.png", ancrage = "center")
	zones_coords = []

	for i, txt in enumerate(("Nouvelle partie", "Charger la sauvegarde")):
		x = gs.window_width / 3 * (i + 1)
		y = gs.window_height / 3 * 2.2
		text_width = longueur_texte(txt)
		text_height = hauteur_texte()

		texte(x, y, txt, ancrage = "center")
		zones_coords.append((x - text_width / 2 - 20, y - text_height / 2 - 20, x + text_width / 2 + 20, y + text_height / 2 + 20))
		rectangle(zones_coords[i][0], zones_coords[i][1], zones_coords[i][2], zones_coords[i][3], epaisseur = 2)
	mise_a_jour()
	return zones_coords
Esempio n. 7
0
def display_players_selection_menu():
	"""
	Display the menu that allow to choose the number of players that will play together. Return a list of coordinates as tuples that represent the clickable areas of the menu.
	"""
	efface_tout()
	image(gs.window_width / 2, gs.window_height / 3, "./res/img/misc/magic-maze.png", ancrage = "center")
	zones_coords = []

	for i in range(1, 4):
		if i > 1:
			text = f"{i} joueurs"
		else:
			text = "solo"
		text_width = longueur_texte(text)
		text_height = hauteur_texte()

		x = gs.window_width / 4 * i
		y = gs.window_height / 3 * 2.2
		texte(x, y, text, ancrage = "center")

		zones_coords.append((x - text_width / 2 - 20, y - text_height / 2 - 20, x + text_width / 2 + 20, y + text_height / 2 + 20))
		rectangle(zones_coords[i - 1][0], zones_coords[i - 1][1], zones_coords[i - 1][2], zones_coords[i - 1][3], epaisseur = 2)
	mise_a_jour()
	return zones_coords
Esempio n. 8
0
def display_cell(coords):
	"""
	Display the cell at the given coordinates to the screen.
	"""
	board = gs.board

	i, j = coords
	x, y = j * gs.cell_width, i * gs.cell_height

	if board[i][j] == "." or board[i][j] == "*" or board[i][j] == "e" or board[i][j] == "h" or board[i][j] == "µ" or board[i][j][0] == "a":
		if board[i][j] == "." or board[i][j] == "h" or board[i][j] == "µ" or board[i][j][0] == "a":
			color = "white"
		elif board[i][j] == "*":
			color = "grey"
		elif board[i][j] == "e":
			if gs.exit_available:
				color = "lightgreen"
			else:
				color = "white"
		else:
			color = "white"

		rectangle(x, y, x + gs.cell_width, y + gs.cell_height, remplissage = color)

		if board[i][j][0] == "a":
			for color in {"purple", "orange", "yellow", "green"}:
				if color[0] == board[i][j][1]:
					image(x, y, f"./res/img/explore/{color}.png", ancrage = "nw")

	vortex = set()
	if board[i][j][0] == "v":
		if not gs.exit_available:
			vortex = {("vp", "./vortex/purple"), ("vo", "./vortex/orange"), ("vy", "./vortex/yellow"), ("vg", "./vortex/green")}
		else:
			vortex = {(("vp", "vo", "vy", "vg"), "./vortex/grey")}

	for char, img in {("h", "./misc/hourglass"), ("µ", "./misc/used_hourglass"), ("e", "./misc/exit")}.union(vortex):
		if board[i][j] in char:
			image(x, y, f"./res/img/{img}.png", ancrage = "nw")

	else:
		objects = {"purple", "orange", "yellow", "green"}

		if not gs.exit_available:
			for obj in objects:
				if board[i][j] == obj[0]:
					image(x, y, f"./res/img/objects/{obj}.png", ancrage = "nw")
					break
		
		rectangle(x, y, x + gs.cell_width, y + gs.cell_height)
Esempio n. 9
0
def display_selected_card(top_left):
	"""
	Display a selector border to a card whose top left corner coordinates are passed as a parameter.
	"""
	image(top_left[1] * gs.cell_width, top_left[0] * gs.cell_height, "./res/img/misc/border.png", ancrage = "nw")