initial commit, kind of working.
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
package com.arc.dh.entities
|
||||
{
|
||||
import com.arc.dh.state.TadpoleMode;
|
||||
import com.arc.dh.util.Data;
|
||||
import com.arc.flixel.ArcSprite;
|
||||
import com.arc.flixel.ArcU;
|
||||
import org.flixel.FlxG;
|
||||
|
||||
public class PlayerTadpole extends ArcSprite
|
||||
{
|
||||
|
||||
public static const sprite:Class = PlayerTadpole_sprite;
|
||||
|
||||
private static const DY:Number = 400;
|
||||
|
||||
private static const MAXVY:Number = 100;
|
||||
|
||||
private var _dead:Boolean = false;
|
||||
|
||||
public function PlayerTadpole(param1:Number, param2:Number)
|
||||
{
|
||||
super(param1,param2);
|
||||
loadRotatedGraphic(sprite,60,-1,true,true);
|
||||
width = height = 2;
|
||||
offset.x = offset.y = 6;
|
||||
angle = 90;
|
||||
this.draw();
|
||||
}
|
||||
|
||||
override public function update() : void
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
if(!this._dead)
|
||||
{
|
||||
if(this.held())
|
||||
{
|
||||
velocity.y -= FlxG.elapsed * DY;
|
||||
}
|
||||
else
|
||||
{
|
||||
velocity.y += FlxG.elapsed * DY;
|
||||
}
|
||||
velocity.y = ArcU.clamp(velocity.y,-MAXVY,MAXVY);
|
||||
_loc1_ = Math.atan2(velocity.y,MAXVY);
|
||||
angle = 180 / Math.PI * _loc1_ + 45;
|
||||
}
|
||||
else
|
||||
{
|
||||
velocity.x = 0;
|
||||
velocity.y = 0;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
override public function draw() : void
|
||||
{
|
||||
super.draw();
|
||||
if(Data.state.player.shielded)
|
||||
{
|
||||
Data.state.player.drawShield(x - 7,y - 7);
|
||||
Data.state.player.drawShield(x - 7,y - 7);
|
||||
}
|
||||
}
|
||||
|
||||
private function held() : Boolean
|
||||
{
|
||||
return FlxG.mouse.pressed() || FlxG.keys.SPACE || FlxG.keys.W || FlxG.keys.UP;
|
||||
}
|
||||
|
||||
private function get speed() : Number
|
||||
{
|
||||
return (Data.state as TadpoleMode).camera.velocity.x;
|
||||
}
|
||||
|
||||
public function die() : void
|
||||
{
|
||||
this._dead = true;
|
||||
}
|
||||
|
||||
public function isDead() : Boolean
|
||||
{
|
||||
return this._dead;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user