Пример #1
0
        //-----------------------------------------------------------------------------
        // Overriden methods
        //-----------------------------------------------------------------------------

        protected override void Draw()
        {
            editorControl.UpdateTicks();

            Graphics2D g = new Graphics2D(spriteBatch);

            g.Begin(GameSettings.DRAW_MODE_DEFAULT);
            DrawLevel(g);
            g.End();

            /*
             * Graphics2D g = new Graphics2D(spriteBatch);
             * g.SetRenderTarget(levelRenderTarget);
             * g.Begin(GameSettings.DRAW_MODE_DEFAULT);
             * DrawLevel(g);
             * g.End();
             *
             * g.SetRenderTarget(null);
             *
             * spriteBatch.GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.Red);
             *
             * g.Begin(GameSettings.DRAW_MODE_DEFAULT);
             * g.DrawImage(levelRenderTarget, Point2I.Zero);
             * g.End();*/
        }
Пример #2
0
        //-----------------------------------------------------------------------------
        // Drawing
        //-----------------------------------------------------------------------------

        // Called every step to draw the game.
        public void Draw(Graphics2D g)
        {
            g.UseIntegerPrecision = true;

            // Render the game-state stack to a buffer.
            g.SetRenderTarget(GameData.RenderTargetGame);
            g.Begin(GameSettings.DRAW_MODE_DEFAULT);
            g.Clear(Color.Black);
            gameStateStack.Draw(g);
            g.End();

            // Draw the buffer to the screen scaled.
            g.SetRenderTarget(null);
            g.ResetTranslation();
            g.Begin(GameSettings.DRAW_MODE_DEFAULT);
            g.DrawImage(GameData.RenderTargetGame, Vector2F.Zero, Vector2F.Zero, new Vector2F(gameScale, gameScale), 0.0);
            g.End();
        }
Пример #3
0
        public override void Draw(Graphics2D g)
        {
            Zone zoneOld = OldRoomControl.Room.Zone;
            Zone zoneNew = NewRoomControl.Room.Zone;

            if (zoneOld == zoneNew)
            {
                // Draw the rooms normally.
                DrawRooms(g);
            }
            else
            {
                // Fade between zones.

                // Switch to the temp render target to draw the new zone.
                g.End();
                g.SetRenderTarget(GameData.RenderTargetGameTemp);
                g.Begin(GameSettings.DRAW_MODE_DEFAULT);
                OldRoomControl.Room.Zone = zoneNew;
                DrawRooms(g);
                OldRoomControl.Room.Zone = zoneOld;

                // Switch to main render target to draw the old zone.
                g.End();
                g.SetRenderTarget(GameData.RenderTargetGame);
                g.Begin(GameSettings.DRAW_MODE_DEFAULT);
                NewRoomControl.Room.Zone = zoneOld;
                DrawRooms(g);
                NewRoomControl.Room.Zone = zoneNew;

                // Draw the temp render target (with the new zone) at an opacity.
                float opacity = (float)distance / (float)maxDistance;
                Color color   = Color.White * opacity;
                g.DrawImage(GameData.RenderTargetGameTemp, Vector2F.Zero, Vector2F.Zero, Vector2F.One, 0.0, color);
            }

            // Draw the HUD.
            GameControl.HUD.Draw(g, false);
        }
Пример #4
0
        //-----------------------------------------------------------------------------
        // Overriden methods
        //-----------------------------------------------------------------------------

        protected override void Draw()
        {
            Graphics2D g = new Graphics2D(spriteBatch);

            //g.SetRenderTarget(GameData.RenderTargetGame);

            g.Begin(GameSettings.DRAW_MODE_DEFAULT);
            g.Clear(Color.White);
            g.Translate(new Vector2F(-this.HorizontalScroll.Value, -this.VerticalScroll.Value));
            g.DrawImage(Tileset.SpriteSheet.Image.GetVariant(Zone.ImageVariantID), Point2I.Zero);

            Point2I tilePoint = SelectedTile * (Tileset.SpriteSheet.CellSize + Tileset.SpriteSheet.Spacing);

            g.DrawRectangle(new Rectangle2I(tilePoint, Tileset.SpriteSheet.CellSize + 1), 1, Color.White);
            g.DrawRectangle(new Rectangle2I(tilePoint + 1, Tileset.SpriteSheet.CellSize - 1), 1, Color.Black);
            g.DrawRectangle(new Rectangle2I(tilePoint - 1, Tileset.SpriteSheet.CellSize + 3), 1, Color.Black);
            g.ResetTranslation();
            g.End();
        }
Пример #5
0
        //-----------------------------------------------------------------------------
        // Overriden methods
        //-----------------------------------------------------------------------------

        protected override void Draw()
        {
            Graphics2D g = new Graphics2D(spriteBatch);

            //g.SetRenderTarget(GameData.RenderTargetGame);
            g.Begin(GameSettings.DRAW_MODE_DEFAULT);

            Point2I selectedTileLocation = GetSelectedTileLocation();

            // Draw the tileset.
            g.Clear(Color.White);
            g.Translate(-this.HorizontalScroll.Value, -this.VerticalScroll.Value);
            if (Tileset.SpriteSheet == null)
            {
                // Draw each tile's sprite seperately.
                for (int y = 0; y < Tileset.Height; y++)
                {
                    for (int x = 0; x < Tileset.Width; x++)
                    {
                        BaseTileData tileData = Tileset.GetTileData(x, y);
                        if (tileData != null)
                        {
                            int             spacing = 1;
                            Vector2F        drawPos = new Vector2F(x, y) * (Tileset.CellSize + spacing);
                            SpriteAnimation spr     = tileData.Sprite;

                            int imageVariantID = tileData.Properties.GetInteger("image_variant", Zone.ImageVariantID);
                            if (imageVariantID < 0)
                            {
                                imageVariantID = Zone.ImageVariantID;
                            }
                            if (spr.IsAnimation)
                            {
                                int substripIndex = tileData.Properties.GetInteger("substrip_index", 0);
                                spr.Animation = spr.Animation.GetSubstrip(substripIndex);
                            }

                            g.DrawAnimation(tileData.Sprite, imageVariantID, 0.0f, drawPos, Color.White);
                        }
                    }
                }
            }
            else
            {
                // Draw the spritesheet's image.
                g.Translate(-Tileset.SpriteSheet.Offset);
                g.DrawImage(Tileset.SpriteSheet.Image.GetVariant(Zone.ImageVariantID), Point2I.Zero);
                g.ResetTranslation();
            }


            // Draw the selection box.
            if (selectedTileLocation >= Point2I.Zero)
            {
                Point2I tilePoint = selectedTileLocation * (Tileset.CellSize + Tileset.Spacing);
                g.Translate(-this.HorizontalScroll.Value, -this.VerticalScroll.Value);
                g.DrawRectangle(new Rectangle2I(tilePoint, Tileset.CellSize + 1), 1, Color.White);
                g.DrawRectangle(new Rectangle2I(tilePoint + 1, Tileset.CellSize - 1), 1, Color.Black);
                g.DrawRectangle(new Rectangle2I(tilePoint - 1, Tileset.CellSize + 3), 1, Color.Black);
                g.ResetTranslation();
            }

            g.End();
        }