Esempio n. 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            GraphicsUtility.Initialize(this);

            TestGameArea area = new TestGameArea(0, 0, 300, 300);

            //TestGameArea2 area2 = new TestGameArea2(400, 0, 300, 300);

            env.AddGameArea(area);
            //env.AddGameArea(area2);
        }
Esempio n. 2
0
        private void SetInitialState()
        {
            Active     = true;
            Visible    = true;
            LayerIndex = 0;

            // final tile size (individual tiles are 16*16)
            Height = BlockHeight * 16;
            Width  = BlockWidth * 16;

            PositionRectangle = new Rectangle(Convert.ToInt32(X), Convert.ToInt32(Y), Width, Height);

            // Surface
            Friction = 0;
            Bounce   = 0;
            CurrentGameArea.Collision.AddCollidableObject(this);

            if (assetName == null)
            {
                int tempTextureId = 0;

                // texture related
                assetName     = "Sprites\\Game Boy GBC - Mega Man I Dr Wilys Revenge - Ice Mans Stage";
                tempTextureId = GraphicsUtility.LoadTexture(assetName);
                spriteSheet   = new SpriteSheetHandler(tempTextureId, 0, 0, 0, 0, 16, 16);

                // Tile helper
                TiledTextureRenderer renderer = new TiledTextureRenderer();
                renderer.AddTextureId(spriteSheet);

                List <TiledTextureDescriptor> tiles = new List <TiledTextureDescriptor>();
                int spriteIdOffset = 2;
                for (int i = 0; i < BlockHeight; i++)
                {
                    if (i > 0)
                    {
                        spriteIdOffset = 0;
                    }

                    for (int j = 0; j < BlockWidth; j++)
                    {
                        tiles.Add(new TiledTextureDescriptor(j * 16, i * 16, spriteIdOffset + j % 2));
                    }
                }
                textureId = renderer.RenderTexture("tiletest " + Height.ToString() + " " + Width.ToString(), tiles, Width, Height);

                GraphicsUtility.AddVisibleGameObjects(LayerIndex, this);
            }
        }
Esempio n. 3
0
        public static int GetColoredDotTextureId(Color color)
        {
            int textureId;

            if (!Dots.TryGetValue(color, out textureId))
            {
                Texture2D texture;
                texture = new Texture2D(GraphicsUtility.CurrentGraphicsDevice, 1, 1);
                texture.SetData(new Color[] { color });
                textureId = GraphicsUtility.AddTexture(color.ToString(), texture);
                Dots.Add(color, textureId);
            }

            return(textureId);
        }
Esempio n. 4
0
        public int RenderTexture(string assetName, List <TiledTextureDescriptor> textureDescriptors, int width, int height)
        {
            int newTextureId = GraphicsUtility.TextureCollection.Count;

            SpriteBatch    spriteBatch  = new SpriteBatch(GraphicsUtility.CurrentGraphicsDevice);
            RenderTarget2D renderTarget = new RenderTarget2D(GraphicsUtility.CurrentGraphicsDevice, width, height); // TODO: figure out image size

            GraphicsUtility.CurrentGraphicsDevice.SetRenderTarget(renderTarget);
            GraphicsUtility.CurrentGraphicsDevice.Clear(Color.Transparent);

            spriteBatch.Begin();

            foreach (TiledTextureDescriptor ttd in textureDescriptors)
            {
                Rectangle ttdr;
#pragma warning disable CS0618 // Type or member is obsolete
                if (TextureRectangles.TryGetValue(ttd.TiledTextureId, out ttdr))
                {
                    spriteBatch.Draw(texture: GraphicsUtility.TextureCollection[TextureIds[ttd.TiledTextureId]],
                                     position: ttd.position,
                                     sourceRectangle: ttdr);
                }
                else
                {
                    spriteBatch.Draw(texture: GraphicsUtility.TextureCollection[TextureIds[ttd.TiledTextureId]],
                                     position: ttd.position);
                }
#pragma warning restore CS0618 // Type or member is obsolete
            }

            spriteBatch.End();

            GraphicsUtility.CurrentGraphicsDevice.SetRenderTarget(null);

            newTextureId = GraphicsUtility.AddTexture(assetName, renderTarget);

            return(newTextureId);
        }
Esempio n. 5
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)
        {
            GraphicsUtility.Draw();

            base.Draw(gameTime);
        }
Esempio n. 6
0
 public virtual void ClearUnmanagedContent()
 {
     GraphicsUtility.ClearUnmanagedContent();
 }