48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
import pygame
|
|
import levels
|
|
|
|
# VARIABLES
|
|
screen_width= 800
|
|
screen_height = 500
|
|
window_fps = 60
|
|
title = "Example Title"
|
|
|
|
def main(fps=window_fps):
|
|
pygame.init()
|
|
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 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()
|
|
clock.tick(fps)
|
|
pygame.quit()
|
|
if __name__ == "__main__":
|
|
main()
|