Exemple #1
0
 /// <summary>
 /// This is called when the game should draw itself.
 /// </summary>
 /// <param name="gameTime">Provides a snapshot of timing values.</param>
 protected override void Draw(GameTime gameTime)
 {
     GraphicsDevice.Clear(Color.CornflowerBlue);
     graphics.BeginDraw();
     MapRenderer.DrawMap(gameTime, spriteBatch, graphics);
     base.Draw(gameTime);
 }
Exemple #2
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            m_screenManager.Draw(gameTime);

            graphics.BeginDraw();

            base.Draw(gameTime);
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gameTime"></param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            _spriteBatch.Begin();

            //TODO: Draw circle and Cross
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (_gameTable[i, j] == 1)
                    {
                        //circle
                        _spriteBatch.Draw(_circle, new Vector2(200 * j, 200 * i),
                                          null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    }
                    else if (_gameTable[i, j] == -1)
                    {
                        //cross
                        _spriteBatch.Draw(_cross, new Vector2(200 * j, 200 * i), null,
                                          Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    }
                }
            }

            //Draw Lines for game board

            // X axis
            _spriteBatch.Draw(_line, new Vector2(0, 200), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            _spriteBatch.Draw(_line, new Vector2(0, 400), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

            // Y axis
            _spriteBatch.Draw(_line, new Vector2(200, 0), null, Color.White, MathHelper.Pi / 2, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            _spriteBatch.Draw(_line, new Vector2(400, 0), null, Color.White, MathHelper.Pi / 2, Vector2.Zero, 1f, SpriteEffects.None, 0f);

            //TODO: Draw Finish line


            _spriteBatch.End();

            _graphics.BeginDraw();

            base.Draw(gameTime);
        }
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.DimGray);

            _spriteBatch.Begin();

            //BG drawing
            _spriteBatch.Draw(_rect, Vector2.Zero, null, Color.Black, 0f, Vector2.Zero, new Vector2(WIDTH, HEIGHT), SpriteEffects.None, 0f);

            //Snake drawing
            foreach (Vector2 sp in _snakePelletsPos)
            {
                if (sp.X >= 0 && sp.X < MainScene.WIDTH &&
                    sp.Y >= 0 && sp.Y < MainScene.HEIGHT)
                {
                    _spriteBatch.Draw(_pellet, sp, Color.White);
                }
            }

            _spriteBatch.Draw(_pellet, _foodPos, Color.Lime);

            _spriteBatch.DrawString(_font, "SCORE : " + _score, new Vector2(10, HEIGHT + 40), Color.White);
            _spriteBatch.DrawString(_font, "TIME : " + String.Format("{0}:{1:00}", _timer / 600000000, (_timer / 10000000) % 60), new Vector2(WIDTH * 3 / 4, HEIGHT + 40), Color.White);

            if (_currentGameState == GameState.GamePaused)
            {
                Vector2 fontSize = _font.MeasureString("Pause");
                _spriteBatch.DrawString(_font, "Pause", new Vector2((WIDTH - fontSize.X) / 2, (HEIGHT - fontSize.Y) / 2), Color.YellowGreen);
            }
            else if (_currentGameState == GameState.GameEnded)
            {
                Vector2 fontSize = _font.MeasureString("Game Over");
                _spriteBatch.DrawString(_font, "Game Over", new Vector2((WIDTH - fontSize.X) / 2, (HEIGHT - fontSize.Y) / 2), Color.YellowGreen);
                fontSize = _font.MeasureString("Press SPACE to restart");
                _spriteBatch.DrawString(_font, "Press SPACE to restart", new Vector2((WIDTH - fontSize.X) / 2, (HEIGHT - fontSize.Y) / 2 + 20), Color.YellowGreen);
            }

            _spriteBatch.End();

            _graphics.BeginDraw();

            base.Draw(gameTime);
        }
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin();
            switch (Singleton.Instance.CurrentGameState)
            {
            case Singleton.GameState.GameMenu:
                DrawMenu();
                break;

            case Singleton.GameState.GameControl:
                DrawImage(_controlBG);
                break;

            case Singleton.GameState.GameAbout:
                DrawImage(_aboutBG);
                break;

            case Singleton.GameState.GamePlaying:
                DrawPlaying();
                break;

            case Singleton.GameState.GamePaused:
                DrawPlaying();
                DrawOverlay("Game paused");
                break;

            case Singleton.GameState.GameLose:
                DrawPlaying();
                DrawOverlay("You Lose");
                break;

            case Singleton.GameState.GameWin:
                DrawPlaying();
                DrawOverlay("You Win");
                break;
            }
            spriteBatch.End();
            graphics.BeginDraw();
            base.Draw(gameTime);
        }
Exemple #6
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            _spriteBatch.Begin();


            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (_gameTable[i, j] == 0)
                    {
                        //nothing
                    }
                    else if (_gameTable[i, j] == 1)
                    {
                        //circle
                        _spriteBatch.Draw(_circle, new Vector2(200 * j, 200 * i), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    }
                    else if (_gameTable[i, j] == -1)
                    {
                        //cross
                        _spriteBatch.Draw(_cross, new Vector2(200 * j, 200 * i), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    }
                }
            }

            //Lines
            _spriteBatch.Draw(_line, new Vector2(0, 200), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            _spriteBatch.Draw(_line, new Vector2(0, 400), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);


            _spriteBatch.Draw(_line, new Vector2(200, 0), null, Color.White, MathHelper.Pi / 2, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            _spriteBatch.Draw(_line, new Vector2(400, 0), null, Color.White, MathHelper.Pi / 2, Vector2.Zero, 1f, SpriteEffects.None, 0f);

            //Finish line
            if (_isGameEnded)
            {
                if (_win1.X == _win2.X)
                {
                    _spriteBatch.Draw(_line, new Vector2(_win1.X * 200 + 100, 0), null, Color.Red, MathHelper.Pi / 2, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                }
                else if (_win1.Y == _win2.Y)
                {
                    _spriteBatch.Draw(_line, new Vector2(0, _win1.Y * 200 + 100), null, Color.Red, 0, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                }
                else if (_win1.X == _win1.Y)
                {
                    _spriteBatch.Draw(_line, new Vector2(0, 0), null, Color.Red, MathHelper.Pi / 4, Vector2.Zero, 1.414f, SpriteEffects.None, 0f);
                }
                else if (_win2.X == _win1.Y)
                {
                    _spriteBatch.Draw(_line, new Vector2(0, 600), null, Color.Red, -MathHelper.Pi / 4, Vector2.Zero, 1.414f, SpriteEffects.None, 0f);
                }
            }


            _spriteBatch.End();

            _graphics.BeginDraw();

            base.Draw(gameTime);
        }
Exemple #7
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.White);

            _spriteBatch.Begin();

            //Draw board
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    //draw checker board
                    if ((i + j) % 2 == 0)
                    {
                        _spriteBatch.Draw(_rect, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Black, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    }
                }
            }

            //draw chips
            switch (_currentGameState)
            {
            case GameState.TurnBeginning:
                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        switch (_gameTable[i, j])
                        {
                        case 1:
                            _spriteBatch.Draw(_chip, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Yellow, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case -1:
                            _spriteBatch.Draw(_chip, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case 2:
                            _spriteBatch.Draw(_horse, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Yellow, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case -2:
                            _spriteBatch.Draw(_horse, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;
                        }
                    }
                }
                break;

            case GameState.WaitingForSelection:
                //draw possible clicked
                foreach (Point p in _possibleClicked)
                {
                    _spriteBatch.Draw(_rect, new Vector2(_TILESIZE * p.X, _TILESIZE * p.Y), null, Color.DarkGreen, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                }

                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        switch (_gameTable[i, j])
                        {
                        case 1:
                            _spriteBatch.Draw(_chip, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Yellow, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case -1:
                            _spriteBatch.Draw(_chip, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case 2:
                            _spriteBatch.Draw(_horse, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Yellow, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case -2:
                            _spriteBatch.Draw(_horse, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;
                        }
                    }
                }
                break;

            case GameState.ChipSelected:
                //draw selected tile
                _spriteBatch.Draw(_rect, new Vector2(_TILESIZE * _selectedTile.X, _TILESIZE * _selectedTile.Y), null, Color.Blue, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                //draw possible move
                foreach (Point v in _possibleClicked)
                {
                    _spriteBatch.Draw(_rect, new Vector2(_TILESIZE * v.X, _TILESIZE * v.Y), null, Color.LimeGreen, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                }

                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        switch (_gameTable[i, j])
                        {
                        case 1:
                            _spriteBatch.Draw(_chip, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Yellow, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case -1:
                            _spriteBatch.Draw(_chip, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case 2:
                            _spriteBatch.Draw(_horse, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Yellow, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case -2:
                            _spriteBatch.Draw(_horse, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;
                        }
                    }
                }
                break;

            case GameState.GameEnded:
                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        switch (_gameTable[i, j])
                        {
                        case 1:
                            _spriteBatch.Draw(_chip, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Yellow, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case -1:
                            _spriteBatch.Draw(_chip, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case 2:
                            _spriteBatch.Draw(_horse, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Yellow, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;

                        case -2:
                            _spriteBatch.Draw(_horse, new Vector2(_TILESIZE * j, _TILESIZE * i), null, Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

                            break;
                        }
                    }
                }

                //display winning text
                _spriteBatch.Draw(_rect, new Vector2(_TILESIZE * (8 - 4) / 2, _TILESIZE * (8 - 2) / 2), null, Color.LightGray, 0f, Vector2.Zero, new Vector2(4, 2), SpriteEffects.None, 0f);



                //if red found unmovable, yellow wins
                if (_currentPlayerTurn == PlayerTurn.RedTurn)
                {
                    Vector2 fontSize = _font.MeasureString("Yellow wins");
                    _spriteBatch.DrawString(_font, "Yellow wins", new Vector2((_TILESIZE * 8 - fontSize.X) / 2, (_TILESIZE * 8 - fontSize.Y) / 2), Color.YellowGreen);
                }
                //else, red wins
                else
                {
                    Vector2 fontSize = _font.MeasureString("Red wins");
                    _spriteBatch.DrawString(_font, "Red wins", new Vector2((_TILESIZE * 8 - fontSize.X) / 2, (_TILESIZE * 8 - fontSize.Y) / 2), Color.DarkRed);
                }
                break;
            }

            _spriteBatch.End();

            _graphics.BeginDraw();

            base.Draw(gameTime);
        }
 public void beginDraw()
 {
     m_graphics.BeginDraw();
     m_spriteBatch.Begin(SpriteSortMode.Immediate, null, SamplerState.PointClamp, null, null, null, m_scale);
     m_gameInstance.GraphicsDevice.Clear(Color.Black);
 }