-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseBullet.py
More file actions
44 lines (37 loc) · 1.54 KB
/
BaseBullet.py
File metadata and controls
44 lines (37 loc) · 1.54 KB
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
from Entity import *
from Vector2 import *
from CollisionManager import *
from Enemy import *
import pygame
'''
Average size and faster speed bullet
'''
class BaseBullet(Entity):
def __init__(self, spawnX, spawnY, aimX, aimY, speed):
self.speed = speed
Entity.__init__(self, spawnX, spawnY, 10, 10, aimX*speed, aimY*speed)
self.isAlive = True
self.hitPoints = 1
self.colBoxAnchorOffset = Vector2(0,0)
self.collisionBox = CollisionManager.buildCollisionBox(self.position.x + self.colBoxAnchorOffset.x,
self.position.y + self.colBoxAnchorOffset.y,
self.dimensions.x, self.dimensions.y, self)
def handleBoundHit(self, direction):
#base functionality, if I go off the screen, I die
if(direction[0] != 0 or direction[1] != 0):
self.isAlive = False
self.hitPoints = 0
self.updateCollisionBox()
def moveIt(self):
self.position.x += self.velocity.x
self.position.y += self.velocity.y
self.updateCollisionBox()
def drawIt(self,screen):
pygame.draw.rect(screen, (255,255,0), self.toRect())
def update(self, screen, lowBound, upBound):
self.moveIt()
self.handleBoundHit(self.collisionBox.checkBoundHit(lowBound, upBound))
if(self.hitPoints == 0):
self.isAlive = False
if(self.isAlive==True):
self.drawIt(screen)