Exemple #1
0
        } /* link_is_pipe() */

/***********************************************************
*
*   Method:
*       set_destination
*
*   Description:
*       Sets mario's location to the destination pipe.
*
***********************************************************/

        public void set_destination(mario_type m)
        {
            int viewx = 0;
            int viewy = 0;

            if (link_v != null)
            {
                m.physics.position.x = link_v.x << 12;
                m.physics.position.y = link_v.y << 12;
                viewx = m.physics.position.x - ((4 * Blocks.size.Width) << 12);
            }
            else if (link_p != null)
            {
                m.physics.position.x = (link_p.x << 16) + (10 << 12);
                m.physics.position.y = (link_p.y << 16) - ((m.physics.hit_box.Height - 1) << 12);
                viewx = (link_p.x - 3) << 16;
            }

            m.physics.acceleration.x = 0;
            m.physics.acceleration.y = 0;
            m.physics.velocity.x     = 0;
            m.physics.velocity.y     = 0;

            viewy = 0;
            ViewDims.set_view_location(viewx, viewy);
        } /* set_destination() */
Exemple #2
0
        } /* unload_content() */

/***********************************************************
*
*   Method:
*       resize_window
*
*   Description:
*       Resets the scale for the game.
*
***********************************************************/

        public void resize_window(object sender, EventArgs e)
        {
            graphics.PreferredBackBufferWidth  = game.Window.ClientBounds.Width;
            graphics.PreferredBackBufferHeight = game.Window.ClientBounds.Height;

            ViewDims.set_window_size(new Rectangle(0, 0, game.Window.ClientBounds.Width, game.Window.ClientBounds.Height));
        } /* resize_window() */
Exemple #3
0
        } /* draw() */

/***********************************************************
*
*   Method:
*       construct
*
*   Description:
*       Initialize the game.
*
***********************************************************/

        public void construct(Game g)
        {
            game = g;

            graphics = new GraphicsDeviceManager(game);
            game.Content.RootDirectory = "Content";

            game.Window.AllowUserResizing  = true;
            game.Window.ClientSizeChanged += resize_window;

            ViewDims.set_window_size(new Rectangle(0, 0, game.Window.ClientBounds.Width, game.Window.ClientBounds.Height));
        } /* construct() */
Exemple #4
0
        } /* view_type() */

/***********************************************************
*
*   Method:
*       draw
*
*   Description:
*       Draws the game.
*
***********************************************************/

        public void draw()
        {
            game.GraphicsDevice.Clear(model.level.map.get_back_color(model.level.mario.physics.position.x >> 16));

            switch (model.game_status)
            {
            case game_status_enum.gameplay:
                ViewDims.view_follow_mario(model);
                spriteBatch.Begin(SpriteSortMode.BackToFront, null, SamplerState.PointClamp, null, null, null, Matrix.CreateTranslation(ViewDims.view_scaled.X, ViewDims.view_scaled.Y, 0));
                model.level.draw(spriteBatch);
                spriteBatch.End();
                break;

            case game_status_enum.level_score:
                spriteBatch.Begin(SpriteSortMode.BackToFront, null, SamplerState.PointClamp, null, null, null, Matrix.CreateTranslation(ViewDims.view_scaled.X, ViewDims.view_scaled.Y, 0));
                model.level.map.draw(spriteBatch);
                spriteBatch.End();
                break;

            case game_status_enum.pipe_transition:
                switch (model.pipe_status)
                {
                case pipe_status_enum.BLACK:
                    game.GraphicsDevice.Clear(Color.Black);
                    break;

                default:
                    spriteBatch.Begin(SpriteSortMode.BackToFront, null, SamplerState.PointClamp, null, null, null, Matrix.CreateTranslation(ViewDims.view_scaled.X, ViewDims.view_scaled.Y, 0));
                    model.level.draw(spriteBatch);
                    spriteBatch.End();
                    break;
                }
                break;

            case game_status_enum.level_complete:
                spriteBatch.Begin(SpriteSortMode.BackToFront, null, SamplerState.PointClamp, null, null, null, Matrix.CreateTranslation(ViewDims.view_scaled.X, ViewDims.view_scaled.Y, 0));
                model.level.draw(spriteBatch);
                spriteBatch.End();
                break;
            }

            DrawShape.Rectangle(ViewDims.left_edge, Color.Black);
            DrawShape.Rectangle(ViewDims.right_edge, Color.Black);
        } /* draw() */
        } /* update_mario() */

/***********************************************************
*
*   Method:
*       update_mario_level_complete
*
*   Description:
*       Updates mario after level is complete.
*
***********************************************************/

        private mario_status_enum update_mario_level_complete()
        {
            mario_status_enum status  = model.level.mario.status;
            physics_type      physics = model.level.mario.physics;

//set status to falling when we hit the pole, then make a check if falling here

            switch (status)
            {
            case mario_status_enum.FALL_L:
                status = mario_status_enum.FALL_R;
                break;

            case mario_status_enum.JUMP_L:
                status = mario_status_enum.JUMP_R;
                break;

            case mario_status_enum.FALL_R:
            case mario_status_enum.JUMP_R:
                /*----------------------------------------------------------
                *  Let mario fall till the top of the pole, then start descent
                *  ----------------------------------------------------------*/
                if (((physics.position.y + physics.hit_box.Height - (8 << 12)) >> 16) >= ((model.level.map.flag_loc.Top) >> 4))
                {
                    status = mario_status_enum.POLE_R;
                }
                else
                {
                    update_mario_falling(physics);
                    physics.position.y += physics.velocity.y;
                    physics.position.x  = (model.level.map.flag_loc.X - physics.hit_box.Width + 6) << 12;
                }
                break;

            case mario_status_enum.POLE_R:
            case mario_status_enum.POLE_BOTTOM_R:
                Boolean mario_bottom = (physics.position.y >> 12) + physics.hit_box.Height >= model.level.map.flag_loc.Bottom;
                Boolean flag_bottom  = (model.level.map.flag.y + model.level.map.flag.height + 4) >= model.level.map.flag_loc.Bottom;

                /*----------------------------------------------------------
                *  Slide down pole
                *  ----------------------------------------------------------*/
                physics.position.x = (model.level.map.flag_loc.X - physics.hit_box.Width + 6) << 12;

                if (!mario_bottom)
                {
                    physics.position.y += MarioPhysics.vy_desc_vine;
                }
                else
                {
                    status = mario_status_enum.POLE_BOTTOM_R;
                }
                if (!flag_bottom)
                {
                    model.level.map.flag.y += (MarioPhysics.vy_desc_vine >> 12);
                }

                /*----------------------------------------------------------
                *  Switch pole sides once mario hits the bottom
                *  ----------------------------------------------------------*/
                if (mario_bottom && flag_bottom)
                {
                    physics.position.y  = (model.level.map.flag_loc.Bottom - physics.hit_box.Height) << 12;
                    physics.position.x += ((2 + physics.hit_box.Width) << 12);
                    status              = mario_status_enum.POLE_L;
                    init_frame_pole_l   = Animations.frame_count;
                }
                break;

            case mario_status_enum.POLE_L:
                if (Animations.frame_count >= (init_frame_pole_l + 30))
                {
                    status            = mario_status_enum.WALK_CTRL_L;
                    init_frame_pole_l = Animations.frame_count;
                }
                break;

            case mario_status_enum.WALK_CTRL_L:
                if (Animations.frame_count >= (init_frame_pole_l + 8))
                {
                    status = mario_status_enum.WALK_CTRL_R;
                }
                else if (Animations.frame_count >= (init_frame_pole_l + 4))
                {
                    physics.position.x += (2 << 12);
                    physics.position.y += ((Animations.frame_count - init_frame_pole_l - 4) << 12);
                }
                else
                {
                    physics.position.x += (2 << 12);
                }
                break;

            case mario_status_enum.WALK_CTRL_R:
                physics.position.y  = (model.level.map.flag_loc.Bottom - physics.hit_box.Height + 17) << 12;
                physics.position.x += MarioPhysics.vx_walk_no_ctrl_max;
                ViewDims.move_view_location(MarioPhysics.vx_walk_no_ctrl_max);

                if (physics.position.x >= model.level.map.exit_loc_x)
                {
                    status            = mario_status_enum.STILL_R;
                    model.game_status = game_status_enum.level_score;
                }
                break;

            default:
                status = mario_status_enum.POLE_R;
                break;
            }

            return(status);
        }