forked from InfoProjekt/game
resorted the Scene class into a subclass of GameObjects
added the class Room to GameObjects added a very simple start screen WIP: disabled option button until option function is implemented Signed-off-by: SpagettiFisch <63868515+SpagettiFisch@users.noreply.github.com>
This commit is contained in:
parent
4e1674d6f3
commit
8f78002015
3 changed files with 32 additions and 20 deletions
BIN
art/images/start.png
Normal file
BIN
art/images/start.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 MiB |
26
classes.py
26
classes.py
|
|
@ -137,10 +137,24 @@ class DropDown():
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
|
||||||
class Scene():
|
class GameObjects():
|
||||||
def __init__(self, _type, bg, objects) -> None:
|
def __init__(self, name:str, _type:str, bg, objects:list) -> None:
|
||||||
self.name
|
self.name = name
|
||||||
self.type = _type
|
self.type = _type
|
||||||
if self.type != 'cutscene':
|
self.background = bg
|
||||||
self.background = bg
|
self.objects = objects
|
||||||
self.objects = objects
|
|
||||||
|
|
||||||
|
class Scene(GameObjects):
|
||||||
|
def __init__(self, name:str, _type:str, bg, objects:list) -> None:
|
||||||
|
super().__init__(name, _type, bg, objects)
|
||||||
|
|
||||||
|
|
||||||
|
class Room(GameObjects):
|
||||||
|
def __init__(self, name:str, _type:str, bg, objects:list, exits:list) -> None:
|
||||||
|
super().__init__(name, _type, bg, objects)
|
||||||
|
self.exits = exits
|
||||||
|
if self.type == 'normal' or self.type == 'boss':
|
||||||
|
self.locked = True
|
||||||
|
else:
|
||||||
|
self.locked = False
|
||||||
|
|
|
||||||
26
main.py
26
main.py
|
|
@ -24,10 +24,7 @@ def readConfig():
|
||||||
def quitGame():
|
def quitGame():
|
||||||
#save progress somehow, if needed
|
#save progress somehow, if needed
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
sys.exit()
|
quit()
|
||||||
|
|
||||||
def uwu():
|
|
||||||
print('uwu')
|
|
||||||
|
|
||||||
def play(screen, clock, running, background, isblack, WIDTH, HEIGHT):
|
def play(screen, clock, running, background, isblack, WIDTH, HEIGHT):
|
||||||
objects = []
|
objects = []
|
||||||
|
|
@ -92,15 +89,16 @@ def options(screen, clock, running, background, isblack, WIDTH, HEIGHT):
|
||||||
|
|
||||||
def menu(screen, clock, running, background, isblack, WIDTH, HEIGHT):
|
def menu(screen, clock, running, background, isblack, WIDTH, HEIGHT):
|
||||||
objects = []
|
objects = []
|
||||||
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'medieval', 48, "Exit game", quitGame))
|
|
||||||
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', 48, "Play", play))
|
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', 48, "Play", play))
|
||||||
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', 48, "Options", uwu))
|
#objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', 48, "Options", uwu))
|
||||||
|
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'medieval', 48, "Exit game", quitGame))
|
||||||
while running:
|
while running:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
running = False
|
running = False
|
||||||
|
quitGame()
|
||||||
# RENDER YOUR GAME HERE
|
# RENDER YOUR GAME HERE
|
||||||
with open(background, 'r') as i:
|
with open(f'art/images/{background}', 'r') as i:
|
||||||
bg = pygame.image.load(i)
|
bg = pygame.image.load(i)
|
||||||
bg = pygame.transform.scale(bg, (WIDTH, HEIGHT))
|
bg = pygame.transform.scale(bg, (WIDTH, HEIGHT))
|
||||||
# fill the screen with an image to clear the screen
|
# fill the screen with an image to clear the screen
|
||||||
|
|
@ -117,11 +115,11 @@ def main():
|
||||||
config = readConfig()
|
config = readConfig()
|
||||||
screen, clock, running, isblack, background, objects = setUp(config["screen"])
|
screen, clock, running, isblack, background, objects = setUp(config["screen"])
|
||||||
WIDTH, HEIGHT = screen.get_size()
|
WIDTH, HEIGHT = screen.get_size()
|
||||||
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'medieval', 48, "Exit game", quitGame))
|
#objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', 48, "Play", play))
|
||||||
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', 48, "Options", uwu))
|
#objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', 48, "Options", uwu))
|
||||||
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', 48, "Play", play))
|
#objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'medieval', 48, "Exit game", quitGame))
|
||||||
|
menu(screen, clock, running, background, isblack, WIDTH, HEIGHT)
|
||||||
while running:
|
"""while running:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
running = False
|
running = False
|
||||||
|
|
@ -141,7 +139,7 @@ def main():
|
||||||
# flip() the display to put your work on screen
|
# flip() the display to put your work on screen
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|
||||||
clock.tick(60) # limits FPS to 60
|
clock.tick(60) # limits FPS to 60"""
|
||||||
|
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue