Guest User

Untitled

a guest
Aug 4th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package  
  2. {
  3.     import net.flashpunk.Entity;
  4.     import net.flashpunk.graphics.Image;
  5.     import net.flashpunk.utils.Input;
  6.     import net.flashpunk.utils.Key;
  7.     import net.flashpunk.FP
  8.    
  9.     public class Pelaaja extends Entity
  10.     {
  11.         [Embed(source ='/../lib/Art/alusp.png')] private const PELAAJA:Class
  12.         public var speed:int;
  13.         public var spralus:Image = new Image(PELAAJA);
  14.         public var health:Number;
  15.         public var moving:Boolean;
  16.         public var level:Number = 0;
  17.         public var inputX:int = 0;
  18.         public var inputY:int = 0;
  19.         public var timer:Number = 0;
  20.         public var time:Boolean;
  21.        
  22.         public function Pelaaja(x:int, y:int, time:Boolean)
  23.         {
  24.             super(x, y);
  25.             graphic = spralus;
  26.             Input.define("Right", Key.RIGHT);
  27.             Input.define("Left", Key.LEFT);
  28.             Input.define("Up", Key.UP);
  29.             Input.define("Down", Key.DOWN);
  30.             Input.define("Shoot", Key.X);
  31.             Input.define("Timestop", Key.Z);
  32.             Input.define("Quit", Key.ESCAPE);
  33.             setHitbox(3, 4, -1, -2);
  34.             centerOrigin();
  35.             speed = 40;
  36.            
  37.         }
  38.        
  39.         override public function update(): void
  40.         {
  41.             inputX = 0;
  42.             inputY = 0;
  43.            
  44.             if (Input.check("Right"))
  45.             {
  46.                 inputX += 1;
  47.                 moving = true;
  48.             }
  49.            
  50.             if (Input.check("Left"))
  51.             {
  52.                 inputX -= 1;
  53.                 moving = true;
  54.             }
  55.            
  56.             if (Input.check("Up"))
  57.             {
  58.                 inputY -= 1;
  59.                 moving = true;
  60.             }
  61.            
  62.             if (Input.check("Down"))
  63.             {
  64.                 inputY += 1;
  65.                 moving = true;
  66.             }
  67.            
  68.             if (Input.check("Shoot") == true && level == 0 && timer == 0)
  69.             {
  70.                 world.add(new Laser1(x + 3, y, level, time));
  71.                 timer = 10;
  72.                 trace("niin");
  73.             }
  74.            
  75.             if (Input.check("Shoot") == true && level == 1 && timer == 0)
  76.             {
  77.                 world.add(new Laser1(x + 3, y, level, time));
  78.                 world.add(new Laser1(x, y + 2, level, time));
  79.                 world.add(new Laser1(x + 6, y + 2, level, time));
  80.                 timer = 10;
  81.                 trace("niin");
  82.             }
  83.            
  84.             if (Input.check("Timestop"))
  85.             {
  86.                 Kentta.time = true;
  87.             }
  88.             else
  89.             {
  90.                 Kentta.time = false;
  91.             }
  92.            
  93.             x += inputX * speed * FP.elapsed;
  94.             y += inputY * speed * FP.elapsed;
  95.            
  96.             if (inputX == 0 && inputY == 0)
  97.             {
  98.                 moving = false;
  99.             }
  100.            
  101.             if (timer > 0)
  102.             {
  103.                 timer -= 1;
  104.             }
  105.         }
  106.        
  107.     }
  108.  
  109. }
Add Comment
Please, Sign In to add comment