CNSA-266-FP/Bullet.py

51 lines
1.5 KiB
Python
Raw Normal View History

2024-04-23 20:14:24 -04:00
import arcade
BULLET_SPEED = 4
class Bullet(arcade.Sprite):
def __init__(self, SCREEN_SCALE, DEBUG, x, y):
super().__init__()
self.isAlive = True
self.deBuggin = DEBUG
self.scScale = SCREEN_SCALE
self.i = 0
if self.deBuggin:
print("Bullet Initializing")
image_source = "assets/Sprites/Player/PlayerBullet.png"
self.bullet_sprite = arcade.Sprite(image_source, self.scScale)
self.center_x = x + (1 * self.scScale) / 2
self.center_y = y + 4 * self.scScale
def update(self):
self.center_y = self.center_y + (BULLET_SPEED * self.scScale)
self.bullet_sprite.center_y = self.center_y
self.bullet_sprite.center_x = self.center_x
# self.bullet_sprite.draw(pixelated=True)
if self.deBuggin:
self.i += 1
if self.i >= 10:
self.i = 0
print("Bullet Updating | X: " + str(self.center_x) + " | Y: " + str(self.center_y) + " ||| SX: " + str(self.bullet_sprite.center_x) + " | SY: " + str(self.bullet_sprite.center_y))
def getX(self):
return self.center_x
def getY(self):
return self.center_y
def death(self):
if self.deBuggin:
print("Bullet Deathing")
self.isAlive = False
self.data = None
self.__del__()
def __del__(self):
self.isAlive = False
if self.deBuggin:
print("Bullet Dead")