Add profiler
This commit is contained in:
parent
d368885e94
commit
a58db98866
@ -1,3 +1,5 @@
|
|||||||
|
from profilehooks import profile
|
||||||
|
|
||||||
import pygame
|
import pygame
|
||||||
import sys
|
import sys
|
||||||
import random
|
import random
|
||||||
@ -9,13 +11,16 @@ from player import *
|
|||||||
from blocks import *
|
from blocks import *
|
||||||
from enemies import *
|
from enemies import *
|
||||||
|
|
||||||
pygame.init()
|
@profile
|
||||||
clock = pygame.time.Clock()
|
def main():
|
||||||
|
|
||||||
screen = pygame.display.set_mode((screen_width,screen_height))
|
pygame.init()
|
||||||
pygame.display.set_caption('Arctic Masher')
|
clock = pygame.time.Clock()
|
||||||
|
|
||||||
players["1"] = (Player(
|
screen = pygame.display.set_mode((screen_width,screen_height))
|
||||||
|
pygame.display.set_caption('Arctic Masher')
|
||||||
|
|
||||||
|
players["1"] = (Player(
|
||||||
"1",
|
"1",
|
||||||
5,
|
5,
|
||||||
5,
|
5,
|
||||||
@ -31,8 +36,8 @@ players["1"] = (Player(
|
|||||||
(pygame.K_q, "nw"),
|
(pygame.K_q, "nw"),
|
||||||
(pygame.K_s, "p"),
|
(pygame.K_s, "p"),
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
players["2"] = (Player(
|
players["2"] = (Player(
|
||||||
"2",
|
"2",
|
||||||
3,
|
3,
|
||||||
3,
|
3,
|
||||||
@ -48,8 +53,8 @@ players["2"] = (Player(
|
|||||||
(pygame.K_KP_7, "nw"),
|
(pygame.K_KP_7, "nw"),
|
||||||
(pygame.K_KP_5, "p"),
|
(pygame.K_KP_5, "p"),
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
players["3"] = (Player(
|
players["3"] = (Player(
|
||||||
"3",
|
"3",
|
||||||
5,
|
5,
|
||||||
5,
|
5,
|
||||||
@ -65,25 +70,25 @@ players["3"] = (Player(
|
|||||||
(pygame.K_t, "nw"),
|
(pygame.K_t, "nw"),
|
||||||
(pygame.K_h, "p"),
|
(pygame.K_h, "p"),
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
|
|
||||||
mapgen.generateMap()
|
mapgen.generateMap()
|
||||||
|
|
||||||
sprite_sheet_image = pygame.image.load('assets/penguin.png').convert_alpha()
|
sprite_sheet_image = pygame.image.load('assets/penguin.png').convert_alpha()
|
||||||
|
|
||||||
def get_image(sheet, x, y, width, height, scale, colour):
|
def get_image(sheet, x, y, width, height, scale, colour):
|
||||||
image = pygame.Surface((width, height)).convert_alpha()
|
image = pygame.Surface((width, height)).convert_alpha()
|
||||||
image.blit(sheet, (0, 0), (x, y, width, height))
|
image.blit(sheet, (0, 0), (x, y, width, height))
|
||||||
image = pygame.transform.scale(image, (width * scale, height * scale))
|
image = pygame.transform.scale(image, (width * scale, height * scale))
|
||||||
image.set_colorkey(colour)
|
image.set_colorkey(colour)
|
||||||
|
|
||||||
return image
|
return image
|
||||||
frame_0 = get_image(sprite_sheet_image, 0, 0, 32, 32, (tile-2)/32, black)
|
frame_0 = get_image(sprite_sheet_image, 0, 0, 32, 32, (tile-2)/32, black)
|
||||||
frame_4 = get_image(sprite_sheet_image, 32, 0, 32, 32, (tile-2)/32, black)
|
frame_4 = get_image(sprite_sheet_image, 32, 0, 32, 32, (tile-2)/32, black)
|
||||||
|
|
||||||
game_font = pygame.font.Font("freesansbold.ttf",32)
|
game_font = pygame.font.Font("freesansbold.ttf",32)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
@ -112,3 +117,6 @@ while True:
|
|||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
clock.tick(60)
|
clock.tick(60)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user