# HG changeset patch # User alys # Date 2021-04-17 22:58:37 # Node ID 86883420e5b4ea002d843c06c7cdf058bfa09bf8 # Parent 5565d2909bef34a2563421d0ce5b8e0c52c48936 Add option to shade squares. diff --git a/SpriteFontPlus/src/obj/Debug/net45/SpriteFontPlus.FNA.csprojAssemblyReference.cache b/SpriteFontPlus/src/obj/Debug/net45/SpriteFontPlus.FNA.csprojAssemblyReference.cache index c836be7abd20d7731fb9406b256968d545cc19c3..ea7981152f806327258b6d961105e05cd386fa83 GIT binary patch literal 11415 zc%1E84{#La72m!8djT$LwO|nw1O!R$a*zZ91PBR{2nmp2szQi+ci$yT_V$k5yvu495Tm7K>}SsF;+JaXC06&GE6|0#<61f|W@T734J{ zQR0$9dAKAP4i*KA3i2w`yqp$Mxq#BL$nphw^U@KXi_S(J3zBU}D3274kC((J#KYlO zNfA4qbwjXxa*T!!Nk)kVnUxV(F>#JZ$}i{8P8DXs^C&7~3Q}+uE49jOgh#-dabn>D z(XFWm8~EoW*;q9jm6M`Z%_j%btxP6TtcXM(7&maskqh6HJdG@$MiNCiDYrYvcbN)4 zSB!B2%j-TT=TDsG#L*cS4savzaf5(xF1Tgm2U+Gcb1eccZY3)ril%eH@lyQX5MV~puGqNzqd!{$|ePTWZT(jKc_ z#mcN=df7QWW9XK1IAN&*_49M;TRNk`7-sr8F#?n!J=WgD{c>zx7HUl

AI_q>zYG zNh!oh_=b!hP$3?}+6v+6W2t_y{RD~kx7Wk#O{{p*D=`&}Hkn2&$LS`t4D?khb zaV3a65cwd6gSZOB2oNJdi~?~rh|wU%fVc+4SP%su3PA)xgg_Kw;f6qCdz_udR%@+V`wu%YW4ZRDqbORDouy z@!4}N76XHIGZ$2g7;jlpZ1c>b0IG;o-Ws)l1Fpjtb%r^(Yvo%E%ignE_)eI>mPAWR z!)4=(QPIRQH}u?IRS9NWcPlGZ)VTzF-;ru_rrKmDej4sL&$dY3Xe!N$(N?gjtZ_s+ zFTQB4;9D4MqAW3GUo;s*5xlbWwxNy`%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-41#=5&AY;=-VyOE9{`}q)4@1 zZ3}(31^OO4=(R-X`)r}_w?IE&2fdD1kVkBxH&~!I+Cgt7vWDHr6AJVQ?6ZoZAeILL zjer@hA`Cz@{^$Mh%rEzBKltybf~&U$wtqkH__6PooP6-!@0{)YU2`_A8@6-uzcwG- ze`xpN&HG9($#*=IBTo6>stqgme7Y?6!M)yPbH^MTH)!1n_sJv2^55Ee>e$z@MRNwM z-~Ga-(M^$pZK&XiGY87$rexvKuU9PoU0~0~@=-(AUR;R==Ox}+UtD|BzV(5}v{ZLY zYhHQLe*Yx;al2HXBv$ch+bV9gRPh-*=xxL*zGw^mk_CFZ9rR8j>s{x~1A4{sfL^sr z^)+G@U$?E|8z@A?;}EgWDC9D0)4;^ z`eP#WAzSFf7U)mxpg*HXwLYR=IOwCQBm60c$LM(6=t!$;GdC;{&$I7jj;`-y%Bq;Y z@R=-IpUL3Eqy8Go&p7c<#zkkY0r`;3$3& zTnvfzNM^+rq%^5&+*~{Vn24qU{j_ogL#}cafNo`G3Vn>o6uOemG@#Ziz*qqMb^rrO K0CYg(lJkF*Erx0U 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 @@ -183,9 +183,12 @@ sound = Content.Load("FNASound"); Tile.TileSetTexture = Content.Load(@"part4_tileset"); + var texture = Content.Load(@"solid_tileset"); Line.initialize(GraphicsDevice); + Quad.Initialize(GraphicsDevice, texture); + //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded: this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice); @@ -693,6 +696,10 @@ //donut Tile.DrawOutlinedSquares(batch, new Vector2[] {new Vector2(19, 1), new Vector2(19, 2), new Vector2(20, 1), new Vector2(21, 1), new Vector2(21, 2), new Vector2(19, 3), new Vector2(20, 3), new Vector2(21, 3)}, Color.Purple); + + Quad.FillSquare2(batch, 7, 4, Color.Orange, 1.0f); + Quad.FillSquare2(batch, 7, 3, Color.Yellow, 1.0f); + Quad.FillSquare2(batch, 7, 5, Color.Yellow, .5f); #endif diff --git a/isometric-park-fna/Quad.cs b/isometric-park-fna/Quad.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Quad.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace isometricparkfna +{ + + public class Quad + { + static public BasicEffect quadEffect; + static VertexPositionTexture[] vert; + static short[] ind; + + public static Texture2D PixelTexture; + public static Texture2D SolidTexture; + + + public static void Initialize(GraphicsDevice device, Texture2D texture) + { + Quad.quadEffect = new BasicEffect(device); + Quad.quadEffect.TextureEnabled = true; + + Quad.vert = new VertexPositionTexture[4]; + Quad.ind = new short[6]; + ind[0] = 0; + ind[1] = 2; + ind[2] = 1; + ind[3] = 1; + ind[4] = 2; + ind[5] = 3; + + Quad.PixelTexture = new Texture2D(device, 1, 1); + Quad.SolidTexture = texture; + } + + static public void FillSquare(GraphicsDevice device, int x, int y, Color color, float alpha) + { + + // Vector2 adjust2 = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved + // + var startX = ((x - y) * Tile.TileSpriteWidth / 2) + (Tile.TileSpriteWidth / 2); + var startY = (x + y) * Tile.TileSpriteHeight / 2 + (Tile.TileSpriteHeight); + startX = 0; + startY = 10; + // + // Rectangle rect = new Rectangle(startX, startY, Tile.TileSpriteWidth / 2, (int)(Tile.TileSpriteHeight * 0.75)); + // batch.Draw(Line.PixelTexture, rect, null, color, 0.785f, new Vector2(0,0), SpriteEffects.None, 0.79f); + // + + // vert[0].Position = new Vector3(startX, startY, 0); + // vert[1].Position = new Vector3(startX+Tile.TileSpriteWidth, startY, 0); + // vert[2].Position = new Vector3(startX, startY+Tile.TileSpriteHeight, 0); + // vert[3].Position = new Vector3(startX+Tile.TileSpriteWidth, startY+Tile.TileSpriteHeight, 0); + vert[0].Position = new Vector3(startX, startY, 0); + vert[1].Position = new Vector3(startX + 100, startY, 0); + vert[2].Position = new Vector3(startX, startY + 100, 0); + vert[3].Position = new Vector3(startX + 100, startY + 100, 0); + + + + vert[0].TextureCoordinate = new Vector2(0, 0); + vert[1].TextureCoordinate = new Vector2(1, 0); + vert[2].TextureCoordinate = new Vector2(0, 1); + vert[3].TextureCoordinate = new Vector2(1, 1); + var PixelTexture = new Texture2D(device, 1, 1); + + PixelTexture.SetData(new Color[] { color }); + + quadEffect.Texture = PixelTexture; + + + foreach (EffectPass effectPass in Quad.quadEffect.CurrentTechnique.Passes) + { + effectPass.Apply(); + device.DrawUserIndexedPrimitives( + PrimitiveType.TriangleList, Quad.vert, 0, Quad.vert.Length, Quad.ind, 0, Quad.ind.Length / 3); + } + } + + public static void FillSquare2(SpriteBatch batch, int x, int y, Color color, float alpha) + { + var height = 1; + var depth = 0.79f; + + int height_adjust = 0; + + if (height > 1) //not sure why this is necessary :/ + { + height_adjust = height; + } + + int adjustedx = x - height_adjust; + int adjustedy = y - height_adjust; + + int screenx = (adjustedx - adjustedy) * Tile.TileSpriteWidth / 2; + int screeny = (adjustedx + adjustedy) * Tile.TileSpriteHeight / 2; + + PixelTexture.SetData(new Color[] { color }); + + // color.A = (byte)(alpha*255.0f); + color *= alpha; + + // if (this.cull(x, y)) + // { + batch.Draw( + Quad.SolidTexture, + new Rectangle( + screenx, + screeny, + Tile.TileWidth, Tile.TileHeight * height), + // Tile.GetExtendedSourceRectangle(tileIndex, height), + // new Rectangle(0, 0, 1, 1), + // null, + Tile.GetExtendedSourceRectangle(0, height), + // Color.White, + color, + 0.0f, + Vector2.Zero, + SpriteEffects.None, + depth); + // } + + } + + } + + +} \ No newline at end of file diff --git a/isometric-park-fna/Tile.cs b/isometric-park-fna/Tile.cs --- a/isometric-park-fna/Tile.cs +++ b/isometric-park-fna/Tile.cs @@ -46,10 +46,16 @@ static public Texture2D TileSetTexture; + + + public Tile() { + } + + static public Rectangle GetSourceRectangle(int tileIndex) { int tileY = tileIndex / (TileSetTexture.Width / TileWidth); @@ -66,6 +72,8 @@ return new Rectangle(tileX * TileWidth, tileY * TileHeight, TileWidth, TileHeight*height); } + + static public void OutlineSquare(SpriteBatch batch, float x, float y, Color color) { Tile.OutlineSquare(batch, x, y, color, 1); diff --git a/isometric-park-fna/isometric-park-fna.csproj b/isometric-park-fna/isometric-park-fna.csproj --- a/isometric-park-fna/isometric-park-fna.csproj +++ b/isometric-park-fna/isometric-park-fna.csproj @@ -37,6 +37,7 @@ + @@ -89,6 +90,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest