home *** CD-ROM | disk | FTP | other *** search
- package com.lofiminds.gm
- {
- import flash.geom.ColorTransform;
-
- public class GameObject
- {
-
-
- public var hasColorTransform:Boolean = false;
-
- public var colorTransform:ColorTransform;
-
- public var depth:int;
-
- public var gravityY:Number = 0;
-
- public var vspeed:Number = 0;
-
- public var useCustomDraw:Boolean;
-
- public var image:GameImage;
-
- public var hspeed:Number = 0;
-
- public var image_speed:Number = 0;
-
- public var image_count:Number = 0;
-
- public var image_index:Number = 0;
-
- public var image_angle:Number = 0;
-
- public var x:Number = 0;
-
- public var y:Number = 0;
-
- public var friction:Number = 0;
-
- internal var collisionData:CollisionData;
-
- public function GameObject()
- {
- colorTransform = new ColorTransform();
- collisionData = new CollisionData();
- super();
- }
-
- public function destroy() : void
- {
- }
-
- public function getClass() : Class
- {
- throw new Error("baseclass getClass() called, must override");
- }
-
- public function update() : void
- {
- var _loc1_:Number = NaN;
- if(image_speed != 0)
- {
- image_index += image_speed;
- if(image_index >= image_count)
- {
- image_index -= image_count;
- animationEnd();
- }
- else if(image_index < 0)
- {
- image_index += image_count;
- animationEnd();
- }
- }
- x += hspeed;
- y += vspeed;
- vspeed += gravityY;
- if(friction != 0)
- {
- _loc1_ = getSpeed();
- _loc1_ = Math.max(_loc1_ - friction,0);
- setSpeedAndDirection(_loc1_,getDirection());
- }
- }
-
- public function onCollision(param1:CollisionContext) : void
- {
- }
-
- final public function getDirection() : Number
- {
- return 0 - Math.atan2(vspeed,hspeed);
- }
-
- final public function setImage(param1:GameImage) : void
- {
- if(image == param1)
- {
- return;
- }
- image = param1;
- image_count = param1.frameCount;
- }
-
- public function set image_blend(param1:uint) : void
- {
- var _loc2_:uint = uint(param1 >> 16 & 255);
- var _loc3_:uint = uint(param1 >> 8 & 255);
- var _loc4_:uint = uint(param1 & 255);
- colorTransform.redMultiplier = _loc2_ / 255;
- colorTransform.greenMultiplier = _loc3_ / 255;
- colorTransform.blueMultiplier = _loc4_ / 255;
- hasColorTransform = true;
- }
-
- final public function getSpeed() : Number
- {
- return Math.sqrt(hspeed * hspeed + vspeed * vspeed);
- }
-
- final public function setSpeedAndDirection(param1:Number, param2:Number) : void
- {
- param2 = 0 - param2;
- hspeed = Math.cos(param2) * param1;
- vspeed = Math.sin(param2) * param1;
- }
-
- public function onCustomDraw(param1:GameGraphics) : Boolean
- {
- return true;
- }
-
- final public function motionAdd(param1:Number, param2:Number) : void
- {
- param1 = 0 - param1;
- hspeed += Math.cos(param1) * param2;
- vspeed += Math.sin(param1) * param2;
- }
-
- final internal function prepareCollisionData() : void
- {
- var _loc3_:Number = NaN;
- var _loc4_:Number = NaN;
- var _loc5_:Number = NaN;
- var _loc1_:CollisionData = this.collisionData;
- var _loc2_:Number = _loc1_.lastAngle - image_angle;
- if(Math.abs(_loc2_) > 0.05)
- {
- _loc1_.lastAngle = image_angle;
- _loc1_.isAABB = image_angle == 0;
- _loc3_ = 0 - image_angle;
- _loc4_ = Math.sin(_loc3_);
- _loc5_ = Math.cos(_loc3_);
- _loc1_.obbAxisX.x = _loc5_;
- _loc1_.obbAxisX.y = _loc4_;
- _loc1_.obbAxisY.x = -_loc4_;
- _loc1_.obbAxisY.y = _loc5_;
- }
- if(_loc1_.lastImage != this.image)
- {
- _loc1_.lastImage = this.image;
- _loc1_.aabbRect.width = image.boundsWidth;
- _loc1_.aabbRect.height = image.boundsHeight;
- _loc1_.obbExtentX = image.boundsHalfWidth;
- _loc1_.obbExtentY = image.boundsHalfHeight;
- }
- if(_loc1_.isAABB)
- {
- _loc1_.aabbRect.x = x - image.boundsHalfWidth;
- _loc1_.aabbRect.y = y - image.boundsHalfHeight;
- }
- _loc1_.obbCenterX = x;
- _loc1_.obbCenterY = y;
- }
-
- public function animationEnd() : void
- {
- }
- }
- }
-