-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFallBall.py
More file actions
65 lines (51 loc) · 1.78 KB
/
FallBall.py
File metadata and controls
65 lines (51 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import arcade as ac
from arcade.experimental.camera import Camera2D
import Game
import Menu
from cryptography.fernet import Fernet
import json
import pyglet
WINDOW_WIDTH = 800
WINDOW_HEIGHT = 500
WINDOW_TITLE = "FallBall by LoupioFR"
class FallingBall(ac.Window):
def __init__(self):
super(FallingBall, self).__init__(title=WINDOW_TITLE, width=960, height=540)
self.set_icon(pyglet.image.load("icon.png"))
# loading settings
with open("settings.json") as file:
self.settings = json.loads(file.read())
if self.settings["full_screen"]:
self.set_fullscreen()
else:
self.maximize()
# init encrypter : yes you can see this key... but it's...
self.encrypter = Fernet("y3pEb-6qmTIkpl8Tx5tjw_eIj6qKseV3yQE20PhO9D4=".encode())
# creating main camera
self.camera = Camera2D(
viewport=(0, 0, self.width, self.height),
projection=(0, 1920, 0, 1080)
)
self.CURSOR = self._mouse_cursor
# creating views
self.menu = Menu.Menu(self, self.camera)
self.game = Game.Game(self, self.camera)
self.show_menu()
def show_game(self):
self.set_mouse_visible(False)
self.show_view(self.game)
def show_menu(self):
self.set_mouse_visible(True)
self.show_view(self.menu)
def on_resize(self, width: float, height: float):
self.camera.viewport = (0, 0, width, height)
def set_setting(self, key: str, value: bool or int):
self.settings[key] = value
def on_close(self):
# saving settings
with open("settings.json", "w") as file:
file.write(json.dumps(self.settings))
self.close()
if __name__ == '__main__':
app = FallingBall()
ac.run()