Пример #1
0
        override public void update()
        {
            //This is just to make the text at the top fade out
            if (topText.Alpha > 0)
            {
                topText.Alpha -= .01f;
            }
            base.update();
            FlxG.collide(theEmitter, collisionGroup);

            if (FlxG.keys.justPressed(Keys.Escape))
            {
                onQuit();
            }
        }
 public override void update()
 {
     base.update();
     if (_collisions)
     {
         FlxG.collide(_bunnies);
     }
     if (_memoryTimer.time != 0)
     {
         _memoryTimer.update();
     }
     if (FlxG.keys.justPressed(Keys.Escape))
     {
         onQuit();
     }
 }
Пример #3
0
        public override void update()
        {
            //Player movement and controls
            player.Acceleration.X = 0;

            if (FlxG.keys.pressed(Keys.Left))
            {
                player.Acceleration.X = -player.MaxVelocity.X * 4;
            }
            if (FlxG.keys.pressed(Keys.Right))
            {
                player.Acceleration.X = player.MaxVelocity.X * 4;
            }

            if (FlxG.keys.pressed(Keys.Space) && player.isTouching(FlxObject.Floor))
            {
                player.Velocity.Y = -player.MaxVelocity.Y / 2;
            }

            if (FlxG.keys.justPressed(Keys.Escape))
            {
                onQuit();
            }


            //Updates all the objects appropriately
            base.update();

            //Check if player collected a coin or coins this frame
            FlxG.overlap(coins, player, getCoin);

            //Check to see if the player touched the exit door this frame
            FlxG.overlap(exit, player, win);

            FlxG.collide(level, player);

            //Check for player lose conditions
            if (player.Y > FlxG.height)
            {
                FlxG.score = 1;                 //sets status.text to "Aww, you died!"
                FlxG.resetState();
            }
        }
Пример #4
0
        override public void update()
        {
            // collide everything
            FlxG.collide();

            //player 1 controls
            player1.Acceleration.X = 0;

            if (FlxG.keys.pressed(Keys.Left))
            {
                player1.Acceleration.X = -player1.MaxVelocity.X * 4;
            }
            if (FlxG.keys.pressed(Keys.Right))
            {
                player1.Acceleration.X = player1.MaxVelocity.X * 4;
            }
            if (FlxG.keys.justPressed(Keys.Up) && player1.isTouching(FlxObject.Floor))
            {
                player1.Velocity.Y -= (float)(player1.MaxVelocity.Y / 1.5);
            }

            //player 2 controls
            player2.Acceleration.X = 0;

            if (FlxG.keys.pressed(Keys.A))
            {
                player2.Acceleration.X = -player2.MaxVelocity.X * 4;
            }
            if (FlxG.keys.pressed(Keys.D))
            {
                player2.Acceleration.X = player2.MaxVelocity.X * 4;
            }
            if (FlxG.keys.justPressed(Keys.W) && player2.isTouching(FlxObject.Floor))
            {
                player2.Velocity.Y -= (float)(player2.MaxVelocity.Y / 1.5);
            }
            if (FlxG.keys.justPressed(Keys.Escape))
            {
                onQuit();
            }

            base.update();
        }
Пример #5
0
        override public void update()
        {
            // Tilemaps can be collided just like any other FlxObject, and flixel
            // automatically collides each individual tile with the object.
            FlxG.collide(player, collisionMap);

            highlightBox.X = (float)Math.Floor(FlxG.mouse.cursor.X / TILE_WIDTH) * TILE_WIDTH;
            highlightBox.Y = (float)Math.Floor(FlxG.mouse.cursor.Y / TILE_HEIGHT) * TILE_HEIGHT;

            if (FlxG.mouse.pressed())
            {
                // FlxTilemaps can be manually edited at runtime as well.
                // Setting a tile to 0 removes it, and setting it to anything else will place a tile.
                // If auto map is on, the map will automatically update all surrounding tiles.
                collisionMap.setTile((uint)FlxG.mouse.x / TILE_WIDTH, (uint)FlxG.mouse.y / TILE_HEIGHT, (uint)(FlxG.keys.pressed(Keys.LeftShift) ? 0 : 1));
            }

            updatePlayer();
            if (FlxG.keys.justPressed(Keys.Escape))
            {
                onQuit();
            }
            base.update();
        }
        public override void update()
        {
            /*
             * if(_pad.Visible)
             *      _pad.update();
             */

            //save off the current score and update the game state
            int oldScore = FlxG.score;

            base.update();

            //collisions with environment
            FlxG.collide(_blocks, _objects);
            FlxG.overlap(_hazards, _player, overlapped);
            FlxG.overlap(_bullets, _hazards, overlapped);

            //check to see if the player scored any points this frame
            bool scoreChanged = oldScore != FlxG.score;

            //Jammed message
            if ((FlxG.keys.justPressed(Keys.C) /*|| _pad.buttonB.status == FlxButton.Pressed*/) && _player.flickering)
            {
                _jamTimer       = 1;
                _gunjam.Visible = true;
            }
            if (_jamTimer > 0)
            {
                if (!_player.flickering)
                {
                    _jamTimer = 0;
                }
                _jamTimer -= FlxG.elapsed;
                if (_jamTimer < 0)
                {
                    _gunjam.Visible = false;
                }
            }

            if (!_fading)
            {
                //Score + countdown stuffs
                if (scoreChanged)
                {
                    _scoreTimer = 2;
                }
                _scoreTimer -= FlxG.elapsed;
                if (_scoreTimer < 0)
                {
                    if (FlxG.score > 0)
                    {
                        if (FlxG.score > 100)
                        {
                            FlxG.score -= 100;
                        }
                        else
                        {
                            FlxG.score = 0;
                            _player.kill();
                        }
                        _scoreTimer  = 1;
                        scoreChanged = true;

                        //Play loud beeps if your score is low
                        float volume = 0.35f;
                        if (FlxG.score < 600)
                        {
                            volume = 1.0f;
                        }
                        _sfxCount.Volume = volume;
                        _sfxCount.play(true);
                    }
                }

                //Fade out to victory screen stuffs
                if (_spawners.CountLiving() <= 0)
                {
                    _fading = true;
                    FlxG.fade(Color.Black, 3, onVictory);
                }
            }

            //actually update score text if it changed
            if (scoreChanged)
            {
                if (!_player.Alive)
                {
                    FlxG.score = 0;
                }
                _score.text = "" + FlxG.score;
            }
        }
Пример #7
0
        override public void update()
        {
            //This is just to make the text at the top fade out
            if (topText.Alpha > 0)
            {
                topText.Alpha -= .01f;
            }

            //Here we'll make the elevator rise and fall - all of the constants chosen here are just after tinkering
            if (rising)
            {
                elevator.Velocity.Y -= 10;
            }
            else
            {
                elevator.Velocity.Y += 10;
            }
            if (elevator.Velocity.Y == -300)
            {
                rising = false;
            }
            else if (elevator.Velocity.Y == 300)
            {
                rising = true;
            }

            //Run through the groups, and if a crate is off screen, get it back!
            foreach (FlxSprite a in crateStormGroup.Members)
            {
                if (a.X < -10)
                {
                    a.X = 400;
                }
                if (a.X > 400)
                {
                    a.X = -10;
                }
                if (a.Y > 300)
                {
                    a.Y = -10;
                }
            }
            foreach (FlxSprite a in crateStormGroup2.Members)
            {
                if (a.X > 400)
                {
                    a.X = -10;
                }
                if (a.X < -10)
                {
                    a.X = 400;
                }
                if (a.Y > 300)
                {
                    a.Y = -10;
                }
            }
            base.update();

            //Here we call our simple collide() function, what this does is checks to see if there is a collision
            //between the two objects specified, But if you pass in a group then it checks the group against the object,
            //or group against a group, You can even check a group of groups against an object - You can see the possibilities this presents.
            //To use it, simply call FlxG.collide(Group/Object1, Group/Object2, Notification(optional))
            //If you DO pass in a notification it will fire the function you created when two objects collide - allowing for even more functionality.
            if (collideGroups)
            {
                FlxG.collide(crateStormGroup, crateStormGroup2);
            }
            if (isCrateStormOn)
            {
                FlxG.collide(elevator, crateStormMegaGroup);
            }
            if (isFlxRiderOn)
            {
                FlxG.collide(elevator, flixelRider);
            }
            //We don't specify a callback here, because we aren't doing anything base specific - just using the default collide method.
        }