game/main.py
SpagettiFisch 51a287ba66 startscreen added
also some buttons added to be completed
button class initalized

Signed-off-by: SpagettiFisch <63868515+SpagettiFisch@users.noreply.github.com>
2024-02-13 10:21:42 +01:00

50 lines
1.3 KiB
Python

import pygame
import sys
import json
import time
def setUp(config):
pygame.init()
if config["fullscreen"]:
screen = pygame.display.set_mode(config["res"], pygame.FULLSCREEN)
else:
screen = pygame.display.set_mode(config["res"])
clock = pygame.time.Clock()
with open('art/textbox.png', 'r') as tb:
box = pygame.image.load(tb)
return screen, clock, True, True, "start.png", box
def readConfig():
with open('config.json', 'r') as c:
json_data = c.read()
return json.loads(json_data)
def main():
config = readConfig()
screen, clock, running, background, isblack, box = setUp(config["screen"])
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if not isblack:
with open(background, 'r') as i:
bg = pygame.image.load(i)
bg = pygame.transform.scale(bg, screen.get_size())
# fill the screen with a color to wipe away anything from last frame
screen.blit(bg, (0, 0))
# RENDER YOUR GAME HERE
else:
screen.fill('#000000')
# flip() the display to put your work on screen
pygame.display.flip()
clock.tick(60) # limits FPS to 60
pygame.quit()
if __name__ == '__main__':
main()