-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer2.py
More file actions
27 lines (22 loc) · 763 Bytes
/
player2.py
File metadata and controls
27 lines (22 loc) · 763 Bytes
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
import pygame
from projectile import Projectile
class Player(pygame.sprite.Sprite):
def __init__(self, game):
super().__init__()
self.game = game
self.health = 100
self.max_health= 100
self.attack= 10
self.velocity=5
self.all_projectiles = pygame.sprite.Group()
self.image=pygame.image.load('assets/player.png')
self.rect = self.image.get_rect()
self.rect.x = 400
self.rect.y = 500
def launch_projectile(self):
self.all_projectiles.add(Projectile(self))
def move_right(self):
if not self.game.check_collision(self, self.game.all_monsters):
self.rect.x += self.velocity
def move_left(self):
self.rect.x -= self.velocity