Changeset 361:534eac55a178


Ignore:
Timestamp:
Sep 6, 2013, 6:10:46 PM (7 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
rebase_source:
3790efc1ab742467f0feadb3c15e49c594796bb3
Message:

ChargingEnemy? spits acid

Location:
nagslang
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • nagslang/constants.py

    r336 r361  
    5555BULLET_DAMAGE = 10
    5656CLAW_DAMAGE = 5
     57ACID_DAMAGE = 7
     58
     59BULLET_SPEED = 1000
     60ACID_SPEED = 300
    5761
    5862CMD_TOGGLE_FORM = 'toggle_form'
  • nagslang/enemies.py

    r358 r361  
    66from nagslang import render
    77from nagslang.constants import (COLLISION_TYPE_ENEMY, COLLISION_TYPE_FURNITURE,
    8                                 ZORDER_MID)
    9 from nagslang.events import EnemyDeathEvent
     8                                ACID_SPEED, ACID_DAMAGE, ZORDER_MID)
     9from nagslang.events import EnemyDeathEvent, FireEvent
    1010from nagslang.game_object import GameObject, SingleShapePhysicser, make_body
    1111from nagslang.mutators import FLIP_H
     
    180180    enemy_damage = 20
    181181    impulse_factor = 300
     182    reload_time = 0.2
    182183
    183184    def __init__(self, space, world, position, attack_range=100):
    184185        super(ChargingAlien, self).__init__(space, world, position)
    185186        self._range = attack_range
     187        self._last_fired = 0
    186188
    187189    def make_physics(self, space, position):
     
    214216            return
    215217        self.is_moving = True
    216         self.set_direction(target.x - pos.x, target.y - pos.y)
     218        dx = target.x - pos.x
     219        dy = target.y - pos.y
     220        self.set_direction(dx, dy)
     221        if self.lifetime - self._last_fired >= self.reload_time:
     222            FireEvent.post(pos, vec_with_length((dx, dy), ACID_SPEED),
     223                           ACID_DAMAGE, COLLISION_TYPE_ENEMY)
     224            self._last_fired = self.lifetime
    217225        super(ChargingAlien, self).update(dt)
    218226
  • nagslang/protagonist.py

    r357 r361  
    88    COLLISION_TYPE_PLAYER, ZORDER_MID, WEREWOLF_SOAK_FACTOR,
    99    PROTAGONIST_HEALTH_MIN_LEVEL, PROTAGONIST_HEALTH_MAX_LEVEL,
    10     NON_GAME_OBJECT_COLLIDERS, BULLET_DAMAGE, CLAW_DAMAGE,
     10    NON_GAME_OBJECT_COLLIDERS, BULLET_DAMAGE, BULLET_SPEED, CLAW_DAMAGE,
    1111    CMD_TOGGLE_FORM, CMD_ATTACK, CMD_ACTION)
    1212from nagslang.events import FireEvent, ClawEvent
     
    298298        if not self.has_item('gun'):
    299299            return
    300         vec = vec_from_angle(self.angle, 1000)
     300        vec = vec_from_angle(self.angle, BULLET_SPEED)
    301301        FireEvent.post(
    302302            self.physicser.position, vec, BULLET_DAMAGE, COLLISION_TYPE_PLAYER)
Note: See TracChangeset for help on using the changeset viewer.