Skip to content

Commit

Permalink
i dont have code block anymore :D
Browse files Browse the repository at this point in the history
  • Loading branch information
AnimatingLegend committed Mar 19, 2022
1 parent 8116409 commit 8966a19
Showing 1 changed file with 66 additions and 1 deletion.
67 changes: 66 additions & 1 deletion source/BackgroundTankmen.hx
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,70 @@ using StringTools;

class BackgroundTankmen extends FlxSprite
{
// CODE BLOCK.

public var tankSpeed:Float = 0.7 * 1000;
public var goingRight:Bool = false;
var runAnimPlayedTimes:Int = 0;
var runAnimPlayedTimesMax:Int = 1;

override public function new()
{
super();
frames = Paths.getSparrowAtlas("warzone/tankmanKilled1");
antialiasing = true;
animation.addByPrefix("run", "tankman running", 24, false);
animation.addByPrefix("shot", "John Shot" + FlxG.random.int(1,2), 24, false);
animation.play("run");

updateHitbox();
setGraphicSize(Std.int(width * 0.8));
updateHitbox();
}

public function resetShit (xPos:Float, yPos:Float, right:Bool, ?stepsMax:Int, ?speedModifier:Float = 1)
{
x = xPos;
y = yPos;

goingRight = right;

if(stepsMax == null)
{
stepsMax = 1;
}

if(speedModifier == null)
{
speedModifier = 1;
}

runAnimPlayedTimesMax = stepsMax;

var newSpeedModifier:Float = speedModifier * 2;

tankSpeed = FlxG.random.float(0.5, 1) * 165;
}
override public function update(elapsed:Float)
{
super.update(elapsed);


if(animation.curAnim.name == "run" && animation.curAnim.finished == true && runAnimPlayedTimes < runAnimPlayedTimesMax)
{
animation.play("run", true);
runAnimPlayedTimes++;
}

if(animation.curAnim.name == "run" && animation.curAnim.finished == true && runAnimPlayedTimes >= runAnimPlayedTimesMax)
{
animation.play("shot", true);
runAnimPlayedTimes = 0;
}

if(animation.curAnim.name == "shot" && animation.curAnim.curFrame >= animation.curAnim.frames.length - 1)
{
destroy();
}
}

}

0 comments on commit 8966a19

Please sign in to comment.