Guest User

Untitled

a guest
May 16th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import org.flixel.*;
  4.    
  5.     public class Circular_Platform extends FlxSprite
  6.     {
  7.         [Embed(source = '../assets/elevator4.png')] private var elevatorPNG:Class;
  8.        
  9.    
  10.         public var newx:Number = 0;
  11.         public var newy:Number = 0;
  12.         public var placex:Number = 200;
  13.         public var placey:Number = 200;
  14.         public var length:Number = 80;
  15.         public var theangle:Number = 0;
  16.         public var angle_stepsize:Number = 1;
  17.        
  18.         public var player:Player;
  19.        
  20.         public function Circular_Platform(X:Number, Y:Number, Width:Number, Height:Number, Speed:int = 40)
  21.         {
  22.             super(X * 16, Y * 16, elevatorPNG);
  23.            
  24.             player = new Player(0,0);
  25.  
  26.             //int placex = 200;
  27.             //int placey = 200;// the center point of the circle will be at 200 x and 200 y
  28.  
  29.             //int length = 20; //the circel will be 20 pixels from its center
  30.  
  31.             //float angle = 0;
  32.             //float angle_stepsize = 20; //The circle will turn 20 degrees in a second.
  33.  
  34.             immovable = true;   //We want the elevator to be "solid" and not shift during collisions
  35.             moves = true;
  36.             allowCollisions = FlxObject.UP;
  37.         }
  38.         public function preCollide(Object:FlxObject):void
  39.         {
  40.             if (Object.toString() == "Player")
  41.             {
  42.                 FlxG.log("MOVE PLAYER");
  43.                 }
  44.         }
  45.        
  46.         override public function update():void
  47.         {
  48.             //  Has platform reached the end of its movement?
  49.             this.x = length * Math.cos(theangle);
  50.             this.y = length * Math.sin(theangle);// the angular math thingy
  51.  
  52.             this.x = x + placex;
  53.             this.y = y + placey;//placing the circle in our world.
  54.  
  55.             theangle += angle_stepsize * FlxG.elapsed;//multplying the stepsize by the
  56.             //time spent since last frame to make sure it moves only 20 angles
  57.             //per second.
  58.            
  59.        
  60.            
  61.         }
  62.     }
  63. }
Add Comment
Please, Sign In to add comment