Changeset 356:582a96e5fdac


Ignore:
Timestamp:
Sep 6, 2013, 4:41:29 PM (7 years ago)
Author:
David Sharpe
Branch:
default
Message:

Tweaks to the claw attack.

Location:
nagslang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r354 r356  
    461461
    462462class ClawAttack(GameObject):
    463     def __init__(self, space, position, vector, damage):
    464         body = make_body(1, pymunk.inf, position)
     463    def __init__(self, space, pos, vector, damage):
     464        body = make_body(1, pymunk.inf,
     465                         (pos[0] + (vector.length * math.cos(vector.angle)),
     466                         pos[1] + (vector.length * math.sin(vector.angle))))
    465467        body.angle = vector.angle
    466468        self.shape = pymunk.Circle(body, 30)
     
    474476                transforms=(FLIP_H,))),
    475477        )
    476         self.physicser.apply_impulse(vector)
    477478
    478479    def update(self, dt):
  • nagslang/protagonist.py

    r341 r356  
     1import math
     2
    13import pymunk
    24import pymunk.pygame_util
     
    298300
    299301    def claw(self):
    300         vec = vec_from_angle(self.angle, 300)
     302        claw_range = (math.sqrt(math.pow(self.physicser.get_velocity()[0], 2) +
     303                                math.pow(self.physicser.get_velocity()[1], 2))
     304                      / 20) + 30
     305        vec = vec_from_angle(self.angle, claw_range)
    301306        ClawEvent.post(self.physicser.position, vec, CLAW_DAMAGE)
    302307
Note: See TracChangeset for help on using the changeset viewer.