forked from STINKpython/CASTEL-DEFENSE
-
Notifications
You must be signed in to change notification settings - Fork 1
/
soldier_rifle.py
54 lines (41 loc) · 1.6 KB
/
soldier_rifle.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
from auxiliar import Auxiliar
import pygame
class Soldier_rifle:
def __init__(self,x,y):
# Animaciones
self.run = Auxiliar.getSurfaceFromSpriteSheet("unidades/soldier/run and point.png",8,1,False,1,1)[:6]
self.atack = Auxiliar.getSurfaceFromSpriteSheet("unidades/soldier/run and point.png",8,1,False,1,1)[6:8]
self.frame = 0
self.animation = self.run
self.image = self.animation[self.frame]
# Movimientos y rectangulos
self.rect = self.image.get_rect()
self.rect.x = x
self.rect.y = y
self.rect_radar = pygame.Rect(self.rect.x,self.rect.y,100,10)
#funciones
self.live=True
self.life=100
self.tiempo_transcurrido = 0
self.frame_rate_ms = 300
def move_x(self):
self.rect.x += 5
def move_y(self):
self.rect.y += 0
def actions(self,delta_ms,lista_eventos):
self.animation=self.run
self.move_x()
def update(self,delta_ms,lista_eventos):
self.tiempo_transcurrido = 0
if self.live:
self.actions(delta_ms,lista_eventos)
self.tiempo_transcurrido += delta_ms
if self.tiempo_transcurrido > self.frame_rate_ms:
if(self.frame < len(self.animation) - 1):
self.frame += 1
else:
self.frame = 0
def draw(self,screen):
if self.live:
self.image = self.animation[self.frame]
screen.blit(self.image,self.rect)