Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import net.flashpunk.FP;
- import net.flashpunk.graphics.Text;
- import net.flashpunk.utils.Input;
- import net.flashpunk.utils.Key;
- import net.flashpunk.World;
- /**
- * ...
- * @author NotARaptor
- */
- public class TestWorld extends World {
- private var thing:TestThing;
- public function TestWorld() {
- }
- override public function begin():void {
- thing = new TestThing(FP.halfWidth, FP.halfHeight);
- add(thing);
- 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);
- }
- override public function update():void {
- super.update();
- if (Input.pressed(Key.DIGIT_1)) {
- thing.setHandle(TestThing.HANDLE_TOPLEFT);
- }
- if (Input.pressed(Key.DIGIT_2)) {
- thing.setHandle(TestThing.HANDLE_CENTRE);
- }
- if (Input.pressed(Key.DIGIT_3)) {
- thing.setHandle(TestThing.HANDLE_BASE);
- }
- if (Input.pressed(Key.DIGIT_4)) {
- thing.setHandle(TestThing.HANDLE_TIP);
- }
- if (Input.pressed(Key.DIGIT_5)) {
- thing.setHandle(TestThing.HANDLE_BOTTOMLEFT);
- }
- if (Input.pressed(Key.SPACE)) {
- thing.toggleBackground();
- }
- if (Input.check(Key.LEFT) || Input.check(Key.A)) {
- thing.x = (thing.x + FP.width - FP.elapsed * 100) % FP.width;
- }
- if (Input.check(Key.UP) || Input.check(Key.W)) {
- thing.y = (thing.y + FP.height - FP.elapsed * 100) % FP.height;
- }
- if (Input.check(Key.RIGHT) || Input.check(Key.D)) {
- thing.x = (thing.x + FP.elapsed * 100) % FP.width;
- }
- if (Input.check(Key.DOWN) || Input.check(Key.S)) {
- thing.y = (thing.y + FP.elapsed * 100) % FP.height;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement