当前位置: 首页>>代码示例>>C#>>正文


C# Model.getAccumulatedHeight方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Model.getAccumulatedHeight方法的典型用法代码示例。如果您正苦于以下问题:C# Model.getAccumulatedHeight方法的具体用法?C# Model.getAccumulatedHeight怎么用?C# Model.getAccumulatedHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.Model的用法示例。


在下文中一共展示了Model.getAccumulatedHeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        internal void Draw(Model.MainModel a_mainModel, double a_elapsedTimeTotalSeconds)
        {
            //Variables used for drawing game
                //Vector2 modelPosition = a_mainModel.getPlayerPosition();

                m_tiles = a_mainModel.getTiles();

                //Destination rectangle for Megaman

                //Get model coordinates for Megaman
                Vector2 megamanModelPos = a_mainModel.getPlayerPosition();

                //Model height of viewPort
                float modelViewPortY = (float)m_windowHeight / 64f;

                //Calculate model displacement for y
                float modelDisplacementY = megamanModelPos.Y - (modelViewPortY / 2.0f);

                //Calculate view DisplacementY for Y
                int viewDisplacementY = (int)(modelDisplacementY * 64f);

                //Translate to view coordinates for megaman
                Vector2 megamanViewPos = megamanModelPos * 64f;

                //Create destination rectangle for megaman
                Rectangle destRectMegaman = new Rectangle((int)megamanViewPos.X, (int)megamanViewPos.Y - viewDisplacementY, 64, 64);

                //Create destination rectangle for background
                Rectangle sourceBackgroundRectangle = new Rectangle(0, 100, 64, 64);

                Rectangle destBackgroundRectangle = new Rectangle(0, -(int)((float)viewDisplacementY / 27f), 640, 1920);

                //Create destination rectangle for scoreboard
                Rectangle destScoreBoard = new Rectangle(0, 10, 640, 60);

                m_spriteBatch.Begin();

                //Draw background
                switch (m_currentLevel)
                {
                    case 0: m_spriteBatch.Draw(m_background, destBackgroundRectangle, Color.White);
                        break;

                    case 1: m_spriteBatch.Draw(m_backGroundSky, destBackgroundRectangle, Color.White);
                        break;

                    case 2: m_spriteBatch.Draw(m_backGroundSpace, destBackgroundRectangle, Color.White);
                        break;

                }

                //Draw level
                for (int x = 0; x < a_mainModel.getlevelWidth(); x++)
                {
                    for (int y = 0; y < a_mainModel.getlevelHeight(); y++)
                    {
                        //Source rectangle
                        Rectangle sourceRectangle = new Rectangle((int)m_tiles[x, y] * m_textureTileSize, 0, m_viewscale, m_viewscale);

                        //Destination rectangle
                        //y ska ändras här för att passa spelarens position! Dvs istället för 100 ska vi ha displacement
                        //Med 100 har allting "flyttats ned" 100 pixlar
                        Rectangle destRect = new Rectangle((x * m_viewscale), (y * m_viewscale) - viewDisplacementY, m_viewscale, m_viewscale);

                        m_spriteBatch.Draw(m_texture, destRect, sourceRectangle, Color.White);

                    }
                }

                //Draw Megaman if not dead
                if (!gameOver)
                    m_spriteBatch.Draw(m_megaMan, destRectMegaman, Color.White);

                else if (gameOver&&!m_clearedAllLevels)
                {
                    m_spriteBatch.Draw(m_megaManDead, destRectMegaman, Color.White);
                    Rectangle gameOverDestRect = new Rectangle(90, 200, 477, 93);
                    m_spriteBatch.Draw(m_gameOverSign, gameOverDestRect, Color.White);
                }

                //Draw scoreboard
                m_spriteBatch.Draw(m_scoreBoard, destScoreBoard, Color.White);

                //Draw height score
                m_spriteBatch.DrawString(font, "Height: " + ((int)((400 - a_mainModel.getPlayerPosition().Y+a_mainModel.getAccumulatedHeight()))).ToString(), new Vector2(20, 30), Color.White);

                //Draw elapsed time
                m_spriteBatch.DrawString(font, "Time: " + String.Format("{0:0.00}", a_mainModel.getElapsedTime()), new Vector2(160, 30), Color.White);

                //Draw number of coins
                m_spriteBatch.DrawString(font, "Coins: " + a_mainModel.getNumberOfCoins().ToString(), new Vector2(300, 30), Color.White);

                //Draw score
                m_spriteBatch.DrawString(font, "Score: " + a_mainModel.getScore().ToString(), new Vector2(440, 30), Color.White);

                if (m_showAnnouncement)
                {
                    Rectangle levelDestRect = new Rectangle(90, 280, 477, 93);
                    m_spriteBatch.Draw(m_nextLevelSign, levelDestRect, Color.White);

//.........这里部分代码省略.........
开发者ID:BaltaX,项目名称:MegaJump,代码行数:101,代码来源:MainView.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Model.getAccumulatedHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。