Added a sword that appears when doing a regular attack.
Justin Armstrong justinmeister@gmail.com
Tue, 22 Apr 2014 18:29:35 -0700
2 files changed,
36 insertions(+),
1 deletions(-)
A
data/components/attackitems.py
@@ -0,0 +1,33 @@
+""" +Attack equipment for battles. +""" +import copy +import pygame as pg +from .. import tools, setup + + +class Sword(object): + """ + Sword that appears during regular attacks. + """ + def __init__(self, player): + self.player = player + self.sprite_sheet = setup.GFX['shopsigns'] + self.image = tools.get_image(48, 0, 16, 16, self.sprite_sheet) + self.image = pg.transform.scale2x(self.image) + + @property + def rect(self): + new_rect = copy.copy(self.player.rect) + new_rect.right -= 10 + new_rect.top += 15 + return new_rect + + def draw(self, surface): + """ + Draw sprite to surface. + """ + if self.player.state == 'attack': + if self.player.x_vel % 5 == 0: + surface.blit(self.image, self.rect) +
M
data/states/battle.py
→
data/states/battle.py
@@ -4,7 +4,7 @@
import random import pygame as pg from .. import tools, battlegui, observer -from .. components import person, attack +from .. components import person, attack, attackitems from .. import constants as c@@ -29,6 +29,7 @@ self.info_box)
self.select_box = battlegui.SelectBox() self.player_health = battlegui.PlayerHealth(self.select_box.rect, self.game_data) + self.sword = attackitems.Sword(self.player) self.attacked_enemy = None self.attacking_enemy = None self.state = c.SELECT_ACTION@@ -176,5 +177,6 @@ surface.blit(self.info_box.image, self.info_box.rect)
surface.blit(self.select_box.image, self.select_box.rect) surface.blit(self.arrow.image, self.arrow.rect) self.player_health.draw(surface) + self.sword.draw(surface)