Guest User

Untitled

a guest
Aug 9th, 2018
84
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.FP
  6.    
  7.     public class Vihu1 extends Entity
  8.     {
  9.         [Embed(source = '/../lib/Art/alus1.png')] private const ALUS:Class;
  10.         public var health:Number = 3;
  11.         public var Sine:Number = 180;
  12.         public var oldX:int;
  13.         public var time:Boolean;
  14.         public var freq:int = Math.random()*2 + 5;
  15.         public var speed:int = 40;
  16.         public var timer_shoot:Number = 0;
  17.        
  18.         public function Vihu1(x:int, y:int, time:Boolean)
  19.         {
  20.             this.time = time;
  21.             super(x, y);
  22.             graphic = new Image(ALUS);
  23.             oldX = this.x;
  24.             setHitbox(11, 6, 0, 0);
  25.             type = "Vihu";
  26.             timer_shoot = Math.random() * 70;
  27.         }
  28.        
  29.         override public function update(): void
  30.         {
  31.            
  32.             if (Kentta.time == false)
  33.             {
  34.                 timer_shoot += 1;
  35.             }
  36.            
  37.             if (timer_shoot >= 80 && Kentta.time == false)
  38.             {
  39.                 timer_shoot = 0;
  40.                 world.add(new e_Panos(x + 5, y + 3, Math.atan2(y - Kentta.player.y, Kentta.player.x - x), time));
  41.                 trace(Math.atan2(y - Kentta.player.y, x - Kentta.player.x));
  42.             }
  43.            
  44.             var coll:p_Laser = collide("omabullet", x, y) as p_Laser;
  45.            
  46.             if (coll)
  47.             {
  48.                 coll.destroy();
  49.                 health -= 1;
  50.             }
  51.            
  52.             if (health <= 0 || y > 126)
  53.             {
  54.                 FP.world.remove(this);
  55.             }
  56.            
  57.         }
  58.        
  59.         public function destroy():void
  60.         {
  61.             graphic = null;
  62.             FP.world.remove(this);
  63.         }
  64.        
  65.     }
  66.  
  67. }
Add Comment
Please, Sign In to add comment