diff --git a/game/play.py b/game/play.py index 5fd3b38..78fa7af 100644 --- a/game/play.py +++ b/game/play.py @@ -4,17 +4,16 @@ from utils.constants import BULLET_SPEED, IRS_AGENT_HEALTH, HEALTH_INCREASE_PER_ from utils.constants import IRS_AGENT_SPAWN_INTERVAL, SPAWN_INTERVAL_DECREASE_PER_LEVEL, SPEED_INCREASE_PER_LEVEL from utils.constants import TAX_EVASION_LEVELS, TAX_EVASION_NAMES, TAX_INCREASE_PER_LEVEL, menu_background_color, INVENTORY_ITEMS, INVENTORY_TRIGGER_KEYS +import utils.preload from utils.preload import irs_agent_texture from utils.preload import light_wizard_left_animation, light_wizard_right_animation, light_wizard_standing_animation, light_wizard_up_animation from utils.preload import dark_wizard_left_animation, dark_wizard_right_animation, dark_wizard_standing_animation, dark_wizard_up_animation from game.inventory import Inventory -class Bullet(arcade.SpriteCircle): - def __init__(self, radius, x, y, direction, color): - super().__init__(radius=radius, color=color) - self.center_x = x - self.center_y = y +class Bullet(arcade.Sprite): + def __init__(self, radius, texture, x, y, direction): + super().__init__(texture, center_x=x, center_y=y) self.radius = radius self.direction = direction @@ -79,11 +78,10 @@ class Game(arcade.gui.UIView): self.last_shoot = time.perf_counter() self.evaded_tax = 0 + self.high_score = self.data["high_score"] self.mana = 0 self.tax_evasion_level = TAX_EVASION_NAMES[0] - self.high_score = self.data["high_score"] - self.bullets: list[Bullet] = [] self.highscore_evaded_tax = self.data["high_score"] self.player = Player(self.window.width / 2, self.window.height / 2) @@ -108,26 +106,10 @@ class Game(arcade.gui.UIView): self.inventory.pay_tax_button.on_click = lambda event: self.pay_tax() def spawn_bullet(self, direction): - bullet = Bullet(INVENTORY_ITEMS[self.inventory.current_inventory_item][3], self.player.center_x, self.player.center_y, direction, arcade.color.BLUE) + bullet = Bullet(INVENTORY_ITEMS[self.inventory.current_inventory_item][3], getattr(utils.preload, INVENTORY_ITEMS[self.inventory.current_inventory_item][4]), self.player.center_x, self.player.center_y, direction) self.bullets.append(bullet) self.spritelist.append(bullet) - def auto_shoot(self): - closest_dist = 999999 - closest_direction = None - - for irs_agent in self.irs_agents: - distance = arcade.math.Vec2(self.player.center_x, self.player.center_y).distance((irs_agent.center_x, irs_agent.center_y)) - - if distance < closest_dist: - closest_dist = distance - closest_direction = (arcade.math.Vec2(irs_agent.center_x, irs_agent.center_y) - (self.player.center_x, self.player.center_y)).normalize() - - if not closest_dist or not closest_direction: - return - - self.spawn_bullet(closest_direction) - def get_current_level_int(self): return TAX_EVASION_NAMES.index(self.tax_evasion_level) @@ -276,9 +258,6 @@ class Game(arcade.gui.UIView): self.high_score = self.evaded_tax self.high_score_label.text = f"High Score: {int(self.high_score)}$" - def on_show_view(self): - super().on_show_view() - def on_key_press(self, symbol, modifiers): if symbol == arcade.key.ESCAPE: self.data["high_score"] = int(self.high_score) diff --git a/utils/constants.py b/utils/constants.py index 57a69dc..8e38187 100644 --- a/utils/constants.py +++ b/utils/constants.py @@ -28,10 +28,9 @@ SHOP_ITEMS = [] PLAYER_SPEED = 4 INVENTORY_ITEMS = [ - ["Fireball", 0.2, 10, 10], - ["Lightning Bolt", 0.4, 20, 20], - ["Ice Blast", 0.1, 5, 7.5], - ["Arcane Beam", 0.2, 20, 15], + ["Fireball", 0.2, 10, 10, "fireball_texture"], + ["Lightning Bolt", 0.4, 20, 20, "lightning_bolt_texture"], + ["Ice Blast", 0.1, 5, 7.5, "ice_blast_texture"], ] INVENTORY_TRIGGER_KEYS = [getattr(arcade.key, f"KEY_{n+1}") for n in range(len(INVENTORY_ITEMS))] diff --git a/utils/preload.py b/utils/preload.py index 1c9e64c..bf8a816 100644 --- a/utils/preload.py +++ b/utils/preload.py @@ -15,4 +15,8 @@ dark_wizard_right_animation = arcade.TextureAnimation([arcade.TextureKeyframe(te dark_wizard_standing_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in dark_wizard_spritesheet[6:8]]) dark_wizard_left_animation = arcade.TextureAnimation([arcade.TextureKeyframe(texture, 300) for texture in dark_wizard_spritesheet[9:11]]) +fireball_texture = arcade.make_circle_texture(10, arcade.color.RED) +lightning_bolt_texture = arcade.make_circle_texture(20, arcade.color.BLUE) +ice_blast_texture = arcade.make_circle_texture(20, arcade.color.ICEBERG) + irs_agent_texture = arcade.load_texture("assets/graphics/irs_agent.png") \ No newline at end of file