예제 #1
0
파일: Bot.cs 프로젝트: Beeblerox/Mode
        public Bot(int xPos, int yPos, List<FlxObject> Bullets, FlxEmitter Gibs, Player ThePlayer)
            : base(xPos,yPos)
        {
            ImgBot = FlxG.Content.Load<Texture2D>("Mode/bot");
            ImgJet = FlxG.Content.Load<Texture2D>("Mode/jetsmoke");

            loadGraphic(ImgBot,false);
            _player = ThePlayer;
            _b = Bullets;
            _gibs = Gibs;

            width = 12;
            height = 12;
            offset.X = 2;
            offset.Y = 2;
            maxAngular = 120;
            angularDrag = 400;
            maxThrust = 100;
            drag.X = 80;
            drag.Y = 80;

            //Jet effect that shoots out from behind the bot
            _jets = new FlxEmitter();
            _jets.setRotation();
            _jets.gravity = 0;
            _jets.createSprites(ImgJet,15,false);

            reset(x,y);
        }
예제 #2
0
파일: Spawner.cs 프로젝트: Beeblerox/Mode
        public Spawner(int X, int Y, FlxEmitter Gibs, FlxGroup Bots, List<FlxObject> BotBullets, FlxEmitter BotGibs, Player ThePlayer)
            : base(X, Y)
        {
            ImgSpawner = FlxG.Content.Load<Texture2D>("Mode/spawner");

            loadGraphic(ImgSpawner,true);
            _gibs = Gibs;
            _bots = Bots;
            _botBullets = BotBullets;
            _botGibs = BotGibs;
            _player = ThePlayer;
            _timer = FlxU.random()*20;
            _open = false;
            health = 8;

            addAnimation("open", new int[] {1, 2, 3, 4, 5}, 40, false);
            addAnimation("close", new int[] {4, 3, 2, 1, 0}, 40, false);
            addAnimation("dead", new int[] {6});
        }
예제 #3
0
파일: Player.cs 프로젝트: Beeblerox/Mode
        public Player(int X, int Y, List<FlxObject> Bullets, FlxEmitter Gibs)
            : base(X, Y)
        {
            ImgSpaceman = FlxG.Content.Load<Texture2D>("Mode/spaceman");

            loadGraphic(ImgSpaceman,true,true,8);
            _restart = 0;

            //bounding box tweaks
            width = 6;
            height = 7;
            offset.X = 1;
            offset.Y = 1;

            //basic player physics
            int runSpeed = 80;
            drag.X = runSpeed*8;
            acceleration.Y = 420;
            _jumpPower = 205;
            maxVelocity.X = runSpeed;
            maxVelocity.Y = _jumpPower;

            //animations
            addAnimation("idle", new int[] {0});
            addAnimation("run", new int [] {1, 2, 3, 0}, 12);
            addAnimation("jump", new int[] {4});
            addAnimation("idle_up", new int[] {5});
            addAnimation("run_up", new int[] {6, 7, 8, 5}, 12);
            addAnimation("jump_up", new int[] {9});
            addAnimation("jump_down", new int[] {10});

            //bullet stuff
            _bullets = Bullets;
            _curBullet = 0;
            _bulletVel = 360;

            //Gibs emitted upon death
            _gibs = Gibs;
        }
예제 #4
0
        public override void create()
        {
            base.create();

            ImgGibs=FlxG.Content.Load<Texture2D>("Mode/spawner_gibs");

            _timer = 0;
            _fading = false;
            FlxG.flash.start(new Color(0xd8, 0xeb, 0xa2));

            //Gibs emitted upon death
            FlxEmitter gibs = new FlxEmitter(0,-50);
            gibs.setSize(FlxG.width,0);
            gibs.setXSpeed();
            gibs.setYSpeed(0,100);
            gibs.setRotation(-360,360);
            gibs.gravity = 80;
            gibs.createSprites(ImgGibs,800);
            add(gibs);
            gibs.start(false,0.005f);

            add((new FlxText(0,FlxG.height/3,FlxG.width,"VICTORY\nSCORE: "+FlxG.score)).setFormat(null,3,new Color(0xd8, 0xeb, 0xa2), FlxJustification.Center, Color.Black));
        }
예제 #5
0
파일: PlayState.cs 프로젝트: Beeblerox/Mode
        public override void create()
        {
            base.create();

            ImgTech=FlxG.Content.Load<Texture2D>("Mode/tech_tiles");
            ImgDirtTop=FlxG.Content.Load<Texture2D>("Mode/dirt_top");
            ImgDirt=FlxG.Content.Load<Texture2D>("Mode/dirt");
            ImgNotch=FlxG.Content.Load<Texture2D>("Mode/notch");
            ImgGibs=FlxG.Content.Load<Texture2D>("Mode/gibs");
            ImgSpawnerGibs = FlxG.Content.Load<Texture2D>("Mode/spawner_gibs");

            FlxG.mouse.hide();
            reload = false;

            //get the gibs set up and out of the way
            _littleGibs = new FlxEmitter();
            _littleGibs.delay = 3;
            _littleGibs.setXSpeed(-150,150);
            _littleGibs.setYSpeed(-200,0);
            _littleGibs.setRotation(-720,-720);
            _littleGibs.createSprites(ImgGibs,100,true,0.5f,0.65f);
            _bigGibs = new FlxEmitter();
            _bigGibs.setXSpeed(-200,200);
            _bigGibs.setYSpeed(-300,0);
            _bigGibs.setRotation(-720,-720);
            _bigGibs.createSprites(ImgSpawnerGibs,50,true,0.5f,0.35f);

            //level generation needs to know about the spawners (and thusly the bots, players, etc)
            _blocks = new FlxGroup();
            _decorations = new FlxGroup();
            _bullets = new FlxGroup();
            _player = new Player(316,300,_bullets.members,_littleGibs);
            _bots = new FlxGroup();
            _botBullets = new FlxGroup();
            _spawners = new FlxGroup();

            //simple procedural level generation
            int i;
            int r = 160;
            FlxTileblock b;

            b = new FlxTileblock(0,0,640,16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(0,16,16,640-16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(640-16,16,16,640-16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(16,640-24,640-32,8);
            b.loadGraphic(ImgDirtTop);
            _blocks.add(b);

            b = new FlxTileblock(16,640-16,640-32,16);
            b.loadGraphic(ImgDirt);
            _blocks.add(b);

            buildRoom(r * 0, r * 0, true);
            buildRoom(r*1,r*0);
            buildRoom(r*2,r*0);
            buildRoom(r * 3, r * 0, true);
            buildRoom(r * 0, r * 1, true);
            buildRoom(r*1,r*1);
            buildRoom(r*2,r*1);
            buildRoom(r * 3, r * 1, true);
            buildRoom(r*0,r*2);
            buildRoom(r*1,r*2);
            buildRoom(r*2,r*2);
            buildRoom(r*3,r*2);
            buildRoom(r*0,r*3,true);
            buildRoom(r*1,r*3);
            buildRoom(r*2,r*3);
            buildRoom(r*3,r*3,true);

            //Add bots and spawners after we add blocks to the state,
            // so that they're drawn on top of the level, and so that
            // the bots are drawn on top of both the blocks + the spawners.
            add(_spawners);
            add(_littleGibs);
            add(_bigGibs);
            add(_blocks);
            add(_decorations);
            add(_bots);

            //actually create the bullets now
            for(i = 0; i < 50; i++)
                _botBullets.add(new BotBullet());
            for(i = 0; i < 8; i++)
                _bullets.add(new Bullet());

            //add player and set up scrolling camera
            add(_player);
            FlxG.follow(_player,2.5f);
            FlxG.followAdjust(0.5f,0.0f);
            FlxG.followBounds(0,0,640,640);

            //add gibs + bullets to scene here, so they're drawn on top of pretty much everything
            add(_botBullets);
            add(_bullets);

            //finally we are going to sort things into a couple of helper groups.
            //we don't add these to the state, we just use them for collisions later!
            _enemies = new FlxGroup();
            _enemies.add(_botBullets);
            _enemies.add(_spawners);
            _enemies.add(_bots);
            _objects = new FlxGroup();
            _objects.add(_botBullets);
            _objects.add(_bullets);
            _objects.add(_bots);
            _objects.add(_player);
            _objects.add(_littleGibs);
            _objects.add(_bigGibs);

            //HUD - score
            Vector2 ssf = new Vector2(0,0);
            _score = new FlxText(0,0,FlxG.width);
            _score.color = new Color (0xd8, 0xeb, 0xa2);
            _score.scale = 2;
            _score.alignment = FlxJustification.Center;
            _score.scrollFactor = ssf;
            _score.shadow = new Color(0x13, 0x1c, 0x1b);
            add(_score);
            if (FlxG.scores.Count < 2)
            {
                FlxG.scores.Add(0);
                FlxG.scores.Add(0);
            }

            //HUD - highest and last scores
            _score2 = new FlxText(FlxG.width/2,0,FlxG.width/2);
            _score2.color = new Color(0xd8, 0xeb, 0xa2);
            _score2.alignment = FlxJustification.Right;
            _score2.scrollFactor = ssf;
            _score2.shadow = _score.shadow;
            add(_score2);
            if (FlxG.score > FlxG.scores[0])
                FlxG.scores[0] = FlxG.score;
            if (FlxG.scores[0] != 0)
                _score2.text = "HIGHEST: " + FlxG.scores[0] + "\nLAST: " + FlxG.score;
            FlxG.score = 0;
            _scoreTimer = 0;

            //HUD - the "number of spawns left" icons
            _notches = new List<FlxSprite>();
            FlxSprite tmp;
            for(i = 0; i < 6; i++)
            {
                tmp = new FlxSprite(4+i*10,4);
                tmp.loadGraphic(ImgNotch,true);
                tmp.scrollFactor.X = tmp.scrollFactor.Y = 0;
                tmp.addAnimation("on", new int[] {0});
                tmp.addAnimation("off",new int[] {1});
                tmp.moves = false;
                tmp.solid = false;
                tmp.play("on");
                _notches.Add((FlxSprite)this.add(tmp));
            }

            //HUD - the "gun jammed" notification
            _jamBar = this.add((new FlxSprite(0,FlxG.height-22)).createGraphic(FlxG.width,24, new Color(0x13, 0x1c, 0x1b))) as FlxSprite;
            _jamBar.scrollFactor.X = _jamBar.scrollFactor.Y = 0;
            _jamBar.visible = false;
            _jamText = new FlxText(0,FlxG.height-22,FlxG.width,"GUN IS JAMMED");
            _jamText.color = new Color(0xd8, 0xeb, 0xa2);
            _jamText.scale = 2;
            _jamText.alignment = FlxJustification.Center;
            _jamText.scrollFactor = ssf;
            _jamText.visible = false;
            add(_jamText);

            FlxG.playMusic(SndMode);
            FlxG.flash.start(new Color(0x13, 0x1c, 0x1b), 0.5f, null, false);
            _fading = false;
        }