# HG changeset patch # User alys # Date 2020-12-28 03:38:48 # Node ID 3fb0a1931f0a325de236ee0e227d73ac32878539 # Parent 5bbfda434f156913b1b832acff3ccd8cb57f53d3 Fix cursor overlay. diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -23,7 +23,7 @@ private Song music; private SpriteFont font; - private Camera camera = new Camera(new float[] {0.25f, 0.5f, 1.0f, 2.0f, 4.0f }); + private Camera camera = new Camera(new float[] { 0.25f, 0.5f, 1.0f, 2.0f, 4.0f }); Random random_generator = new Random(); @@ -160,14 +160,14 @@ } Vector2 calculateMousegrid(Vector2 normalizedMousePos) - { + { //int gridx = (int)(normalizedMousePos.X / Tile.TileSpriteWidth); //int gridy = (int)(normalizedMousePos.Y / Tile.TileSpriteHeight); Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); Vector2 adjustedMousePos = normalizedMousePos - adjust; - float boardx = ((adjustedMousePos.X/ Tile.TileSpriteWidth) + (adjustedMousePos.Y / Tile.TileSpriteHeight)); + float boardx = ((adjustedMousePos.X / Tile.TileSpriteWidth) + (adjustedMousePos.Y / Tile.TileSpriteHeight)); float boardy = ((adjustedMousePos.Y / Tile.TileSpriteHeight) - (adjustedMousePos.X / Tile.TileSpriteWidth)); @@ -238,21 +238,21 @@ } - if (keyboardCur.IsKeyDown(Keys.Down) ) + if (keyboardCur.IsKeyDown(Keys.Down)) { this.camera.Move(new Vector2(0, -2)); } - else if (keyboardCur.IsKeyDown(Keys.Up) ) - { + else if (keyboardCur.IsKeyDown(Keys.Up)) + { this.camera.Move(new Vector2(0, 2)); } - else if (keyboardCur.IsKeyDown(Keys.Left) ) + else if (keyboardCur.IsKeyDown(Keys.Left)) { this.camera.Move(new Vector2(-2, 0)); } - else if (keyboardCur.IsKeyDown(Keys.Right) ) + else if (keyboardCur.IsKeyDown(Keys.Right)) { this.camera.Move(new Vector2(2, 0)); @@ -299,13 +299,13 @@ { this.camera.Move(new Vector2(0, -4)); } - else if (MathUtils.Between(mouseCur.Y , (FNAGame.height - 50), FNAGame.height)) + else if (MathUtils.Between(mouseCur.Y, (FNAGame.height - 50), FNAGame.height)) { this.camera.Move(new Vector2(0, 4)); } - + this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice))); @@ -333,7 +333,17 @@ } + protected void drawTileAt(int x, int y, int tileIndex, int height) + { + float maxdepth = ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10; + + float depthOffset = 0.7f - ((0 + (0 * Tile.TileWidth)) / maxdepth); + + drawTileAt(x, y, tileIndex, height, depthOffset); + } + + protected void drawTileAt(int x, int y, int tileIndex, int height, float depth) { /* Vector2 firstSquare = Vector2.Zero; @@ -371,9 +381,6 @@ int screenx = (x - y) * Tile.TileSpriteWidth / 2; int screeny = (x + y) * Tile.TileSpriteHeight / 2; - float maxdepth = ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10; - - float depthOffset = 0.7f - ((0 + (0 * Tile.TileWidth)) / maxdepth); batch.Draw( Tile.TileSetTexture, @@ -386,7 +393,7 @@ 0.0f, Vector2.Zero, SpriteEffects.None, - depthOffset); + depth); } protected override void Draw(GameTime gameTime) @@ -548,7 +555,7 @@ //drawTileAt(0, 0, 22, 1); - drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1); + drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines /*