Permalink
Browse files

Enemies now no longer trigger at all unless they are on screen. It's …

…a bit fudgy, the code for this, but maybe I - or someone else - will be able to express it better later on
  • Loading branch information...
1 parent 1ca41ec commit cdf62e0d570905c9f4b38ebbec86c143d6a80742 @gavD committed Apr 17, 2012
View
1 src/uk/co/gavd/danmakuengine/HitTaker.as
@@ -2,7 +2,6 @@
import flash.filters.ColorMatrixFilter;
import fl.motion.AdjustColor;
import flash.display.MovieClip;
- import flash.events.Event;
import flash.media.Sound;
public class HitTaker {
View
12 src/uk/co/gavd/danmakuengine/enemies/Enemy.as
@@ -34,9 +34,11 @@
}
public function process():void {
+ if(!this.isOnScreen()) {
+ return;
+ }
if (game.hero.lAction != 0) {
- //trace("game not in play");
return;
}
@@ -111,9 +113,13 @@
}
+ protected function getOnScreenMin():uint {
+ return 777;
+ }
+
public function isOnScreen():Boolean {
- var foo:Number = (this.x - 580) * -1; // TODO 580 is a magic number
- if (game.BGMid.x < foo) {
+ var fudgedNumber:Number = (this.x - this.getOnScreenMin()) * -1;
+ if (game.BGMid.x < fudgedNumber) {
return true;
}
View
19 src/uk/co/gavd/danmakuengine/enemies/Guardian1.as
@@ -18,6 +18,10 @@
false,false,false,false,false,false,false,false,false,false,
true,false,false,true,false,false,true,false,false,true];
private var firePointer:int = 0;
+
+ private var targetX:Number = 0;
+ private var targetY:Number = 0;
+ private var gameAffected:Boolean = false;
public function Guardian1(game:Game) {
super(game);
@@ -42,24 +46,24 @@
} else if (this.y < 140) { // TODO magic number
this.yMovementPerFrame = MOVEMENT_SPEED;
}
-
+ }
+
+ override protected function getOnScreenMin():uint {
+ return 580;
}
override protected function handleMovementX():void {}
- protected override function getNewBullet():Bullet {
+ override protected function getNewBullet():Bullet {
return new BulletFast(game);
}
- private var targetX:Number = 0;
- private var targetY:Number = 0;
- private var gameAffected:Boolean = false;
- protected override function dieHook():void {
+ override protected function dieHook():void {
game.startScrolling();
}
override protected function doFire (lTargetX:Number, distFromHero:Number):Boolean {
- if(!gameAffected && this.isOnScreen()) {
+ if(!gameAffected) {
game.stopScrolling();
gameAffected = true;
}
@@ -97,6 +101,5 @@
return true;
}
-
}
}

0 comments on commit cdf62e0

Please sign in to comment.