made a huge progress on how the game is gonna go (in code, basically level2 finished)

This commit is contained in:
Martin Dvořák 2026-05-31 17:55:23 +02:00
commit b867506b56
4 changed files with 81 additions and 9 deletions

13
main.py
View file

@ -7,12 +7,14 @@ def main(fps=window_fps): # the main function
pygame.init() # initalizes pygame
screen_width = 768 # the screen width
screen_height = 576 # the screen height
tick = 0
# for sprites 48x36
title = "Revival Inc." # 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
pygame.display.set_caption(title) # this actually sets the title of the window from the title variable
basicfont = pygame.font.SysFont(None, 50) # this sets a basic font for now, we can change this to anything later onvariable
smalltext = pygame.font.Font('Monocraft.ttf', 25)
basicfont = pygame.font.Font('Monocraft.ttf', 50) # this sets a basic font for now, we can change this to anything later onvariable
bigtext = pygame.font.Font('Monocraft.ttf', 50)
clock = pygame.time.Clock() # this is used to control the fps of the game if you scroll down the code a bit
click = False # variable I use to check if u clicked with the mouse when calling level function from levels.
@ -33,18 +35,17 @@ def main(fps=window_fps): # the main function
lastclickpos = pygame.mouse.get_pos() # sets the variable to the position you last clicked
if event.type == pygame.MOUSEBUTTONUP: # what happens when you release a mouse button
click = False # sets the click variable to False so level function in levels.py can see again
if level == 0:
running = False
elif 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, bigtext, level) # runs the level1 function from levels.py
level = levels.level1(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigtext, level, tick) # runs the level1 function from levels.py
# 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
tick += 1
level = levels.level2(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigtext, level, tick, smalltext) # runs the level2 function from levels.py
fps_text = smalltext.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