generated from dvorakmortonxd/pygame-template
169 lines
No EOL
8.2 KiB
Python
169 lines
No EOL
8.2 KiB
Python
from render import load_sprite # this makes it so our function for rendering sprites from sprites.png is available in here
|
|
import pygame
|
|
tickd = 0
|
|
dialognum = 0
|
|
DIALOGTEXT = "UNDEFINED"
|
|
def level1(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, mouse, click, big_text, level, tick, slightfont, pygamemixer): # the function for our first level, ignore the unused variables here, you can use them when you edit it
|
|
global tickd
|
|
tickd += 1
|
|
screen.blit(load_sprite(sheet, 0, 0, 57, 36, 912, 576), (0, 0)) # this renders a button I made in the sprites.png, its purely for visual purposes so it doesnt matter where you click rn
|
|
if tickd in range(100,110) or tickd in range(120,130) or tickd in range(300,310) or tickd in range(320,330):
|
|
overlay = pygame.Surface(screen.get_size(), pygame.SRCALPHA)
|
|
overlay.fill((255, 255, 255, 18))
|
|
screen.blit(overlay, (0, 0))
|
|
elif tickd > 450:
|
|
tickd = 0
|
|
mainmenu_text = slightfont.render("THE DESTROYER OF CITIES", True, (210, 210, 210))
|
|
playb_collision = pygame.Rect(315, 200, 285, 105)
|
|
exitb_collision = pygame.Rect(315, 350, 285, 105)
|
|
if playb_collision.collidepoint(mouse.get_pos()):
|
|
screen.blit(load_sprite(sheet, 57, 7, 19, 7, 285, 105), (315, 200))
|
|
play_text = basicfont.render("Play", True, (0,0,0))
|
|
if click:
|
|
tickd = 0
|
|
pygamemixer.stop()
|
|
level = 2
|
|
else:
|
|
screen.blit(load_sprite(sheet, 57, 0, 19, 7, 285, 105), (315, 200))
|
|
play_text = basicfont.render("Play", True, (255,255,255))
|
|
|
|
screen.blit(play_text, (414, 230))
|
|
|
|
if exitb_collision.collidepoint(mouse.get_pos()):
|
|
screen.blit(load_sprite(sheet, 57, 7, 19, 7, 285, 105), (315, 350))
|
|
exit_text = basicfont.render("Exit", True, (0,0,0))
|
|
if click:
|
|
level = 0
|
|
else:
|
|
screen.blit(load_sprite(sheet, 57, 0, 19, 7, 285, 105), (315, 350))
|
|
exit_text = basicfont.render("Exit", True, (255,255,255))
|
|
screen.blit(exit_text, (414, 380))
|
|
screen.blit(mainmenu_text, (45, 65))
|
|
return level # this returns the change we made to the level so that it updates in main.py
|
|
def level2(blip, screen, sheet, screen_width, screen_height, lastclickpos, basicfont, mouse, click, big_text, level, tick, slightfont, pygamemixer): # the function for our first level, ignore the unused variables here, you can use them when you edit it
|
|
global tickd, dialognum, DIALOGTEXT
|
|
if dialognum not in [9, 11]:
|
|
tickd += 1
|
|
else:
|
|
if tickd < 500:
|
|
tickd += 1
|
|
if tickd == 59:
|
|
pygame.mixer.Sound.play(blip)
|
|
if tickd in range(60,501):
|
|
if tickd < 315:
|
|
transparency = (tickd-60, tickd-60, tickd-60)
|
|
else:
|
|
transparency = (255,255,255)
|
|
if dialognum == 0:
|
|
DIALOGTEXT = "Where am I..."
|
|
if dialognum == 1:
|
|
DIALOGTEXT = "What am I doing here?!"
|
|
if dialognum == 2:
|
|
DIALOGTEXT = "Why can't I remember anything?"
|
|
if dialognum == 3:
|
|
DIALOGTEXT = ". . ."
|
|
if dialognum == 4:
|
|
DIALOGTEXT = "Wait."
|
|
if dialognum == 5:
|
|
DIALOGTEXT = "Those aren't my hands."
|
|
if dialognum == 6:
|
|
DIALOGTEXT = ". . ."
|
|
if dialognum == 7:
|
|
DIALOGTEXT = ""
|
|
screen.blit(load_sprite(sheet, 0, 37, 57,36, 912, 576), (0,0))
|
|
screen.blit(load_sprite(sheet,57,15,8,25, 80, 250), (660, 290))
|
|
screen.blit(load_sprite(sheet, 65, 14, 13, 5, 65, 25), (710, 285))
|
|
if dialognum == 8:
|
|
DIALOGTEXT = "Oh..."
|
|
screen.blit(load_sprite(sheet, 0, 37, 57,36, 912, 576), (0,0))
|
|
screen.blit(load_sprite(sheet,57,15,8,25, 80, 250), (660, 290))
|
|
screen.blit(load_sprite(sheet, 65, 14, 13, 5, 65, 25), (710, 285))
|
|
dialog_square = pygame.surface.Surface((800, 68), pygame.SRCALPHA)
|
|
dialog_square.fill((0, 0, 0))
|
|
screen.blit(dialog_square, (56, 500))
|
|
if dialognum == 9:
|
|
DIALOGTEXT = "Press <H> to hide yourself"
|
|
screen.blit(load_sprite(sheet, 0, 37, 57,36, 912, 576), (0,0))
|
|
screen.blit(load_sprite(sheet,57,15,8,25, 80, 250), (660, 290))
|
|
screen.blit(load_sprite(sheet, 65, 14, 13, 5, 65, 25), (710, 285))
|
|
dialog_square = pygame.surface.Surface((800, 68), pygame.SRCALPHA)
|
|
dialog_square.fill((0, 0, 0))
|
|
screen.blit(dialog_square, (56, 500))
|
|
if dialognum == 10:
|
|
DIALOGTEXT = "Yep, that's whats going on.."
|
|
screen.blit(load_sprite(sheet, 0, 37, 57,36, 912, 576), (0,0))
|
|
screen.blit(load_sprite(sheet,57,15,8,25, 80, 250), (660, 290))
|
|
dialog_square = pygame.surface.Surface((800, 68), pygame.SRCALPHA)
|
|
dialog_square.fill((0, 0, 0))
|
|
screen.blit(dialog_square, (56, 500))
|
|
if dialognum == 11:
|
|
DIALOGTEXT = "Press <Space> to get up."
|
|
screen.blit(load_sprite(sheet, 0, 37, 57,36, 912, 576), (0,0))
|
|
screen.blit(load_sprite(sheet,57,15,8,25, 80, 250), (660, 290))
|
|
dialog_square = pygame.surface.Surface((800, 68), pygame.SRCALPHA)
|
|
dialog_square.fill((0, 0, 0))
|
|
screen.blit(dialog_square, (56, 500))
|
|
if dialognum == 12:
|
|
DIALOGTEXT = "I'm the parasite..."
|
|
screen.blit(load_sprite(sheet, 0, 37, 57,36, 912, 576), (0,0))
|
|
screen.blit(load_sprite(sheet,57,40,6,28, 60, 280), (600, 290))
|
|
dialog_square = pygame.surface.Surface((800, 68), pygame.SRCALPHA)
|
|
dialog_square.fill((0, 0, 0))
|
|
screen.blit(dialog_square, (56, 500))
|
|
if dialognum == 13:
|
|
DIALOGTEXT = ""
|
|
tickd = 0
|
|
screen.blit(load_sprite(sheet, 0, 37, 57,36, 912, 576), (0,0))
|
|
screen.blit(load_sprite(sheet,57,15,8,25, 80, 250), (660, 290))
|
|
level = 3
|
|
dialog = basicfont.render(DIALOGTEXT, True, transparency)
|
|
if len(DIALOGTEXT) < 16:
|
|
DX = 456-len(DIALOGTEXT)*9
|
|
else:
|
|
DX = 456-len(DIALOGTEXT)*10
|
|
if dialognum < 7:
|
|
DY = 230
|
|
else:
|
|
DY = 510
|
|
screen.blit(dialog, (DX,DY))
|
|
if tickd > 500:
|
|
dialognum += 1
|
|
if dialognum > 6:
|
|
screen.blit(load_sprite(sheet, 0, 37, 57, 36, 912, 576), (0, 0))
|
|
if dialognum != 7:
|
|
pygame.mixer.Sound.play(blip)
|
|
tickd = 60
|
|
return level # returns the current level set
|
|
|
|
def level3(blip, screen, sheet, screen_width, screen_height, lastclickpos, basicfont, mouse, click, big_text, level, tick, slightfont, pygamemixer): # the function for our first level, ignore the unused variables here, you can use them when you edit it
|
|
global tickd
|
|
tickd += 1
|
|
screen.blit(load_sprite(sheet, 0, 37, 57, 36, 912, 576), (0, 0))
|
|
screen.blit(load_sprite(sheet,57,15,8,25, 80, 250), (660, 290))
|
|
square = pygame.surface.Surface((812, 476), pygame.SRCALPHA)
|
|
square.fill((0, 0, 0))
|
|
if tickd < 255:
|
|
transparency = (tickd, tickd, tickd)
|
|
else:
|
|
transparency = (255,255,255)
|
|
dialog1 = basicfont.render("Controls:", True, transparency)
|
|
dialog2 = basicfont.render("<WASD> to move around", True, transparency)
|
|
dialog3 = basicfont.render("<E> to interact when prompted", True, transparency)
|
|
dialog4 = basicfont.render("<H> to hide yourself (the parasite)", True, transparency)
|
|
dialog5 = basicfont.render("<Escape> to pause", True, transparency)
|
|
dialog6 = basicfont.render("Press <Space> to continue.", True, transparency)
|
|
square.blit(dialog1, (15, 15))
|
|
square.blit(dialog2, (15, 65))
|
|
square.blit(dialog3, (15, 115))
|
|
square.blit(dialog4, (15, 165))
|
|
square.blit(dialog5, (15, 215))
|
|
square.blit(dialog6, (15, 426))
|
|
screen.blit(square, (50, 50))
|
|
return level
|
|
|
|
def level4(blip, screen, sheet, screen_width, screen_height, lastclickpos, basicfont, mouse, click, big_text, level, tick, slightfont, pygamemixer): # the function for our first level, ignore the unused variables here, you can use them when you edit it
|
|
global tickd
|
|
tickd += 1
|
|
screen.blit(load_sprite(sheet, 0, 37, 57, 36, 912, 576), (0, 0))
|
|
screen.blit(load_sprite(sheet,57,15,8,25, 80, 250), (660, 290))
|
|
return level |