made some work on the intro so far so good ig

This commit is contained in:
Martin Dvořák 2026-06-07 00:53:37 +02:00
commit f316adc74c
7 changed files with 96 additions and 13 deletions

22
main.py
View file

@ -4,17 +4,22 @@ import pygame, levels # Imports the pygame library and our own levels.py we made
window_fps = 60 # the frames per second, this decides how fast the main loop runs per second
def main(fps=window_fps): # the main function
pygame.init() # initalizes pygame
pygame.init() # initializes pygame
pygame.mixer.init()
pygame.mixer.music.load('theme.wav')
pygame.mixer.music.play(-1,0,2000)
blip = pygame.mixer.Sound('blip.wav')
tick = 0
screen_width = 912 # the screen width
screen_height = 576 # the screen height
# THE SCREEN IS 19:12 RATIO
title = "The Destroyer of Cities" # the title of the window obviously
lastclickpos = [0, 0] # last position that was clicked, this changes every time you click somewhere on the game window
screen = pygame.display.set_mode((screen_width, screen_height)) # this initalizes the display with the screen_width and screen_height variables
screen = pygame.display.set_mode((screen_width, screen_height)) # this initializes the display with the screen_width and screen_height variables
pygame.display.set_caption(title) # this actually sets the title of the window from the title variable
basicfont = pygame.font.Font('KiwiSoda.ttf', 50) # this sets a basic font for now, we can change this to anything later on
bigfont = pygame.font.Font('KiwiSoda.ttf', 80)
sysfont = pygame.font.SysFont('', 30)
slightly_smaller_than_bigfont = pygame.font.Font('KiwiSoda.ttf', 70)
smallfont = pygame.font.Font('KiwiSoda.ttf', 30)
clock = pygame.time.Clock() # this is used to control the fps of the game if you scroll down the code a bit
@ -28,8 +33,11 @@ def main(fps=window_fps): # the main function
if event.type == pygame.QUIT: # what happens when you click the X button on the window
running = False # poof
if event.type == pygame.KEYDOWN: # what happens when you press down a key
if event.key == pygame.K_ESCAPE: # what happens when you press escape
running = False # poof
if event.key == pygame.K_ESCAPE:
levels.dialognum += 1
if event.key == pygame.K_h:
if levels.dialognum == 9:
levels.dialognum = 10
if event.type == pygame.MOUSEBUTTONDOWN: # what happens when you press down a mouse button
click = True # sets the click variable to True so level function in levels.py can see
print(pygame.mouse.get_pos()) # prints out where the mouse is during the click for debugging purposes
@ -39,14 +47,14 @@ def main(fps=window_fps): # the main function
if level == 0:
running = False
if level == 1: # what happens when the level variable is equal to 1
level = levels.level1(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigfont, level, tick, slightly_smaller_than_bigfont) # runs the level1 function from levels.py
level = levels.level1(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigfont, level, tick, slightly_smaller_than_bigfont, pygame.mixer.music) # runs the level1 function from levels.py
if level == 2:
pass
level = levels.level2(blip, screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigfont, level, tick, slightly_smaller_than_bigfont, pygame.mixer.music)
# THE REASON WE CALL IT LIKE THIS INSTEAD OF NORMALLY IS SO WE CAN CHANGE THE LEVEL VARIABLE
elif level == 2: # what happens when the level variable is equal to 2 ofc
level = levels.level2(screen, sheet, lastclickpos, basicfont, pygame.mouse, click, level) # runs the level2 function from levels.py
fps_text = basicfont.render(str(int(clock.get_fps())), True, (0, 255, 0)) # defines a thing that renders your fps in the top left corner
fps_text = sysfont.render(str(int(clock.get_fps())), True, (0, 255, 0)) # defines a thing that renders your fps in the top left corner
screen.blit(fps_text, (5, 5)) # this actually renders "ftp_text" on the screen at the position (5, 5) which is the top left corner
pygame.display.flip() # this updates the display so it displays all the new stuff we added
clock.tick(fps) # this makes sure the game loop runs at the fps we set it to before