-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.pyw
38 lines (30 loc) · 1.08 KB
/
functions.pyw
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
# importing sub-modules
from settings import *
# game functions
# exit game function
def exit():
pygame.quit()
sys.exit()
running = False
# drawing game boundaries function
def marker(color=GREEN):
pygame.draw.rect(SCREEN, color, (0, 0, 800, 600), LINE_TICKNESS)
pygame.draw.line(SCREEN, color, (400, 0), (400, 600), LINE_TICKNESS)
# health bar function
def health_bar(pos_x, pos_y, health=50):
# if health greather than zero draw health bar
if health > 0:
# drawing green health bar
bar = pygame.draw.rect(SCREEN, GREEN, (pos_x, pos_y - 15, health, 8))
frame = pygame.draw.rect(SCREEN, WHITE, (pos_x, pos_y - 15, 50, 8), LINE_TICKNESS)
if health < 50:
# drawing yellow health bar
bar = pygame.draw.rect(SCREEN, YELLOW, (pos_x, pos_y - 15, health, 8))
frame = pygame.draw.rect(SCREEN, WHITE, (pos_x, pos_y - 15, 50, 8), LINE_TICKNESS)
if health < 15:
# drawing red healthbar
bar = pygame.draw.rect(SCREEN, RED, (pos_x, pos_y - 15, health, 8))
frame = pygame.draw.rect(SCREEN, WHITE, (pos_x, pos_y - 15, 50, 8), LINE_TICKNESS)
# else not draw just pass
else:
pass