finally functional, next step: add comments
This commit is contained in:
parent
e4206ba0da
commit
dca14abe57
4 changed files with 31 additions and 49 deletions
11
levels.py
Normal file
11
levels.py
Normal 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
73
main.py
|
|
@ -8,66 +8,37 @@ screen_height = 500
|
|||
window_fps = 60
|
||||
title = "Example Title"
|
||||
|
||||
def main(width=screen_width, height=screen_height, fps=window_fps):
|
||||
def main(fps=window_fps):
|
||||
pygame.init()
|
||||
screen = pygame.display.set_mode((width, height))
|
||||
pygame.display.set_caption(title)
|
||||
clock = pygame.time.Clock()
|
||||
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
|
||||
while running:
|
||||
screen.fill((0, 0, 0))
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
# Fill these in with your logic
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if variables.level == 3 and variables.canyoutypethename == True:
|
||||
name = pygame.key.name(event.key)
|
||||
if name == "backspace":
|
||||
variables.playername = variables.playername[:-1]
|
||||
elif len(variables.playername) >= 12:
|
||||
pass
|
||||
elif name == "return" or name == "space":
|
||||
pass
|
||||
elif len(name) == 1:# and name.isalpha():
|
||||
variables.playername += str(name)
|
||||
# Example: print(event.key) or handle input
|
||||
if event.key == pygame.K_ESCAPE:
|
||||
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
|
||||
if event.key == pygame.K_ESCAPE: # put in here some action yknow
|
||||
pygame.quit()
|
||||
if event.type == pygame.MOUSEBUTTONDOWN:
|
||||
click = True
|
||||
print(pygame.mouse.get_pos())
|
||||
lastclickpos = pygame.mouse.get_pos()
|
||||
if event.type == pygame.MOUSEBUTTONUP:
|
||||
click = False
|
||||
if level == 1:
|
||||
level = levels.level1(screen, sheet, lastclickpos, basicfont, pygame.mouse, click, level)
|
||||
elif level == 2:
|
||||
level = levels.level2(screen, sheet, lastclickpos, basicfont, pygame.mouse, click, level)
|
||||
fps_text = basicfont.render(str(int(clock.get_fps())), True, (0, 255, 0))
|
||||
screen.blit(fps_text, (5, 5))
|
||||
pygame.display.flip()
|
||||
|
|
|
|||
BIN
sprites.png
Normal file
BIN
sprites.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
sprites.pxo
Normal file
BIN
sprites.pxo
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue