makeGraphic() public method

public makeGraphic ( float Width, float Height, Color color ) : FlxSprite
Width float
Height float
color Color
return FlxSprite
Beispiel #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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public Building(float X, float Y, float Width, float Height, Player Player, FlxSprite Blackout)
            : base(X, Y)
        {
            makeGraphic(Width, Height, FlxColor.GOLD);

            _blackout = Blackout;
            _player   = Player;
            //_floor = new FlxSprite(X, Y);
            //_floor.makeGraphic(Width, Height, FlxColor.BROWN);
            _roof = new FlxSprite(X, Y);
            _roof.makeGraphic(Width, Height, FlxColor.CRIMSON);
            visible = _roof.visible = false;
        }
Beispiel #4
0
 public FlxConsole()
     : base()
 {
     bg = new FlxSprite(80, 40);
     bg.makeGraphic((uint)FlxS.GraphicsDevice.Viewport.Width - 160, (uint)FlxS.GraphicsDevice.Viewport.Height - 80, FlxColor.WHITE * 0.45f);
     bg.Alpha = 0.5f;
     add(bg);
     ScrollFactor.X = ScrollFactor.Y = 0;
     Visible        = false;
     text           = new FlxText(100, 60, FlxS.GraphicsDevice.Viewport.Width - 160, "internal console is a work in progress", FlxG.defaultFont);
     text.setFormat(FlxColor.WHITE);
     text.Alpha = 0.75f;
     add(text);
 }
Beispiel #5
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);
        }
Beispiel #6
0
 public void createCoin(uint X, uint Y)
 {
     FlxSprite coin = new FlxSprite(X * 8 + 3, Y * 8 + 2);
     coin.makeGraphic(2, 4, new Color(1f, 1f, 0f));
     coins.add(coin);
 }