2021-03-16 05:51:23 +00:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxG;
|
|
|
|
import flixel.FlxSprite;
|
2021-03-17 09:20:25 +00:00
|
|
|
import haxe.display.Display.Package;
|
2021-03-16 05:51:23 +00:00
|
|
|
|
|
|
|
class TankmenBG extends FlxSprite
|
|
|
|
{
|
2021-03-30 20:58:05 +00:00
|
|
|
public static var animationNotes:Array<Dynamic> = [];
|
|
|
|
|
2021-03-17 09:20:25 +00:00
|
|
|
public var strumTime:Float = 0;
|
|
|
|
public var goingRight:Bool = false;
|
|
|
|
public var tankSpeed:Float = 0.7;
|
|
|
|
|
|
|
|
public var endingOffset:Float;
|
|
|
|
|
2021-03-30 20:58:05 +00:00
|
|
|
public function new(x:Float, y:Float, isGoingRight:Bool)
|
2021-03-17 09:20:25 +00:00
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
|
|
|
|
// makeGraphic(200, 200);
|
|
|
|
|
|
|
|
frames = Paths.getSparrowAtlas('tankmanKilled1');
|
|
|
|
antialiasing = true;
|
|
|
|
animation.addByPrefix('run', 'tankman running', 24, true);
|
|
|
|
animation.addByPrefix('shot', 'John', 24, false);
|
|
|
|
|
|
|
|
animation.play('run');
|
2021-04-01 23:39:03 +00:00
|
|
|
animation.curAnim.curFrame = FlxG.random.int(0, animation.curAnim.numFrames - 1);
|
2021-03-17 09:20:25 +00:00
|
|
|
|
2021-03-30 20:58:05 +00:00
|
|
|
goingRight = isGoingRight;
|
|
|
|
endingOffset = FlxG.random.float(50, 200);
|
2021-03-16 05:51:23 +00:00
|
|
|
|
2021-03-30 20:58:05 +00:00
|
|
|
tankSpeed = FlxG.random.float(0.6, 1);
|
2021-03-16 05:51:23 +00:00
|
|
|
|
2021-03-17 09:20:25 +00:00
|
|
|
if (goingRight)
|
|
|
|
flipX = true;
|
|
|
|
}
|
2021-03-16 05:51:23 +00:00
|
|
|
|
2021-03-17 09:20:25 +00:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
super.update(elapsed);
|
2021-03-16 05:51:23 +00:00
|
|
|
|
2021-03-17 09:20:25 +00:00
|
|
|
if (animation.curAnim.name == 'run')
|
|
|
|
{
|
|
|
|
var endDirection:Float = (FlxG.width * 0.74) + endingOffset;
|
2021-03-16 05:51:23 +00:00
|
|
|
|
2021-03-17 09:20:25 +00:00
|
|
|
if (goingRight)
|
|
|
|
{
|
|
|
|
endDirection = (FlxG.width * 0.02) - endingOffset;
|
2021-03-16 05:51:23 +00:00
|
|
|
|
2021-03-17 09:20:25 +00:00
|
|
|
x = (endDirection + (Conductor.songPosition - strumTime) * tankSpeed);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = (endDirection - (Conductor.songPosition - strumTime) * tankSpeed);
|
|
|
|
}
|
|
|
|
}
|
2021-03-16 05:51:23 +00:00
|
|
|
|
2021-03-17 09:20:25 +00:00
|
|
|
if (Conductor.songPosition > strumTime)
|
|
|
|
{
|
|
|
|
// kill();
|
|
|
|
animation.play('shot');
|
2021-03-16 05:51:23 +00:00
|
|
|
|
2021-03-17 09:20:25 +00:00
|
|
|
if (goingRight)
|
|
|
|
{
|
|
|
|
offset.y = 200;
|
|
|
|
offset.x = 300;
|
|
|
|
}
|
|
|
|
}
|
2021-03-16 05:51:23 +00:00
|
|
|
|
2021-03-17 09:20:25 +00:00
|
|
|
if (animation.curAnim.name == 'shot' && animation.curAnim.curFrame >= animation.curAnim.frames.length - 1)
|
|
|
|
{
|
|
|
|
kill();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|