Initial Commit 2 (BE AWARE THIS ISNT FUNCTIONAL CODE YET DONT USE)
This commit is contained in:
parent
f6107b1745
commit
06f265bdac
2 changed files with 84 additions and 0 deletions
77
main.py
Normal file
77
main.py
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import pygame
|
||||||
|
import levels
|
||||||
|
|
||||||
|
# VARIABLES
|
||||||
|
screen_width= 800
|
||||||
|
screen_height = 500
|
||||||
|
window_fps = 60
|
||||||
|
title = "Example Title"
|
||||||
|
|
||||||
|
def main(width=screen_width, height=screen_height, 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")
|
||||||
|
running = True
|
||||||
|
while running:
|
||||||
|
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
|
||||||
|
fps_text = basicfont.render(str(int(clock.get_fps())), True, (0, 255, 0))
|
||||||
|
screen.blit(fps_text, (5, 5))
|
||||||
|
pygame.display.flip()
|
||||||
|
clock.tick(fps)
|
||||||
|
pygame.quit()
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
7
render.py
Normal file
7
render.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
import pygame
|
||||||
|
|
||||||
|
def load_sprite(sheet, x, y, width, height, screen_width, screen_height):
|
||||||
|
rect = pygame.Rect(x, y, width, height)
|
||||||
|
sprite = sheet.subsurface(rect)
|
||||||
|
scaled = pygame.transform.scale(sprite, (screen_width, screen_height))
|
||||||
|
return scaled
|
||||||
Loading…
Add table
Add a link
Reference in a new issue