might aswell add the last changes before I unfinished the jam

This commit is contained in:
dvorakmortonxd 2026-06-12 08:00:28 +02:00
commit a0e8d6a6ba
4 changed files with 47 additions and 11 deletions

36
main.py
View file

@ -13,7 +13,7 @@ def main(fps=window_fps): # the main function
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
title = "The Larvae" # 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 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
@ -28,6 +28,7 @@ def main(fps=window_fps): # the main function
level = 1 # the level variable, this also gets changed during the "gameplay"
running = True # this variable starts the game loop
while running: # game loop
levels.oldpx, levels.oldpy = levels.playerx, levels.playery
screen.fill((0, 0, 0)) # fills the screen with black, so the sprites loaded previously dont overlap and this clears the last frame every "tick"
for event in pygame.event.get(): # this checks for stuff like key presses and mouse clicks
if event.type == pygame.QUIT: # what happens when you click the X button on the window
@ -41,6 +42,17 @@ def main(fps=window_fps): # the main function
if level == 3:
tickd = 0
level = 4
if level > 3:
if event.key == pygame.K_w:
levels.playerYc = -3
if event.key == pygame.K_a:
levels.playerXc = -3
if event.key == pygame.K_s:
levels.playerYc = +3
if event.key == pygame.K_d:
levels.playerXc = +3
if event.key == pygame.K_h:
if levels.dialognum == 9:
levels.tickd = 0
@ -49,6 +61,16 @@ def main(fps=window_fps): # the main function
if levels.dialognum == 11:
levels.tickd = 0
levels.dialognum = 12
if event.type == pygame.KEYUP:
if level > 3:
if event.key == pygame.K_w:
playerYc = 0
if event.key == pygame.K_a:
playerXc = 0
if event.key == pygame.K_s:
playerYc = 0
if event.key == pygame.K_d:
playerXc = 0
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
@ -67,6 +89,18 @@ def main(fps=window_fps): # the main function
level = levels.level4(blip, screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigfont, level, tick, slightly_smaller_than_bigfont, pygame.mixer.music)
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
if 180 > levels.playerx:
levels.playerx = 180
if 615 < levels.playerx:
levels.playerx = 615
if 165 > levels.playery:
levels.playery = 165
if 275 < levels.playery:
levels.playery = 275
levels.playerx += levels.playerXc
levels.playery += levels.playerYc
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
pygame.quit() #this quits our game when the game loop somehow ends, for example by pressing escape or the X button on the window