Advertisement
Guest User

PreRotation Demo - TestWorld.as

a guest
Sep 29th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package  {
  2.     import net.flashpunk.FP;
  3.     import net.flashpunk.graphics.Text;
  4.     import net.flashpunk.utils.Input;
  5.     import net.flashpunk.utils.Key;
  6.     import net.flashpunk.World;
  7.     /**
  8.      * ...
  9.      * @author NotARaptor
  10.      */
  11.     public class TestWorld extends World {
  12.        
  13.         private var thing:TestThing;
  14.        
  15.         public function TestWorld() {
  16.            
  17.         }
  18.        
  19.         override public function begin():void {
  20.             thing = new TestThing(FP.halfWidth, FP.halfHeight);
  21.             add(thing);
  22.            
  23.             addGraphic(new Text("[1] Top-left\n[2] Centre\n[3] Base\n[4] Tip\n[5] Bottom-left\n\n[SPACE] Toggle Background\n\n[ARROWS/WASD] Move\n\n[TAB] FP Console"), 0, 10, 50);
  24.         }
  25.        
  26.         override public function update():void {
  27.             super.update();
  28.             if (Input.pressed(Key.DIGIT_1)) {
  29.                 thing.setHandle(TestThing.HANDLE_TOPLEFT);
  30.             }
  31.             if (Input.pressed(Key.DIGIT_2)) {
  32.                 thing.setHandle(TestThing.HANDLE_CENTRE);
  33.             }
  34.             if (Input.pressed(Key.DIGIT_3)) {
  35.                 thing.setHandle(TestThing.HANDLE_BASE);
  36.             }
  37.             if (Input.pressed(Key.DIGIT_4)) {
  38.                 thing.setHandle(TestThing.HANDLE_TIP);
  39.             }
  40.             if (Input.pressed(Key.DIGIT_5)) {
  41.                 thing.setHandle(TestThing.HANDLE_BOTTOMLEFT);
  42.             }
  43.            
  44.             if (Input.pressed(Key.SPACE)) {
  45.                 thing.toggleBackground();
  46.             }
  47.            
  48.             if (Input.check(Key.LEFT) || Input.check(Key.A)) {
  49.                 thing.x = (thing.x + FP.width - FP.elapsed * 100) % FP.width;
  50.             }
  51.             if (Input.check(Key.UP) || Input.check(Key.W)) {
  52.                 thing.y = (thing.y + FP.height - FP.elapsed * 100) % FP.height;
  53.             }
  54.             if (Input.check(Key.RIGHT) || Input.check(Key.D)) {
  55.                 thing.x = (thing.x + FP.elapsed * 100) % FP.width;
  56.             }
  57.             if (Input.check(Key.DOWN) || Input.check(Key.S)) {
  58.                 thing.y = (thing.y + FP.elapsed * 100) % FP.height;
  59.             }
  60.         }
  61.        
  62.     }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement