just uploaded the game on github
This commit is contained in:
2020-12-06 13:16:28 +01:00
parent 6f4be0b8d5
commit 14871022ab
24 changed files with 939 additions and 0 deletions

12
Sounds.py Normal file
View File

@@ -0,0 +1,12 @@
import pygame
from pygame.locals import *
pygame.mixer.pre_init(48000, -16, 2, 512)
pygame.init()
pygame.mixer.set_num_channels(16)
def get_sounds():
sounds = {"circle": pygame.mixer.Sound("assets/sounds/button_click.wav"),
"click": pygame.mixer.Sound("assets/sounds/circle_placed.wav")}
return sounds

1
assets/save Normal file
View File

@@ -0,0 +1 @@
Yes u found the save file congrats.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
assets/textures/icon.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

BIN
assets/textures/sheet.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
assets/textures/wasd.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

283
fast_and_trash.py Normal file
View File

@@ -0,0 +1,283 @@
import math
import random
import pygame
from pygame.locals import *
pygame.init()
def distance_indicator(cords1, cords2):
x_distance = abs(cords1[0] - cords2[0])
y_distance = abs(cords1[1] - cords2[1])
distance = math.sqrt((x_distance ** 2) + (y_distance ** 2))
return round(distance, 4)
def area_intersection_of_circles(points, radius_list):
try:
dist = distance_indicator(points[0], points[1])
alpha_cos = (pow(radius_list[1], 2) + pow(dist, 2) - pow(radius_list[0], 2)) / (2 * radius_list[1] * dist)
alpha = math.acos(alpha_cos)
beta_cos = (dist - alpha_cos * radius_list[1]) / radius_list[0]
beta = math.acos(beta_cos)
triangles = (alpha_cos * pow(radius_list[1], 2) * math.sin(alpha)) + (
beta_cos * pow(radius_list[0], 2) * math.sin(beta))
arcs = ((math.pi * pow(radius_list[0], 2) * beta * 2) / math.tau) + (
(math.pi * pow(radius_list[1], 2) * alpha * 2) / math.tau)
return arcs - triangles
except:
return False
class Circle:
def __init__(self, radius, center, colorX, color_value):
self.radius = radius
self.center = center
self.color = colorX
self.color_value = color_value
def draw(self, display, scroll):
sur = pygame.Surface((self.radius * 2, self.radius * 2))
pygame.draw.circle(sur, self.color_value, [self.radius, self.radius], self.radius)
sur.set_alpha(self.color_value.a)
sur.set_colorkey((0, 0, 0))
display.blit(sur, [-self.radius + self.center[0] - scroll.scroll[0],
-self.radius + self.center[1] - scroll.scroll[1]])
class Game:
def __init__(self):
self.alive = True
self.circles = []
self.c_template = {"color": "red",
"radius": random.randint(30, 50),
"pos": pygame.mouse.get_pos()}
self.colors = get_colors()
self.color_names = list(self.colors.keys())
self.ended_on_own_will = False
# scroll
self.aditional_scroll = [0, 0]
# consts
self.midpoint = [450, 300]
# for gravity
self.base_limit = 1000
self.limit = 1000
self.black = None
self.collapse = False
# points
self.points = 0
def add_circle(self, pos, radius, colorX, color_value, scroll):
new_pos = [pos[0] + scroll.scroll[0], pos[1] + scroll.scroll[1]]
self.circles.append(Circle(radius, new_pos, colorX, color_value))
def disp_circles(self, display, scroll):
for circle in self.circles:
circle.draw(display, scroll)
def get_new_circle_template(self):
self.c_template = get_circle_template(self.color_names)
def draw_template(self, display):
sur = pygame.Surface((self.c_template["radius"] * 2, self.c_template["radius"] * 2))
pygame.draw.circle(sur, self.colors[self.c_template["color"]],
[self.c_template["radius"],
self.c_template["radius"]], self.c_template["radius"])
sur.set_alpha(self.colors[self.c_template["color"]].a)
sur.set_colorkey((0, 0, 0))
display.blit(sur, [-self.c_template["radius"] + self.c_template["pos"][0],
-self.c_template["radius"] + self.c_template["pos"][1]])
def get_gravity(self):
final_value = [0, 0]
for circle in self.circles:
dist = distance_indicator(circle.center, self.midpoint)
angle = find_angle_between_points(circle.center, self.midpoint)
final_value[0] += round(math.cos(angle) * dist, 2) * (circle.radius/20)
final_value[1] += round(math.sin(angle) * dist, 2) * (circle.radius/20)
dist = distance_indicator(self.midpoint, [final_value[0] + self.midpoint[0], final_value[1] + self.midpoint[1]])
if dist > self.limit:
self.collapse = True
self.alive =False
elif dist > self.limit * 0.6:
self.black.color_value.r = round((dist - (self.limit * 0.6)) * (255 / (self.limit * 0.4)))
if self.black.color_value.r > 255:
self.black.color_value.r = 255
else:
self.black.color_value.r = 0
return final_value
# must be called before add circle
def update_points(self, pos, radius, colorX):
collided = []
multiplier = 1
for circle in self.circles:
dist = distance_indicator(circle.center, pos)
if dist < (radius + circle.radius):
collided.append(circle)
for circle in collided:
area = area_intersection_of_circles([pos, circle.center], [circle.radius, radius])
if colorX == "green":
multiplier = 1.1
elif colorX == "yellow":
multiplier = 1.2
elif colorX == "purple":
multiplier = 2
elif colorX == "smaragd":
multiplier = 4
self.points += (area // 10) * multiplier
def update_lim(self):
self.limit = self.base_limit + (self.points / 10)
def rotate_around_mid(self):
for circle in self.circles:
if circle.color != "black":
dist = distance_indicator(circle.center, self.midpoint)
angle = find_angle_between_points(self.midpoint, circle.center)
angle -= 0.005
angle = round(angle, 3)
circle.center = [self.midpoint[0] + (math.cos(angle) * dist),
self.midpoint[1] + (math.sin(angle) * dist)]
class Scroll:
def __init__(self, scroll):
self.scroll = scroll
self.fade = 20
self.safe_fade = 20
self.in_progress = False
self.save_scroll = self.scroll
def move_scroll(self, player, screen, which, space=20):
if which == "y" or which == "both":
self.scroll[1] += (player.rect.y - self.scroll[1] - (screen[1] / 2) + (player.size[1] / 2)) / space
self.scroll[1] = int(self.scroll[1])
if which == "x" or which == "both":
self.scroll[0] += (player.rect.x - self.scroll[0] - (screen[0] / 2) + (player.size[0] / 2)) / space
self.scroll[0] = int(self.scroll[0])
def add_scroll(self, which, how_much, fade=None):
if fade is not None:
self.safe_fade = fade
if self.in_progress is False:
self.load_safe_fade()
self.save_scroll = self.scroll
self.in_progress = True
how_much[0] /= self.fade
how_much[1] /= self.fade
self.fade += 0.01 * self.fade
if which == "x" or which == "both":
self.scroll[0] += how_much[0]
self.scroll[0] = round(self.scroll[0])
if which == "y" or which == "both":
self.scroll[1] += how_much[1]
self.scroll[1] = round(self.scroll[1])
def load_safe_fade(self):
self.fade = self.safe_fade
self.in_progress = False
def get_colors():
colors = {"red": pygame.Color(255, 0, 0, 125), # weight 16
"blue": pygame.Color(0, 0, 220, 125), # weight 20
"green": pygame.Color(0, 220, 0, 125), # weight 20
"yellow": pygame.Color(252, 239, 56, 125), # weight 22
"purple": pygame.Color(105, 0, 158, 125), # weight 4
"smaragd": pygame.Color(0, 214, 168, 125)} # weight 1
return colors
def get_random_color():
colors = []
colors = add_to_list("red", 20, colors)
colors = add_to_list("blue", 20, colors)
colors = add_to_list("green", 20, colors)
colors = add_to_list("yellow", 18, colors)
colors = add_to_list("purple", 4, colors)
colors = add_to_list("smaragd", 1, colors)
return colors[random.randint(0, len(colors)-1)]
def get_circle_template():
template = {"color": get_random_color(),
"radius": random.randint(10, 50),
"pos": pygame.mouse.get_pos()}
return template
def add_to_list(what, amount, listx):
for i in range(amount):
listx.append(what)
return listx
def find_angle_between_points(center, point):
dists = distances(center, point)
try:
angle = math.atan(dists[1] / dists[0])
if point[0] < center[0]:
if point[1] < center[1]:
return angle + math.pi
else:
return (math.pi / 2 - angle) + (math.pi / 2)
else:
if point[1] < center[1]:
return (math.pi / 2 - angle) + 3 * (math.pi / 2)
else:
return angle
except ZeroDivisionError:
return False
def distances(cords1, cords2):
return [abs(cords1[0] - cords2[0]), abs(cords1[1] - cords2[1])]
def get_circle(color_value, radius):
sur = pygame.Surface((radius * 2, radius * 2))
pygame.draw.circle(sur, color_value, [radius, radius], radius)
sur.set_alpha(color_value.a)
sur.set_colorkey((0, 0, 0))
return sur
def get_gravity_sur(gravity, limit):
ratio = limit/40
sur = pygame.Surface((100, 100))
pygame.draw.circle(sur, (200, 200, 200), [50, 50], 40)
pygame.draw.circle(sur, (217, 24, 114), [50 + (gravity[0] / ratio), 50 + (gravity[1] / ratio)], 10)
sur.set_alpha(200)
sur.set_colorkey((0, 0, 0))
return sur
def rotate(center, pos, angleX):
dist = distance_indicator(center, pos)
angle = find_angle_between_points(center, pos)
angle += angleX
return [center[0] + (math.cos(angle) * dist), center[1] + (math.sin(angle) * dist)]

4
garbage.py Normal file
View File

@@ -0,0 +1,4 @@
import numpy as np
array = np.linspace(20, 42, num=4)
print(array)

135
mouse_engine.py Normal file
View File

@@ -0,0 +1,135 @@
import math
from fast_and_trash import *
import pygame
class Mouse:
points = 0
def __init__(self, mouse_pos):
self.mouse_pos = mouse_pos
def update(self, Win_size, Default_size):
self.mouse_pos = pygame.mouse.get_pos()
self.mouse_pos = [round(self.mouse_pos[0] * (Default_size[0] / Win_size[0])),
round(self.mouse_pos[1] * (Default_size[1] / Win_size[1]))]
def in_circle(self, circle_cords, radius):
if distance_indicator(self.mouse_pos, circle_cords) < radius:
return True
else:
return False
def check_availability(self, color_name, radius, game, scroll):
scrolled_pos = [self.mouse_pos[0] + scroll.scroll[0],
self.mouse_pos[1] + scroll.scroll[1]]
collided = []
for circle in game.circles:
dist = distance_indicator(circle.center, scrolled_pos)
if dist < (radius + circle.radius):
if dist < radius or dist < circle.radius:
return False
collided.append(circle)
if collided:
# if u try placing red circle
if color_name == "red":
for circle in collided:
if circle.color == "purple":
return False
return True
# if u try placing blue circle
if color_name == "blue":
usable = False
for circle in collided:
if circle.color not in ["black", "smaragd", "red"]:
return False
else:
usable = True
if usable:
return True
else:
return False
# if u try placing green circle
if color_name == "green":
usable = [False, False]
for circle in collided:
if circle.color not in ["black", "smaragd", "red", "blue"]:
return False
elif circle.color in ["black", "smaragd"]:
usable = [True, True]
elif circle.color == "red":
usable[0] = True
else:
usable[1] = True
if usable[0] and usable[1]:
return True
else:
return False
# if u try placing yellow circle
if color_name == "yellow":
usable = [False, False]
for circle in collided:
if circle.color not in ["red", "green", "black", "smaragd"]:
return False
elif circle.color in ["black", "smaragd"]:
usable = [True, True]
elif circle.color == "red":
usable[0] = True
else:
usable[1] = True
if usable[0] and usable[1]:
return True
else:
return False
# if u try placing purple circle
if color_name == "purple":
usable = [False, False, False, False]
for circle in collided:
if circle.color not in ["red", "blue", "green", "yellow", "black", "smaragd"]:
return False
elif circle.color in ["black", "smaragd"]:
usable = [True, True, True, True]
elif circle.color == "red":
usable[0] = True
elif circle.color == "blue":
usable[1] = True
elif circle.color == "green":
usable[2] = True
else:
usable[3] = True
if usable[0] and usable[1] and usable[2] and usable[3]:
return True
else:
return False
# if u try placing smaragd circle
if color_name == "smaragd":
usable = False
for circle in collided:
if circle.color not in ["purple", "black"]:
return False
else:
usable = True
if usable:
return True
else:
return False
else:
return False

BIN
planetio.exe Normal file
View File

Binary file not shown.

504
planetio.py Normal file
View File

@@ -0,0 +1,504 @@
from fast_and_trash import *
from Sounds import *
from mouse_engine import *
import pygame
import sys
from pygame.locals import *
# basic config
pygame.mixer.pre_init(48000, -16, 2, 512)
pygame.init()
pygame.mixer.set_num_channels(16)
font = pygame.font.SysFont('Comic Sans MS', 80)
small_font = pygame.font.SysFont('Comic Sans MS', 40)
tiny_font = pygame.font.SysFont('Comic Sans MS', 20)
Window_size = [900, 600]
Default_size = Window_size
screen = pygame.display.set_mode(Window_size)
display = pygame.Surface((900, 600))
pygame.display.set_caption("Planetio")
pygame.display.set_icon(pygame.image.load("assets/textures/icon.png"))
clock = pygame.time.Clock()
sounds = get_sounds()
def menu(screenX, fs, Win_size):
# preparations
alive = True
gravity_button = [pygame.image.load("assets/textures/gravity_not_nonhover.png").convert(),
pygame.image.load("assets/textures/gravity_not_hover.png").convert(),
pygame.image.load("assets/textures/gravity_do_nonhover.png").convert(),
pygame.image.load("assets/textures/gravity_do_hover.png").convert()]
g_index = 0
sheets = [pygame.image.load("assets/textures/sheet.png").convert(),
pygame.image.load("assets/textures/sheet_cheat.png").convert(),
pygame.image.load("assets/textures/sheet_pressed.png").convert(),
pygame.image.load("assets/textures/sheet_cheat_pressed.png").convert()]
sheets[0].set_colorkey((0, 0, 0))
sheets[1].set_colorkey((0, 0, 0))
sheets[2].set_colorkey((0, 0, 0))
sheets[3].set_colorkey((0, 0, 0))
s_index = 0
# values to pass
setup = {"rotate": True,
"gravity": False,
"cheatsheet": True}
# mouse
mouse = Mouse([0, 0])
colorX = (0, 0, 0)
rotate_color = (0, 0, 0)
r_circle_cords = [730, 500]
# checking if tutorial
file = open("assets/save", "r")
place = file.read()
file.close()
if place == "tutorial":
screenX, fs, Win_size = tutorial(screenX, fs, Win_size)
file = open("assets/save", "w")
file.write("Yes u found the save file congrats.")
file.close()
# game loop
while alive:
display.fill((255, 255, 255))
# event loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
mouse.update(Win_size, Default_size)
# setting actions for buttons
if mouse.in_circle([450, 300], 50):
sounds["click"].play(0)
run_game(screenX, fs, setup, Win_size)
if mouse.in_circle([700, 500], 20):
sounds["click"].play(0)
setup["rotate"] = not setup["rotate"]
if mouse.in_circle([107, 375], 17):
sounds["click"].play(0)
setup["gravity"] = not setup["gravity"]
if mouse.in_circle([743, 140], 35):
sounds["click"].play(0)
setup["cheatsheet"] = not setup["cheatsheet"]
if event.type == pygame.MOUSEMOTION:
# if mouse moving get mouse pos
mouse.update(Win_size, Default_size)
if mouse.in_circle([450, 300], 50):
colorX = (100, 100, 100)
else:
colorX = (0, 0, 0)
if mouse.in_circle([700, 500], 20):
rotate_color = (80, 80, 80)
else:
rotate_color = (0, 0, 0)
if mouse.in_circle([107, 375], 17):
if setup["gravity"]:
g_index = 1
else:
g_index = 3
else:
if setup["gravity"]:
g_index = 0
else:
g_index = 2
if mouse.in_circle([743, 140], 35):
s_index = 1
else:
s_index = 0
if event.type == KEYDOWN:
if event.key == K_f:
fs = not fs
if fs is False:
Win_size = Default_size
screenX = pygame.display.set_mode(Win_size)
else:
screenX = pygame.display.set_mode(Win_size, pygame.FULLSCREEN)
d = pygame.display.get_surface()
Win_size = [d.get_width(), int((d.get_width()*2)/3)]
elif event.key == K_ESCAPE:
pygame.quit()
sys.exit()
# making menu
pygame.draw.circle(display, colorX, [450, 300], 50)
pygame.draw.circle(display, rotate_color, [700, 500], 20)
pygame.draw.circle(display, (126, 189, 43), r_circle_cords, 10)
if setup["rotate"]:
r_circle_cords = rotate([700, 500], r_circle_cords, -0.01)
display.blit(gravity_button[g_index], [40, 300])
# sheets
if setup["cheatsheet"]:
display.blit(sheets[1 + (s_index * 2)], [700, 100])
else:
display.blit(sheets[0 + (s_index * 2)], [700, 100])
# basic loop config
screenX.blit(pygame.transform.scale(display, Win_size), (0, 0))
pygame.display.update()
clock.tick(60)
def run_game(screenX, fs, setup, Win_size):
# basics
mouse = Mouse([0, 0])
mouse.update(Win_size, Default_size)
game = Game()
scroll = Scroll([0, 0])
game.add_circle([450, 300], 40, "black", pygame.Color(10, 10, 10, 255), scroll)
game.black = game.circles[0]
# indicator
indicator_colors = [pygame.Color(230, 73, 25, 150), pygame.Color(165, 230, 25, 150)]
indicators = [get_circle(indicator_colors[0], 30), get_circle(indicator_colors[1], 30)]
allowed = None
# exit button
exit_buttons = [get_circle(pygame.Color(1, 1, 1, 200), 20), get_circle(pygame.Color(255, 0, 0, 200), 20)]
endex = 0
# wasd tutorial
wasd = pygame.image.load("assets/textures/wasd.png").convert()
wasd.set_colorkey((0, 0, 0))
wasd_timer = 0
# cheatsheet
cheatsheet = pygame.image.load("assets/textures/cheatsheet.png").convert()
cheatsheet.set_colorkey((0, 0, 0))
cheatsheet.set_alpha(180)
while game.alive:
display.fill((255, 255, 255))
# circles stuff
game.disp_circles(display, scroll)
game.draw_template(display)
if setup["rotate"]:
game.rotate_around_mid()
# mouse checking
mouse.update(Win_size, Default_size)
game.c_template["pos"] = mouse.mouse_pos
if setup["rotate"]:
if mouse.check_availability(game.c_template["color"], game.c_template["radius"], game, scroll):
allowed = True
else:
allowed = False
# indicator & sensor
if allowed:
display.blit(indicators[1], [830, 530])
else:
display.blit(indicators[0], [830, 530])
if setup["gravity"]:
sensor = get_gravity_sur(game.get_gravity(), game.limit)
display.blit(sensor, [10, 490])
# exit button
display.blit(exit_buttons[endex], [850, 10])
# wasd tutorial
if setup["cheatsheet"]:
if wasd_timer < 255:
wasd.set_alpha(255 - wasd_timer)
wasd_timer += 2
display.blit(wasd, [50, 260])
# and cheatsheet
if setup["cheatsheet"]:
display.blit(cheatsheet, [0, 5])
# scroll stuff
scroll.scroll[0] += game.aditional_scroll[0]
scroll.scroll[1] += game.aditional_scroll[1]
# event loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.MOUSEBUTTONDOWN:
if mouse.check_availability(game.c_template["color"], game.c_template["radius"], game, scroll):
game.update_points([mouse.mouse_pos[0] + scroll.scroll[0],
mouse.mouse_pos[1] + scroll.scroll[1]], game.c_template["radius"],
game.c_template["color"])
# command above must run before u add circle
game.add_circle(mouse.mouse_pos, game.c_template["radius"], game.c_template["color"],
game.colors[game.c_template["color"]], scroll)
game.c_template = get_circle_template()
sounds["circle"].play(0)
if setup["gravity"]:
game.update_lim()
if mouse.in_circle([870, 30], 20):
game.alive = False
game.ended_on_own_will = True
sounds["click"].play(0)
elif event.type == pygame.MOUSEMOTION:
if setup["rotate"] is False:
if mouse.check_availability(game.c_template["color"], game.c_template["radius"], game, scroll):
allowed = True
else:
allowed = False
if mouse.in_circle([870, 30], 20):
endex = 1
else:
endex = 0
elif event.type == KEYDOWN:
if event.key == K_f:
fs = not fs
if fs is False:
Win_size = Default_size
screenX = pygame.display.set_mode(Win_size)
else:
screenX = pygame.display.set_mode(Win_size, pygame.FULLSCREEN)
d = pygame.display.get_surface()
Win_size = [d.get_width(), int((d.get_width() * 2) / 3)]
elif event.key == K_ESCAPE:
return screenX, fs, Win_size
elif event.key == K_r:
return screenX, fs, Win_size
# managing scroll
elif event.key == K_s:
game.aditional_scroll[1] += 10
elif event.key == K_w:
game.aditional_scroll[1] -= 10
elif event.key == K_a:
game.aditional_scroll[0] -= 10
elif event.key == K_d:
game.aditional_scroll[0] += 10
elif event.type == KEYUP:
# just scroll
if event.key == K_s:
game.aditional_scroll[1] -= 10
elif event.key == K_w:
game.aditional_scroll[1] += 10
elif event.key == K_a:
game.aditional_scroll[0] += 10
elif event.key == K_d:
game.aditional_scroll[0] -= 10
# basic loop config
screenX.blit(pygame.transform.scale(display, Win_size), (0, 0))
pygame.display.update()
clock.tick(60)
if game.collapse or game.ended_on_own_will:
# setting up
display.fill((255, 255, 255))
if game.collapse:
game.black.color_value.r = 255
game.disp_circles(display, scroll)
screenX.blit(pygame.transform.scale(display, Win_size), (0, 0))
pygame.display.update()
# ending
if game.collapse:
screenX, fs, Win_size = end(screenX, fs, Win_size, game, "collapse")
else:
screenX, fs, Win_size = end(screenX, fs, Win_size, game, "ignore")
return screenX, fs, Win_size
def end(screenX, fs, Win_size, game, reason):
# prep work
game.alive = True
mouse = Mouse([0, 0])
mouse.update(Win_size, Default_size)
# bg
sur = pygame.Surface((800, 500))
sur.fill((0, 0, 0))
sur.set_alpha(20)
display.blit(sur, [50, 50])
# loading objects
title = font.render("Game ended.", False, (40, 40, 40))
reason_text = None
if reason == "collapse":
reason_text = tiny_font.render("planet collapsed", False, (40, 40, 40))
circles = small_font.render(f"Circles placed : {len(game.circles)-1}", False, (40, 40, 40))
points = small_font.render(f"Points collected : {round(game.points)}", False, (40, 40, 40))
# menu button
button_colors = [pygame.Color(60, 60, 60, 150), pygame.Color(160, 160, 160, 150)]
menu_buttons = [get_circle(button_colors[0], 30), get_circle(button_colors[1], 30)]
menu_index = 0
while game.alive:
mouse.update(Win_size, Default_size)
# bliting text
display.blit(title, [200, 100])
if reason == "collapse":
display.blit(reason_text, [350, 200])
display.blit(circles, [80, 320])
display.blit(points, [80, 420])
display.blit(menu_buttons[menu_index], [770, 470])
# event loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
elif event.type == KEYDOWN:
if event.key == K_f:
fs = not fs
if fs is False:
Win_size = Default_size
screenX = pygame.display.set_mode(Win_size)
else:
screenX = pygame.display.set_mode(Win_size, pygame.FULLSCREEN)
d = pygame.display.get_surface()
Win_size = [d.get_width(), int((d.get_width() * 2) / 3)]
elif event.key == K_ESCAPE:
return screenX, fs, Win_size
elif event.type == MOUSEBUTTONDOWN:
if mouse.in_circle([800, 500], 30):
sounds["click"].play(0)
return screenX, fs, Win_size
elif event.type == MOUSEMOTION:
if mouse.in_circle([800, 500], 30):
menu_index = 1
else:
menu_index = 0
# basic loop config
screenX.blit(pygame.transform.scale(display, Win_size), (0, 0))
pygame.display.update()
clock.tick(60)
def tutorial(screenX, fs, Win_size):
menu_buttons = pygame.transform.scale(pygame.image.load("assets/textures/tutorial/menu_buttons.png").convert(),
[400, 400])
full_s = small_font.render("F = FULLSCREEN", False, (0, 0, 0))
colorX = (10, 10, 10)
mouse = Mouse([0, 0])
mouse.update(Win_size, Default_size)
alive = True
while alive:
mouse.update(Win_size, Default_size)
# drawing things
display.fill((255, 255, 255))
display.blit(menu_buttons, [50, 40])
display.blit(full_s, [50, 470])
pygame.draw.circle(display, colorX, [700, 300], 40)
# event loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
elif event.type == KEYDOWN:
if event.key == K_f:
fs = not fs
if fs is False:
Win_size = Default_size
screenX = pygame.display.set_mode(Win_size)
else:
screenX = pygame.display.set_mode(Win_size, pygame.FULLSCREEN)
d = pygame.display.get_surface()
Win_size = [d.get_width(), int((d.get_width()*2)/3)]
elif event.key == K_ESCAPE:
return screenX, fs, Win_size
elif event.type == MOUSEMOTION:
if mouse.in_circle([700, 300], 40):
colorX = (80, 80, 80)
else:
colorX = (10, 10, 10)
elif event.type == MOUSEBUTTONDOWN:
if mouse.in_circle([700, 300], 40):
return screenX, fs, Win_size
# basic loop config
screenX.blit(pygame.transform.scale(display, Win_size), (0, 0))
pygame.display.update()
clock.tick(60)
menu(screen, False, Window_size)
# pip install pygame==2.0.0.dev16