-
Notifications
You must be signed in to change notification settings - Fork 1
/
zmundo_aberto.py
87 lines (76 loc) · 2.89 KB
/
zmundo_aberto.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
from configuracoes import *
from zclasse_mundo_aberto import *
pygame.init()
clock=pygame.time.Clock()
#gera tela de jogo
mapa_sprittes= pygame.sprite.Group()
tchsuco_sprittes=pygame.sprite.Group()
versus_sprittes=pygame.sprite.Group()
class Cenario:
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.matriz=MAPA
def criar_mapa(self):
for index_linha, linha in enumerate (MAPA):
for index_coluna,coluna in enumerate(linha):
x=index_coluna*TAMNHO_PEDACOS
y=index_linha*TAMNHO_PEDACOS
if coluna=='X':
rua=Rua([x,y])
mapa_sprittes.add(rua)
if coluna =="c":
candidato=Candidato([x,y])
versus_sprittes.add(candidato)
def mundo_screen2(screen,nome,x,y):
rodando='s'
tchusco=mapa_player()
tchusco.rect.centerx=x-50
tchusco.rect.centery=y-50
tchsuco_sprittes.add(tchusco)
Cenario.criar_mapa(screen)
while rodando=='s':
clock.tick(60)
#-----Eventos------
for event in pygame.event.get():
if event.type==pygame.QUIT:
rodando=False
else:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
tchusco.vy-=8
if event.key == pygame.K_s:
tchusco.vy+=8
if event.key == pygame.K_d:
tchusco.vx+=8
if event.key == pygame.K_a:
tchusco.vx-=8
if event.type == pygame.KEYUP:
if event.key == pygame.K_w:
tchusco.vy+=8
if event.key == pygame.K_s:
tchusco.vy-=8
if event.key == pygame.K_d:
tchusco.vx-=8
if event.key == pygame.K_a:
tchusco.vx+=8
screen.fill((0,0,0))
tchsuco_sprittes.update()
versus_sprittes.update()
#colide entre coisa do mapa e o player
encontros=pygame.sprite.spritecollide(tchusco,mapa_sprittes,False)
#verifica se tem colisão e não deixa passar
if encontros:
if tchusco.vx!=0:
tchusco.rect.centerx-=tchusco.vx
if tchusco.vy!=0:
tchusco.rect.centery-=tchusco.vy
lutas=pygame.sprite.spritecollide(tchusco,versus_sprittes,True)
if lutas:
tchusco.kill()
return LUTA,nome,tchusco.rect.centerx,tchusco.rect.centery
print('lutem')
#gera saidas
tchsuco_sprittes.draw(screen)
mapa_sprittes.draw(screen)
versus_sprittes.draw(screen)
pygame.display.update()