This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPyTux.py
147 lines (136 loc) · 4.33 KB
/
PyTux.py
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# by Choc12
## GPLv3
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# import pygame
import pygame
# import pygame_widgets
import pygame_widgets
from pygame_widgets.button import Button
# import sys
import sys
# print the PyTux info
print("Welcome to PyTux!")
print("PyTux is a Pygame-based game for Linux, Windows And MacOS.")
print("PyTux is a game about Tux, the Linux mascot, and his adventures.")
print("PyTux is currently in development.")
print("PyTux is currently in version 0.0.0.")
print("PyTux is licensed under the GNU GPL v3.")
print("PyTux is made by the PyTux Team.(currently only Choc12.)")
print("PyTux is made in Python 3.11.4.")
print("PyTux is made in Pygame 2.5.0.")
print("PyTux is made in Visual Studio Code 1.79.2.")
print("PyTux is made in Windows 10.")
# pygame.init()
pygame.init()
# set the PyTux window
screen = pygame.display.set_mode((1280, 720), pygame.RESIZABLE)
# set the PyTux window title
pygame.display.set_caption("PyTux")
pygame.display.flip()
# update the PyTux window
pygame.display.update()
# set the PyTux window icon
pygame.display.set_icon(pygame.image.load("images/icon.png"))
# set the clock
setclock = pygame.time.Clock()
# set the PyTux FPS
FPS = 60
# set the PyTux background
color = (173, 216, 230)
screen.fill(color)
# set the PyTux text
textcolor = (0, 0, 0)
def text(text, x, y, textcolor, size):
font = pygame.font.SysFont("Arial", size)
text = font.render(text, True, textcolor)
screen.blit(text, (x, y))
# show the PyTux Logo
logo = pygame.image.load("images/logo.png")
screen.blit(logo, (500, 100))
# set the PyTux text
text("Welcome to PyTux!", 500, 10, (0, 0, 0), 30)
# button to start the game
button = Button(
screen, 250, 200, 150, 50, text='Start', fontSize=30,
margin=20,
inactiveColour=(0, 0, 0),
pressedColour=(255, 0, 0),
radius=20,
onClick=lambda: print('Click')
)
# when the start button is pressed
whenbutton = pygame.mouse.get_pressed()
if whenbutton[0]:
# start the game
whenbutton = True
print("Starting PyTux...")
exec(open("level1.py").read())
# press enter to start the game
whenenter = pygame.key.get_pressed()
if whenenter[pygame.K_RETURN]:
# start the game
whenenter = False
print("Starting PyTux...")
exec(open("level1.py").read())
# button to quit PyTux
quitbutton = Button(
screen, 250, 300, 150, 50, text='Quit', fontSize=30,
margin=20,
inactiveColour=(0, 0, 0),
pressedColour=(255, 0, 0),
radius=20,
onClick=lambda: print('Click')
)
# when the quit button is pressed
whenquitbutton = pygame.mouse.get_pressed()
if whenquitbutton[0]:
# quit PyTux
whenquitbutton = False
print("Quitting PyTux...")
sys.exit()
# button to go view the credits
creditsbutton = pygame.draw.rect(screen, (0, 0, 0), (250, 400, 150, 50))
text("Credits", 300, 410, (255, 255, 255), 30)
# when the credits button is pressed
whencreditsbutton = pygame.mouse.get_pressed()
if whencreditsbutton[0]:
# open Credits file
whencreditsbutton = False
print("Opening Credits file...")
exec(open("Credits").read())
# button to go view the license
licensebutton = pygame.draw.rect(screen, (0, 0, 0), (250, 500, 150, 50))
text("License", 300, 510, (255, 255, 255), 30)
# when the license button is pressed
whenlicensebutton = pygame.mouse.get_pressed()
if whenlicensebutton[0]:
# open License file
whenlicensebutton = False
print("Opening License file...")
exec(open("Copying").read())
# pygame.mixer.init()
maintheme = pygame.mixer.Sound("sounds/maintheme.ogg")
# play the main theme
maintheme.play(loops=-1)
# loop the main theme
pygame.display.update()
# main loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# quit PyTux
pygame.quit()
print("Quitting PyTux...")