finally functional, next step: add comments

This commit is contained in:
dvorakmortonxd 2026-05-29 09:57:18 +02:00
commit dca14abe57
4 changed files with 31 additions and 49 deletions

11
levels.py Normal file
View file

@ -0,0 +1,11 @@
from render import load_sprite
def level1(screen, sheet, lastclickpos, basicfont, mouse, click, level):
screen.blit(load_sprite(sheet, 0, 0, 26, 8, 210, 60), (200, 200))
if click:
level = 2
print("yo")
return level
def level2(screen, sheet, lastclickpos, basicfont, mouse, click, level):
print("ur done")
return level

73
main.py
View file

@ -8,66 +8,37 @@ screen_height = 500
window_fps = 60 window_fps = 60
title = "Example Title" title = "Example Title"
def main(width=screen_width, height=screen_height, fps=window_fps): def main(fps=window_fps):
pygame.init() pygame.init()
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption(title)
clock = pygame.time.Clock()
sheet = pygame.image.load("sprites.png") sheet = pygame.image.load("sprites.png")
lastclickpos = [0, 0]
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption(title)
basicfont = pygame.font.SysFont(None, 30)
clock = pygame.time.Clock()
click = False
sheet = pygame.image.load("sprites.png")
level = 1
running = True running = True
while running: while running:
screen.fill((0, 0, 0))
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
# Fill these in with your logic # Fill these in with your logic
if event.type == pygame.KEYDOWN: if event.type == pygame.KEYDOWN:
if variables.level == 3 and variables.canyoutypethename == True: if event.key == pygame.K_ESCAPE: # put in here some action yknow
name = pygame.key.name(event.key) pygame.quit()
if name == "backspace": if event.type == pygame.MOUSEBUTTONDOWN:
variables.playername = variables.playername[:-1] click = True
elif len(variables.playername) >= 12: print(pygame.mouse.get_pos())
pass lastclickpos = pygame.mouse.get_pos()
elif name == "return" or name == "space": if event.type == pygame.MOUSEBUTTONUP:
pass click = False
elif len(name) == 1:# and name.isalpha(): if level == 1:
variables.playername += str(name) level = levels.level1(screen, sheet, lastclickpos, basicfont, pygame.mouse, click, level)
# Example: print(event.key) or handle input elif level == 2:
if event.key == pygame.K_ESCAPE: level = levels.level2(screen, sheet, lastclickpos, basicfont, pygame.mouse, click, level)
running = False
elif event.key == pygame.K_SLASH:
if variables.devmode:
variables.level = 4
variables.dialognum = 4
variables.playername = "BlackNagger"
elif event.key == pygame.K_SPACE:
if variables.devmode:
variables.hairstyle += 1
variables.stubble += 1
variables.skincolor += 1
elif event.key == pygame.K_BACKSPACE:
if variables.devmode:
variables.skincolor -= 1
variables.hairstyle -= 1
variables.stubble -= 1
elif event.key == pygame.K_CAPSLOCK:
if variables.devmode:
variables.playerstrength += 1
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
variables.clicked = True
variables.lastclickpos = pygame.mouse.get_pos()
if variables.level == 1:
levels.level1(screen, sheet, gamefont, variables.screen_width/2-100, variables.screen_height/2+120, pygame.mouse, variables.clicked, variables.lastclickpos)
elif variables.level == 2:
levels.level2(screen, sheet, smallergamefont, variables.screen_width/2-100, variables.screen_height/2+120, pygame.mouse, variables.clicked, variables.lastclickpos)
elif variables.level == 3:
levels.level3(screen, sheet, smallergamefont, pygame.mouse, variables.clicked, variables.lastclickpos, variables.playername, smallergamefont, variables.ticks, variables.screen_fps, chunkyfont)
elif variables.level == 4:
levels.level4(screen, sheet, smallergamefont, pygame.mouse, variables.clicked, variables.lastclickpos, variables.playername, smallergamefont, variables.ticks, variables.screen_fps, chunkyfont, chunkygamefont, variables.unlimited_slappeartext)
elif variables.level == 5:
levels.level5(screen, sheet, smallergamefont, pygame.mouse, variables.clicked, variables.lastclickpos, variables.playername, smallergamefont, variables.ticks, variables.screen_fps, chunkyfont, chunkygamefont, variables.unlimited_slappeartext)
variables.ticks += 1
if variables.ticks > fps:
variables.ticks = 0
fps_text = basicfont.render(str(int(clock.get_fps())), True, (0, 255, 0)) fps_text = basicfont.render(str(int(clock.get_fps())), True, (0, 255, 0))
screen.blit(fps_text, (5, 5)) screen.blit(fps_text, (5, 5))
pygame.display.flip() pygame.display.flip()

BIN
sprites.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
sprites.pxo Normal file

Binary file not shown.