home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / xwung.swf / scripts / com / lofiminds / xwung / Hitbox.as < prev    next >
Encoding:
Text File  |  2008-09-03  |  2.2 KB  |  70 lines

  1. package com.lofiminds.xwung
  2. {
  3.    import com.lofiminds.gm.CollisionContext;
  4.    import com.lofiminds.gm.GameImage;
  5.    import com.lofiminds.gm.GameObject;
  6.    import com.lofiminds.gm.GameUtil;
  7.    import com.lofiminds.gm.Instances;
  8.    import flash.display.Bitmap;
  9.    
  10.    public class Hitbox extends GameObject
  11.    {
  12.       
  13.       private static var gameImage:GameImage = new GameImage(Bitmap(new GxClass()).bitmapData,24,24,10,6).setOrigin(12,13);
  14.       
  15.       private static var GxClass:Class = Hitbox_GxClass;
  16.        
  17.       
  18.       public function Hitbox()
  19.       {
  20.          super();
  21.          setImage(gameImage);
  22.          image_speed = 0.2;
  23.          depth = 3;
  24.       }
  25.       
  26.       override public function destroy() : void
  27.       {
  28.          var _loc1_:Number = NaN;
  29.          var _loc3_:int = 0;
  30.          var _loc4_:GameObject = null;
  31.          _loc1_ = image_angle + Math.PI / 4;
  32.          _loc3_ = 0;
  33.          while(_loc3_ < 4)
  34.          {
  35.             (_loc4_ = Instances.create(Debris,x + GameUtil.lengthdir_x(11,_loc1_),y + GameUtil.lengthdir_y(11,_loc1_))).setSpeedAndDirection(4,_loc1_);
  36.             _loc4_.image_angle = image_angle;
  37.             _loc1_ += Math.PI * 0.5;
  38.             _loc3_++;
  39.          }
  40.          var _loc2_:int = int(GameUtil.randomRange(6,3));
  41.          _loc1_ = Math.random() * Math.PI * 2;
  42.          _loc3_ = 0;
  43.          while(_loc3_ < _loc2_)
  44.          {
  45.             (_loc4_ = Instances.create(Explosion,x,y)).setSpeedAndDirection(4 + Math.random() * 12,_loc1_);
  46.             _loc1_ += Math.PI * 2 / _loc2_;
  47.             _loc3_++;
  48.          }
  49.          _loc3_ = 0;
  50.          while(_loc3_ < 15 + int(Math.random() * 10))
  51.          {
  52.             (_loc4_ = Instances.create(Blip,x + GameUtil.randomRange(0,20),y + GameUtil.randomRange(0,20))).setSpeedAndDirection(Math.random() * 3,GameUtil.point_direction(x,y,_loc4_.x,_loc4_.y));
  53.             _loc4_.image_speed = 0.3 + Math.random() * 0.7;
  54.             _loc3_++;
  55.          }
  56.       }
  57.       
  58.       override public function getClass() : Class
  59.       {
  60.          return Hitbox;
  61.       }
  62.       
  63.       override public function onCollision(param1:CollisionContext) : void
  64.       {
  65.          Instances.destroy(this);
  66.          Instances.destroy(Instances.getFirst(Player));
  67.       }
  68.    }
  69. }
  70.