Example #1
0
        public void Draw(SpriteBatch spriteBatch, ContentDistributionThing contentDistributionThing)
        {
            var totSize  = contentDistributionThing.ScreenSizeTotal;
            var gameSize = contentDistributionThing.ScreenSizeGame;

            if (measuredHelloString == Vector2.Zero)
            {
                measuredHelloString = contentDistributionThing.SecularOne72.MeasureString(_helloString);
            }

            var newVersionString = $"ScreenSize: {totSize.Width}x{totSize.Height}{n}GameSize: {gameSize.Width}x{gameSize.Height}{n}Version: {version}";

            if (_measuredVersionString == Vector2.Zero || newVersionString != _versionString)
            {
                _versionString         = newVersionString;
                _measuredVersionString = contentDistributionThing.SecularOne72.MeasureString(_versionString);
            }

            var posHelloString   = new Vector2(gameSize.Width / 2, gameSize.Height / 2 - gameSize.Height / 10f + (gameSize.Height / 5.0f * (float)Math.Sin(framesDelay / 20.0f)));
            var scaleHelloString = gameSize.Width / (measuredHelloString.X * 1.3f);

            //Take up 50% of the screen (in width) (also we use {sideDistance} to move it away from the side)
            int sideDistance         = 5;
            var scaleVersionString   = (1f / ((_measuredVersionString.X + sideDistance) / gameSize.Width)) * 0.25f;
            var scaledMeasuredString = _measuredVersionString * scaleVersionString;
            var posVersionString     = new Vector2(gameSize.Width - scaledMeasuredString.X - sideDistance, gameSize.Height - scaledMeasuredString.Y - sideDistance);

            spriteBatch.DrawString(contentDistributionThing.SecularOne72, _helloString, posHelloString, Color.White, 0, measuredHelloString / 2, scaleHelloString, SpriteEffects.None, 0);
            spriteBatch.DrawString(contentDistributionThing.SecularOne72, _versionString, posVersionString, Color.White, 0, Vector2.Zero, scaleVersionString, SpriteEffects.None, 0);
        }
        public static void DrawGrid(SpriteBatch spriteBatch, ContentDistributionThing contentDistributionThing, GameData gameData)
        {
            var gameSize = contentDistributionThing.ScreenSizeGame;

            for (int y = gameData.GridHeight - 1; y >= 0; y--)
            {
                for (int x = gameData.GridWidth - 1; x >= 0; x--)
                {
                    float widthOfBlockje  = gameSize.Width / gameData.GridWidth;
                    float heightOfBlockje = gameSize.Height / gameData.GridHeight;

                    float yyy       = gameSize.Height - ((1 + y) * heightOfBlockje);
                    var   blocketje = new Blocketje(contentDistributionThing.SquareImage, x * widthOfBlockje, yyy, widthOfBlockje, heightOfBlockje, 3);

                    if (gameData.Gridje[x, y] == true)
                    {
                        if (y > 7)
                        {
                            blocketje.Draw(spriteBatch, Color.Red);
                        }
                        else
                        {
                            blocketje.Draw(spriteBatch, Color.Blue);
                        }
                    }
                }
            }
        }
Example #3
0
        public void Draw(SpriteBatch spriteBatch, ContentDistributionThing contentDistributionThing)
        {
            var gameSize = contentDistributionThing.ScreenSizeGame;

            if (measuredString == Vector2.Zero)
            {
                measuredString = contentDistributionThing.SecularOne72.MeasureString(gameOverString);
            }

            if (previousHighscoreString != null && measuredPreviousHighScoreString == Vector2.Zero)
            {
                measuredPreviousHighScoreString = contentDistributionThing.SecularOne72.MeasureString(previousHighscoreString);
            }

            NormalGridDrawer.DrawGrid(spriteBatch, contentDistributionThing, gameData);

            var pos = new Vector2(gameSize.Width / 2, gameSize.Height / 2 + (gameSize.Height / 5.0f * (float)Math.Sin(framesDelay / 20.0f)));

            var scale = gameSize.Width / (measuredString.X * 1.3f);

            spriteBatch.DrawString(contentDistributionThing.SecularOne72, gameOverString, pos, Color.White, 0, measuredString / 2, scale + ((1.0f + (float)Math.Sin(framesDelay / 6.0f)) * 0.15f), SpriteEffects.None, 0);

            if (measuredPreviousHighScoreString != Vector2.Zero)
            {
                var scalePrev = gameSize.Width / (measuredPreviousHighScoreString.X * 1.3f);
                var posPrev   = new Vector2(gameSize.Width / 2, 5 + measuredPreviousHighScoreString.Y * scale / 2.0f);
                spriteBatch.DrawString(contentDistributionThing.SecularOne72, previousHighscoreString, posPrev, Color.White, 0, measuredPreviousHighScoreString / 2, scalePrev, SpriteEffects.None, 0);
            }
        }
Example #4
0
        public EffectBlock(Color color, int gridX, int gridY, bool leftSide, ContentDistributionThing contentDistributionThing)
        {
            _color = color;

            GridX    = gridX;
            GridY    = gridY;
            LeftSide = leftSide;
            _contentDistributionThing = contentDistributionThing;
        }
Example #5
0
        public TheGame(IContentManagerExtension contentManagerExtension, IntSize?desiredScreenSize, Platform platform) : base()
        {
            _contentManagerExtension = contentManagerExtension;
            _desiredScreenSize       = desiredScreenSize;
            _platform = platform;

            _graphics = new GraphicsDeviceManager(this);

            //This is required for Blazor since it loads assets in a custom way
            Content = new ExtendibleContentManager(this.Services, _contentManagerExtension);
            Content.RootDirectory = "Content";

            IsMouseVisible = true;

            _inputStatifier = new InputStatifier();

            _contentDistributionThing = new ContentDistributionThing(_graphics);
            _currentState             = new NewGameState();
            _platform = platform;

            _effectBlockDrawer = new EffectBlockDrawer(_contentDistributionThing);
        }
Example #6
0
 public void Draw(SpriteBatch spriteBatch, ContentDistributionThing contentDistributionThing)
 {
     NormalGridDrawer.DrawGrid(spriteBatch, contentDistributionThing, gameData);
 }
Example #7
0
 public EffectBlockDrawer(ContentDistributionThing contentDistributionThing)
 {
     _contentDistributionThing = contentDistributionThing;
 }