Advertisement
Guest User

Untitled

a guest
May 27th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package  
  2. {
  3.     import org.flixel.FlxSprite;
  4.     import pixelperfectoverlap.FlxSpriteEx;
  5.     import org.flixel.FlxG;
  6.    
  7.    
  8.     /**
  9.      * ...
  10.      * @author Kristian Macanga
  11.      */
  12.     public class Player extends FlxSpriteEx
  13.     {
  14.        
  15.         private const GRAVITY:int = 200;
  16.    
  17.         protected var flm:int = 0;
  18.         protected var name:String = "";
  19.         protected var msg:String = "";
  20.        
  21.         protected var boost:Boolean = false;
  22.         protected var pack:Boolean = false;
  23.         protected var rightFace:int = 1;
  24.         protected var ammo:int = 0;
  25.         protected var backAmmo:int = 0;
  26.         protected var canShoot:Boolean = true;
  27.        
  28.         protected var pHealth:int = 50;
  29.         protected var life:int = 3;
  30.         protected var char:int = 0;
  31.        
  32.         protected var jumpPower:int = 100;
  33.         protected var runSpeed:int = 100;
  34.         protected var swimSpeed:int = 100;
  35.         protected var special:String = "";
  36.  
  37.  
  38.         public function Player(costume:Class)
  39.         {
  40.             super(120, 0);
  41.             loadGraphic(costume, true, true);
  42.             setOrigin(0, 0);
  43.             addAnimation("normal", [0]);
  44.             addAnimation("jumping", [1]);
  45.             addAnimation("midAir", [2]);
  46.             addAnimation("falling", [3]);
  47.             addAnimation("running", [4, 5, 6, 7, 8], 15, true);
  48.             play("normal", true);
  49.             Global.spriteLayer.add(this);
  50.            
  51.             acceleration.y = GRAVITY;
  52.             cameraFollow();
  53.         }
  54.        
  55.         private function setAnimation():void
  56.         {
  57.            
  58.             if ( FlxG.keys.LEFT || FlxG.keys.A )
  59.             {
  60.                 play("running", false);
  61.                 facing = LEFT;
  62.             }
  63.             else if ( FlxG.keys.RIGHT || FlxG.keys.D )
  64.             {
  65.                 play("running", false);
  66.                 facing = RIGHT;
  67.             }
  68.             else
  69.             {
  70.                 play("normal", true);
  71.             }
  72.            
  73.            
  74.         }
  75.        
  76.         private function cameraFollow():void
  77.         {
  78.             FlxG.follow(this, 0.1);
  79.             FlxG.followBounds(x - FlxG.width / 8, y - FlxG.height / 8, x + FlxG.width / 8, y + FlxG.height / 8);
  80.         }
  81.        
  82.         override public function update():void
  83.         {
  84.             super.update();
  85.             setAnimation();
  86.  
  87.         }
  88.        
  89.     }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement