-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcombat.py
107 lines (78 loc) · 2.98 KB
/
combat.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import pygame
from pygame.locals import *
class Combat(object):
def __init__(self, world):
self.world = world
self.display = world.display
self.interface = GUI(self)
self.display_rect = self.display.get_rect()
self.image = pygame.Surface((0, 0))
self.outcome = 'unknown'
self.interface.set_client(self)
self.opponents = {}
self.player = None
self.font = pygame.font.SysFont('Monospace', 18, True)
def renderText(self, text):
return self.font.render(text, True, (255, 255, 255))
def init_map(self, surface):
self.image = surface.copy()
def Fight(self, player, opponents):
self.player = player
self.player.face('right')
self.outcome = 'unknown'
self.opponent = opponents[0]
self.opponent.face('left')
self.interface.start()
self.world.state = 'combat'
def key_loop(self):
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_ESCAPE: self.world.state = self.world.prev_state
def loop(self):
self.key_loop()
def draw(self):
self.display.blit(self.image, (0, 0))
self.display.blit(self.player.image, (300, 300))
self.display.blit(self.opponent.image, (600, 300))
self.interface.draw()
class GUI(object):
def __init__(self, parent):
self.parent = parent
self.display = parent.display
self.load_image = parent.world.load_image
self.image = self.load_image('interface/timeline.png')
self.actors = []
self.rect = self.image.get_rect()
self.rect.midtop = (self.display.get_rect().width/2, 550)
self.font = pygame.font.SysFont('Monospace', 16, True)
self.face_friend_frame = self.load_image('interface/face_frame.png')
self.face_foe_frame = \
pygame.transform.flip(self.face_friend_frame, False, True)
pygame.draw.rect(self.face_friend_frame, (145, 255, 145), \
pygame.Rect(2, 2, 50, 50))
pygame.draw.rect(self.face_foe_frame, (250, 75, 65), \
pygame.Rect(2, 18, 50, 50))
self.client = None
self.faces = {}
self.opponents = []
self.player = None
def init_gui(self):
pass
def set_client(self, client):
self.client = client
def start(self):
self.player_face = self.face_friend_frame.copy()
self.player_face.blit(pygame.transform.scale( \
self.client.player.portrait, (50, 50)), (2, 2))
self.opponent_face = self.face_foe_frame.copy()
self.opponent_face.blit(pygame.transform.scale( \
self.client.opponent.portrait, (50, 50)), (2, 18))
def draw(self):
self.image.blit(self.player_face, (27, 30))
self.image.blit(self.opponent_face, (27, 100))
self.display.blit(self.image, self.rect.topleft)
def move(self):
pass
class Face(object):
def __init__(self):
pass