-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheader.py
41 lines (35 loc) · 1.03 KB
/
header.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from xml.dom import minidom
import pygame
import sys
global assets, asset_height, asset_width, screen
def initAssets():
global assets, asset_height, asset_width
assetnodes = minidom.parse('assets.xml').getElementsByTagName('asset')
assets = dict( [\
(i.attributes["name"].value, pygame.image.load('assets/'+i.attributes["image"].value)) for i in assetnodes\
] )
asset_height = dict( [\
(i, assets[i].get_rect().bottom) for i in assets\
] )
asset_width = dict( [\
(i, assets[i].get_rect().right) for i in assets\
] )
def get_height(name):
global asset_height
return asset_height[name]
def get_width(name):
global asset_width
return asset_width[name]
def window(width, height):
global screen
pygame.init()
screen = pygame.display.set_mode((width, height))
def draw(array):
global assets, screen
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
screen.fill((0, 0, 0))
for (name, x, y) in array:
screen.blit(assets[name], (int(x), int(y)))
pygame.display.flip()
pygame.time.Clock().tick(200)