-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.py
More file actions
64 lines (46 loc) · 1.56 KB
/
tools.py
File metadata and controls
64 lines (46 loc) · 1.56 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import pygame
import constants as c
import Map
def drawrec(x, y, w, h, color):
pygame.draw.rect(c.gameDisplay, color, [x, y, w, h])
def drawhitbox(color, pos, radius, width):
pygame.draw.circle(c.gameDisplay, color, (pos), radius + 25, width)
def drawimage(image, x, y):
c.gameDisplay.blit(pygame.image.load(image), (x, y))
def rot_center(image, angle):
"""rotate a Surface, maintaining position."""
loc = image.get_rect().center # rot_image is not defined
rot_sprite = pygame.transform.rotate(image, angle)
rot_sprite.get_rect().center = loc
return rot_sprite
def drawcentered(image, pos):
position = list(pos)
x = position[0] - 20
y = position[1] - 20
c.gameDisplay.blit(pygame.image.load(image), (x, y))
def getspawny():
for i in range(len(Map.map.map)):
if Map.map.map[i][0] == "# ":
print (i)
return (40 * i)
else:
print ("Not in " + str(i))
def eztext(text, size, color, x, y):
default_font = pygame.font.get_default_font()
font_renderer = pygame.font.Font(default_font, size)
label = font_renderer.render(
text, # The font to render
1, # With anti aliasing
color) # RGB Color
# To apply this surface to another you can do the following
c.gameDisplay.blit(
label, # The text to render
(x, y)) # Where on the destination surface to render said font
def listx(pos):
position = list(pos)
x = int(pos[0] / 40)
return x
def listy(pos):
position = list(pos)
y = int(pos[1] / 40)
return y