haha
cc
This commit is contained in:
parent
14871022ab
commit
d61d7a1b1f
BIN
__pycache__/Sounds.cpython-39.pyc
Normal file
BIN
__pycache__/Sounds.cpython-39.pyc
Normal file
Binary file not shown.
BIN
__pycache__/fast_and_trash.cpython-39.pyc
Normal file
BIN
__pycache__/fast_and_trash.cpython-39.pyc
Normal file
Binary file not shown.
BIN
__pycache__/mouse_engine.cpython-39.pyc
Normal file
BIN
__pycache__/mouse_engine.cpython-39.pyc
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
Yes u found the save file congrats.
|
1
assets/save.json
Normal file
1
assets/save.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
BIN
assets/textures/load.png
Normal file
BIN
assets/textures/load.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 594 B |
BIN
assets/textures/load_hover.png
Normal file
BIN
assets/textures/load_hover.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 565 B |
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
@ -1,3 +1,4 @@
|
||||
import json
|
||||
import math
|
||||
import random
|
||||
import pygame
|
||||
@ -160,6 +161,44 @@ class Game:
|
||||
circle.center = [self.midpoint[0] + (math.cos(angle) * dist),
|
||||
self.midpoint[1] + (math.sin(angle) * dist)]
|
||||
|
||||
# saving & loading
|
||||
def save(self, path, setup):
|
||||
|
||||
save = {"gravity": setup["gravity"],
|
||||
"next_circle": self.c_template,
|
||||
"limit": self.limit,
|
||||
"points": self.points,
|
||||
"circles": []}
|
||||
|
||||
for circle in self.circles:
|
||||
save["circles"].append({"radius": circle.radius,
|
||||
"center": circle.center,
|
||||
"color": circle.color,
|
||||
"color_value": str(circle.color_value)})
|
||||
|
||||
del save["circles"][0]
|
||||
|
||||
with open(path, "w") as f:
|
||||
json.dump(save, f, indent=4)
|
||||
|
||||
def load(self, path, setup):
|
||||
|
||||
with open(path, "r") as f:
|
||||
save = json.load(f)
|
||||
|
||||
setup["gravity"] = save["gravity"]
|
||||
|
||||
self.c_template = save["next_circle"]
|
||||
|
||||
for circle in save["circles"]:
|
||||
self.circles.append(Circle(circle["radius"], circle["center"], circle["color"],
|
||||
pygame.Color(eval(circle["color_value"]))))
|
||||
|
||||
self.points = save["points"]
|
||||
self.limit = save["limit"]
|
||||
|
||||
return setup
|
||||
|
||||
|
||||
class Scroll:
|
||||
def __init__(self, scroll):
|
||||
|
BIN
planetio.exe
BIN
planetio.exe
Binary file not shown.
126
planetio.py
126
planetio.py
@ -1,4 +1,3 @@
|
||||
from fast_and_trash import *
|
||||
from Sounds import *
|
||||
from mouse_engine import *
|
||||
import pygame
|
||||
@ -16,6 +15,7 @@ tiny_font = pygame.font.SysFont('Comic Sans MS', 20)
|
||||
|
||||
Window_size = [900, 600]
|
||||
Default_size = Window_size
|
||||
monitor_size = [pygame.display.Info().current_w, pygame.display.Info().current_h]
|
||||
screen = pygame.display.set_mode(Window_size)
|
||||
display = pygame.Surface((900, 600))
|
||||
pygame.display.set_caption("Planetio")
|
||||
@ -44,11 +44,18 @@ def menu(screenX, fs, Win_size):
|
||||
sheets[3].set_colorkey((0, 0, 0))
|
||||
s_index = 0
|
||||
|
||||
load = [pygame.image.load("assets/textures/load.png").convert(),
|
||||
pygame.image.load("assets/textures/load_hover.png").convert()]
|
||||
for item in load:
|
||||
item.set_colorkey((0, 0, 0))
|
||||
l_index = 0
|
||||
|
||||
# values to pass
|
||||
|
||||
setup = {"rotate": True,
|
||||
"gravity": False,
|
||||
"cheatsheet": True}
|
||||
"cheatsheet": True,
|
||||
"load": False}
|
||||
|
||||
# mouse
|
||||
|
||||
@ -57,17 +64,6 @@ def menu(screenX, fs, Win_size):
|
||||
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))
|
||||
@ -83,10 +79,20 @@ def menu(screenX, fs, Win_size):
|
||||
mouse.update(Win_size, Default_size)
|
||||
|
||||
# setting actions for buttons
|
||||
if mouse.in_circle([200, 120], 50):
|
||||
with open("assets/save.json", "r") as f:
|
||||
file = json.load(f)
|
||||
|
||||
if file != {}:
|
||||
setup["load"] = True
|
||||
sounds["click"].play(0)
|
||||
screenX, fs, Win_size = run_game(screenX, fs, setup, Win_size)
|
||||
|
||||
setup["load"] = False
|
||||
|
||||
if mouse.in_circle([450, 300], 50):
|
||||
sounds["click"].play(0)
|
||||
run_game(screenX, fs, setup, Win_size)
|
||||
screenX, fs, Win_size = run_game(screenX, fs, setup, Win_size)
|
||||
|
||||
if mouse.in_circle([700, 500], 20):
|
||||
sounds["click"].play(0)
|
||||
@ -130,6 +136,11 @@ def menu(screenX, fs, Win_size):
|
||||
else:
|
||||
s_index = 0
|
||||
|
||||
if mouse.in_circle([200, 120], 50):
|
||||
l_index = 1
|
||||
else:
|
||||
l_index = 0
|
||||
|
||||
if event.type == KEYDOWN:
|
||||
if event.key == K_f:
|
||||
fs = not fs
|
||||
@ -137,9 +148,9 @@ def menu(screenX, fs, Win_size):
|
||||
Win_size = Default_size
|
||||
screenX = pygame.display.set_mode(Win_size)
|
||||
else:
|
||||
screenX = pygame.display.set_mode(Win_size, pygame.FULLSCREEN)
|
||||
screenX = pygame.display.set_mode(monitor_size, pygame.FULLSCREEN)
|
||||
d = pygame.display.get_surface()
|
||||
Win_size = [d.get_width(), int((d.get_width()*2)/3)]
|
||||
Win_size = [int((d.get_height() / 2) * 3), d.get_height()]
|
||||
|
||||
elif event.key == K_ESCAPE:
|
||||
pygame.quit()
|
||||
@ -164,6 +175,10 @@ def menu(screenX, fs, Win_size):
|
||||
else:
|
||||
display.blit(sheets[0 + (s_index * 2)], [700, 100])
|
||||
|
||||
# load
|
||||
|
||||
display.blit(load[l_index], [140, 60])
|
||||
|
||||
# basic loop config
|
||||
|
||||
screenX.blit(pygame.transform.scale(display, Win_size), (0, 0))
|
||||
@ -200,6 +215,10 @@ def run_game(screenX, fs, setup, Win_size):
|
||||
cheatsheet.set_colorkey((0, 0, 0))
|
||||
cheatsheet.set_alpha(180)
|
||||
|
||||
# if loading
|
||||
if setup["load"]:
|
||||
setup = game.load("assets/save.json", setup)
|
||||
|
||||
while game.alive:
|
||||
|
||||
display.fill((255, 255, 255))
|
||||
@ -260,6 +279,7 @@ def run_game(screenX, fs, setup, Win_size):
|
||||
|
||||
for event in pygame.event.get():
|
||||
if event.type == QUIT:
|
||||
game.save("assets/save.json", setup)
|
||||
pygame.quit()
|
||||
sys.exit()
|
||||
|
||||
@ -304,14 +324,17 @@ def run_game(screenX, fs, setup, Win_size):
|
||||
Win_size = Default_size
|
||||
screenX = pygame.display.set_mode(Win_size)
|
||||
else:
|
||||
screenX = pygame.display.set_mode(Win_size, pygame.FULLSCREEN)
|
||||
screenX = pygame.display.set_mode(monitor_size, pygame.FULLSCREEN)
|
||||
d = pygame.display.get_surface()
|
||||
Win_size = [d.get_width(), int((d.get_width() * 2) / 3)]
|
||||
Win_size = [int((d.get_height() / 2) * 3), d.get_height()]
|
||||
|
||||
elif event.key == K_ESCAPE:
|
||||
game.save("assets/save.json", setup)
|
||||
return screenX, fs, Win_size
|
||||
|
||||
elif event.key == K_r:
|
||||
with open("assets/save.json", "w") as f:
|
||||
json.dump({}, f, indent=4)
|
||||
return screenX, fs, Win_size
|
||||
|
||||
# managing scroll
|
||||
@ -352,6 +375,10 @@ def run_game(screenX, fs, setup, Win_size):
|
||||
screenX.blit(pygame.transform.scale(display, Win_size), (0, 0))
|
||||
pygame.display.update()
|
||||
|
||||
# todo save
|
||||
with open("assets/save.json", "w") as f:
|
||||
json.dump({}, f, indent=4)
|
||||
|
||||
# ending
|
||||
if game.collapse:
|
||||
screenX, fs, Win_size = end(screenX, fs, Win_size, game, "collapse")
|
||||
@ -416,9 +443,9 @@ def end(screenX, fs, Win_size, game, reason):
|
||||
Win_size = Default_size
|
||||
screenX = pygame.display.set_mode(Win_size)
|
||||
else:
|
||||
screenX = pygame.display.set_mode(Win_size, pygame.FULLSCREEN)
|
||||
screenX = pygame.display.set_mode(monitor_size, pygame.FULLSCREEN)
|
||||
d = pygame.display.get_surface()
|
||||
Win_size = [d.get_width(), int((d.get_width() * 2) / 3)]
|
||||
Win_size = [int((d.get_height() / 2) * 3), d.get_height()]
|
||||
|
||||
elif event.key == K_ESCAPE:
|
||||
return screenX, fs, Win_size
|
||||
@ -441,64 +468,5 @@ def end(screenX, fs, Win_size, game, reason):
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user