-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.py
72 lines (46 loc) · 1.6 KB
/
player.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
import pygame
# CONSTANTES
RED = (255, 0, 0)
BLACK = (0, 0, 0)
BLUE = (0, 0, 255)
WHITE = (255, 255, 255)
PLANE_SIZE = 40 # Ancho y alto del avion (JUGADOR Y TODOS LOS TIPOS DE ENEMIGOS)
class Player:
# Player position corresponde a las coordenadas del jugador: player_position[WIDTH, HEIGTH] [X,Y]
def __init__(self, player_position):
self.picture = pygame.image.load("pictures/nave1.png")
self.picture.set_colorkey(WHITE)
self.health = 100
self.position = player_position
self.level = 0
# self.center = [player_position[0] + PLANE_SIZE // 2, player_position[1] + PLANE_SIZE // 2]
# self.radius = PLANE_SIZE // 2
def get_position(self):
return self.position
def get_picture(self):
return self.picture
def get_health(self):
return self.health
def set_damage(self, damage_points):
self.health -= damage_points
def set_healing(self, healing_points):
self.health += healing_points
def increase_level(self):
self.level += 1
def decrease_level(self):
self.level -= 1
def get_level(self):
return self.level
# Player movements
def move(self, new_player_position):
self.position = new_player_position
def move_left(self, distance):
self.position[0] -= distance
def move_right(self, distance):
self.position[0] += distance
def move_up(self, distance):
self.position[1] -= distance
def move_down(self, distance):
self.position[1] += distance
def revive(self):
self.health = 100