-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectile.py
35 lines (26 loc) · 928 Bytes
/
Projectile.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
import pygame
projectile_speed = 1
projectile_dimensions = (10, 10)
class Projectile:
def __init__(self, x, y):
self.x = x
self.y = y
self.speed = projectile_speed
def move(self):
self.y -= self.speed
def draw(self,window):
#pygame.draw.circle(window, (255, 255, 0), (self.x, self.y, 10 , 10))
pygame.draw.circle(window, (255, 255, 0), (self.x, self.y), 2)
#draw the projectile
#window.blit(self.image, (self.x, self.y))
def update(self,window):
self.move()
self.draw(window)
def off_screen(self, height):
return self.y < 0 or self.y > height
def get_rect(self):
return pygame.Rect(self.x, self.y, 10, 10)
def collides_with(self, enemy):
projectile_rect = self.get_rect()
enemy_rect = enemy.get_rect()
return projectile_rect.colliderect(enemy_rect)