Inheritance: FlxObject
Exemplo n.º 1
0
        public override void create()
        {
            base.create();

            houseBases  = new FlxGroup();
            houseRooves = new FlxGroup();

            FlxG.bgColor = FlxColor.INDIGO;

            p = new Player(200, 200);
            add(p.footsteps);

            blackout = new FlxSprite();
            blackout.makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
            blackout.visible = false;
            add(blackout);

            add(houseBases);

            add(p);

            add(houseRooves);

            house1 = new Building(0, 0, 600, 600, p, blackout);
            houseBases.add(house1);
            houseRooves.add(house1.roof);

            FlxG.camera.follow(p, FlxCamera.STYLE_TOPDOWN);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initiate all the things needed by the engine
        /// </summary>
        internal static void init()
        {
            FlxG.defaultWholeScreenViewport = FlxG.viewport;
            FlxG.cameras   = new List <FlxCamera>();
            FlxG.viewports = new List <Viewport>();
            //FlxG.width = FlxG.graphics.PreferredBackBufferWidth;
            //FlxG.height = FlxG.graphics.PreferredBackBufferHeight;
            FlxG.bgColor     = Color.Black;
            FlxG.mute        = false;
            FlxG.sounds      = new FlxGroup();
            FlxG.console     = new FlxConsole();
            FlxG.worldBounds = new FlxRect();
            FlxG.defaultFont = FlxG.content.Load <SpriteFont>("ConsoleFont");
            //FlxG.zoom = 1f;
            FlxG.rotation = 0f;
            FlxG.pad1     = new FlxGamepad(PlayerIndex.One);
            FlxG.pad2     = new FlxGamepad(PlayerIndex.Two);
            FlxG.pad3     = new FlxGamepad(PlayerIndex.Three);
            FlxG.pad4     = new FlxGamepad(PlayerIndex.Four);
            FlxG.keys     = new FlxKeyboard();
            FlxG.mouse    = new FlxMouse();
            FlxG.safeZone = new FlxRect(FlxG.graphicsDevice.Viewport.TitleSafeArea.X, FlxG.graphicsDevice.Viewport.TitleSafeArea.Y, FlxG.graphicsDevice.Viewport.TitleSafeArea.Width, FlxG.graphicsDevice.Viewport.TitleSafeArea.Height);
            FlxCamera defaultCam = new FlxCamera(0, 0, FlxG.width, FlxG.height, FlxG.zoom);

            FlxG.addCamera(defaultCam);

            //Thread tCreate = new Thread(FlxG.state.create);
            //tCreate.Start();

            //create state last
            FlxG.state.create();
        }
Exemplo n.º 3
0
        public override void create()
        {
            base.create();

            houseBases = new FlxGroup();
            houseRooves = new FlxGroup();

            FlxG.bgColor = FlxColor.INDIGO;

            p = new Player(200, 200);
            add(p.footsteps);

            blackout = new FlxSprite();
            blackout.makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
            blackout.visible = false;
            add(blackout);

            add(houseBases);

            add(p);

            add(houseRooves);

            house1 = new Building(0, 0, 600, 600, p, blackout);
            houseBases.add(house1);
            houseRooves.add(house1.roof);

            FlxG.camera.follow(p, FlxCamera.STYLE_TOPDOWN);
        }
Exemplo n.º 4
0
        public override void create()
        {
            base.create();

            FlxG.bgColor = Color.LightGray;

            //Design your platformer level with 1s and 0s (at 40x30 to fill 320x240 screen)
            int [] data = {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1,
                    1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
                    1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
                    1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1,
                    1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,
                    1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1,
                    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
                    };

            level = new FlxTilemap();

            exit = new FlxSprite(35 * 8 + 1, 25 * 8);
            exit.makeGraphic(14, 16, new Color(3f, 3f, 3f ));
            exit.exists = false;
            add(exit);

            coins = new FlxGroup();
            //Top left coins
            createCoin(18, 4);
            createCoin(12, 4);
            createCoin(9, 4);
            createCoin(8, 11);
            createCoin(1, 7);
            createCoin(3, 4);
            createCoin(5, 2);
            createCoin(15, 11);
            createCoin(16, 11);

            //Bottom left coins
            createCoin(3, 16);
            createCoin(4, 16);
            createCoin(1, 23);
            createCoin(2, 23);
            createCoin(3, 23);
            createCoin(4, 23);
            createCoin(5, 23);
            createCoin(12, 26);
            createCoin(13, 26);
            createCoin(17, 20);
            createCoin(18, 20);

            //Top right coins
            createCoin(21, 4);
            createCoin(26, 2);
            createCoin(29, 2);
            createCoin(31, 5);
            createCoin(34, 5);
            createCoin(36, 8);
            createCoin(33, 11);
            createCoin(31, 11);
            createCoin(29, 11);
            createCoin(27, 11);
            createCoin(25, 11);
            createCoin(36, 14);

            //Bottom right coins
            createCoin(38, 17);
            createCoin(33, 17);
            createCoin(28, 19);
            createCoin(25, 20);
            createCoin(18, 26);
            createCoin(22, 26);
            createCoin(26, 26);
            createCoin(30, 26);
            add(coins);

            //Create player (a red box)
            player = new FlxSprite(FlxG.width / 2 - 5);
            player.makeGraphic(10, 12, new Color (170, 17, 17));
            player.maxVelocity.x = 80;
            player.maxVelocity.y = 200;
            player.acceleration.y = 200;
            player.drag.x = player.maxVelocity.x * 4;
            add(player);

            score = new FlxText(2, 2, 80);
            //score.shadow = 0xff000000;
            score.shadow = Color.Black;
            score.text = "SCORE: " + (coins.countDead() * 100);
            add(score);

            status = new FlxText(FlxG.width - 160 - 2, 2, 160);
            //status.shadow = 0xff000000;
            //status.alignment = "right";
            switch (FlxG.score)
            {
                case 0: status.text = "Collect coins."; break;
                case 1: status.text = "Aww, you died!"; break;
            }
            add(status);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called by <code>FlxGame</code> to set up <code>FlxG</code> during <code>FlxGame</code>'s constructor.
        /// </summary>
        internal static void init(FlxGame game, int width, int height, float zoom)
        {
            FlxG._game = game;
            FlxG.width = width;
            FlxG.height = height;

            FlxG.mute = false;
            FlxG.volume = 1.0f;
            FlxG.sounds = new FlxGroup();
            FlxG.volumeHandler = delegate { };

            //FlxG.clearBitmapCache();

            //if(flashGfxSprite == null)
            //{
            //    flashGfxSprite = new Sprite();
            //    flashGfx = flashGfxSprite.graphics;
            //}

            FlxCamera.DefaultZoom = zoom;
            //FlxG._cameraRect = new Rectangle();
            FlxG.cameras = new List<FlxCamera>();
            //FlxG.UseBufferLocking = false;

            FlxG.plugins = new List<FlxBasic>();
            //addPlugin(new DebugPathDisplay());
            //addPlugin(new TimerManager());

            FlxG.mouse = new FlxMouse();
            FlxG.keys = new FlxKeyboard();
            //FlxG.mobile = false;

            FlxG.levels = null;
            FlxG.scores = null;
            FlxG.visualDebug = false;

            // flx# stuff

            FlxG.cameras = new List<FlxCamera>();

            //FlxG.width = FlxG.graphics.PreferredBackBufferWidth;
            //FlxG.height = FlxG.graphics.PreferredBackBufferHeight;
            FlxG.bgColor = Color.Black;
            FlxG.mute = false;
            FlxG.sounds = new FlxGroup();
            FlxG.worldBounds = new FlxRect();
            FlxG.defaultFont = FlxS.ContentManager.Load<SpriteFont>("ConsoleFont");
            //FlxG.zoom = 1f;
            FlxG.pad1 = new FlxGamepad(PlayerIndex.One);
            FlxG.pad2 = new FlxGamepad(PlayerIndex.Two);
            FlxG.pad3 = new FlxGamepad(PlayerIndex.Three);
            FlxG.pad4 = new FlxGamepad(PlayerIndex.Four);
            FlxG.keys = new FlxKeyboard();
            FlxG.mouse = new FlxMouse();
            FlxCamera defaultCam = new FlxCamera(0, 0, FlxG.width, FlxG.height, FlxG.zoom);
            FlxG.addCamera(defaultCam);

            //Thread tCreate = new Thread(FlxG.state.create);
            //tCreate.Start();

            //create state last
            //FlxG.State.create();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initiate all the things needed by the engine
        /// </summary>
        internal static void init()
        {
            FlxG.defaultWholeScreenViewport = FlxG.viewport;
            FlxG.cameras = new List<FlxCamera>();
            FlxG.viewports = new List<Viewport>();
            //FlxG.width = FlxG.graphics.PreferredBackBufferWidth;
            //FlxG.height = FlxG.graphics.PreferredBackBufferHeight;
            FlxG.bgColor = Color.Black;
            FlxG.mute = false;
            FlxG.sounds = new FlxGroup();
            FlxG.console = new FlxConsole();
            FlxG.worldBounds = new FlxRect();
            FlxG.defaultFont = FlxG.content.Load<SpriteFont>("ConsoleFont");
            //FlxG.zoom = 1f;
            FlxG.rotation = 0f;
            FlxG.pad1 = new FlxGamepad(PlayerIndex.One);
            FlxG.pad2 = new FlxGamepad(PlayerIndex.Two);
            FlxG.pad3 = new FlxGamepad(PlayerIndex.Three);
            FlxG.pad4 = new FlxGamepad(PlayerIndex.Four);
            FlxG.keys = new FlxKeyboard();
            FlxG.mouse = new FlxMouse();
            FlxG.safeZone = new FlxRect(FlxG.graphicsDevice.Viewport.TitleSafeArea.X, FlxG.graphicsDevice.Viewport.TitleSafeArea.Y, FlxG.graphicsDevice.Viewport.TitleSafeArea.Width, FlxG.graphicsDevice.Viewport.TitleSafeArea.Height);
            FlxCamera defaultCam = new FlxCamera(0, 0, FlxG.width, FlxG.height, FlxG.zoom);
            FlxG.addCamera(defaultCam);

            //Thread tCreate = new Thread(FlxG.state.create);
            //tCreate.Start();

            //create state last
            FlxG.state.create();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Override create() and initialize your game objects here
 /// </summary>
 public virtual void create()
 {
     hud = new FlxGroup();
     add(hud);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Override create() and initialize your game objects here
 /// </summary>
 public virtual void create()
 {
     hud = new FlxGroup();
     add(hud);
 }