diff options
author | Zoryn Aaron <zoryn4163@gmail.com> | 2016-03-01 02:16:35 -0500 |
---|---|---|
committer | Zoryn Aaron <zoryn4163@gmail.com> | 2016-03-01 02:16:35 -0500 |
commit | dddb8d129b9e02279370969b0f098de31c829c2e (patch) | |
tree | 79f91cf17c76fed63fa164edc2d0c87a81f668ad /StardewModdingAPI/Inheritance | |
parent | f511c36ad357b7085891aa917e67dcd0fe51b522 (diff) | |
download | SMAPI-dddb8d129b9e02279370969b0f098de31c829c2e.tar.gz SMAPI-dddb8d129b9e02279370969b0f098de31c829c2e.tar.bz2 SMAPI-dddb8d129b9e02279370969b0f098de31c829c2e.zip |
i got it to draw without crashing im going to bed. custom content is still nyi don't try it yet
Diffstat (limited to 'StardewModdingAPI/Inheritance')
-rw-r--r-- | StardewModdingAPI/Inheritance/SGame.cs | 6 | ||||
-rw-r--r-- | StardewModdingAPI/Inheritance/SGameLocation.cs | 2 | ||||
-rw-r--r-- | StardewModdingAPI/Inheritance/SObject.cs | 31 |
3 files changed, 33 insertions, 6 deletions
diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs index b549aaf4..9f30e05e 100644 --- a/StardewModdingAPI/Inheritance/SGame.cs +++ b/StardewModdingAPI/Inheritance/SGame.cs @@ -107,9 +107,13 @@ namespace StardewModdingAPI.Inheritance { base.Draw(gameTime); Events.InvokeDrawTick(); - spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone); if (CurrentLocation != null) CurrentLocation.draw(Game1.spriteBatch); + + if (player != null && player.position != null) + spriteBatch.DrawString(Game1.dialogueFont, Game1.player.position.ToString(), new Vector2(0, 180), Color.Orange); + spriteBatch.End(); } diff --git a/StardewModdingAPI/Inheritance/SGameLocation.cs b/StardewModdingAPI/Inheritance/SGameLocation.cs index f4523c21..82caab40 100644 --- a/StardewModdingAPI/Inheritance/SGameLocation.cs +++ b/StardewModdingAPI/Inheritance/SGameLocation.cs @@ -83,7 +83,7 @@ namespace StardewModdingAPI.Inheritance { foreach (var v in ModObjects) { - v.Value.draw(b, (int)v.Key.X, (int)v.Key.Y, -999999, 1); + v.Value.draw(b, (int)v.Key.X, (int)v.Key.Y, 0.999f, 1); } } } diff --git a/StardewModdingAPI/Inheritance/SObject.cs b/StardewModdingAPI/Inheritance/SObject.cs index e05b4f20..79edcb34 100644 --- a/StardewModdingAPI/Inheritance/SObject.cs +++ b/StardewModdingAPI/Inheritance/SObject.cs @@ -48,16 +48,38 @@ namespace StardewModdingAPI.Inheritance public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) { + if (Texture != null) spriteBatch.Draw(Texture, new Vector2(x, y), new Color(255, 255, 255, 255f * alpha)); } public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) { - if (Texture != null) + try + { + if (Texture != null) + { + int targSize = 64; + int midX = (int) ((xNonTile) + 32); + int midY = (int) ((yNonTile) + 32); + + int targX = midX - targSize / 2; + int targY = midY - targSize / 2; + + Rectangle targ = new Rectangle(targX, targY, targSize, targSize); + spriteBatch.Draw(Texture, targ, null, new Color(255, 255, 255, 255f * alpha), 0, Vector2.Zero, SpriteEffects.None, layerDepth); + spriteBatch.Draw(Program.DebugPixel, targ, null, Color.Red, 0, Vector2.Zero, SpriteEffects.None, layerDepth); + spriteBatch.DrawString(Game1.dialogueFont, "TARG: " + targ, new Vector2(128, 0), Color.Red); + spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX * 0.5f, targY), Color.Orange); + spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX, targY), Color.Red); + spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX * 1.5f, targY), Color.Yellow); + spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX * 2f, targY), Color.Green); + } + } + catch (Exception ex) { - spriteBatch.Draw(Texture, new Vector2(xNonTile, yNonTile), null, new Color(255, 255, 255, 255f * alpha), 0, Vector2.Zero, 1, SpriteEffects.None, layerDepth); - spriteBatch.DrawString(Game1.dialogueFont, "TARG: " + new Vector2(xNonTile, yNonTile), new Vector2(128, 0), Color.Red); + Program.LogError(ex.ToString()); + Console.ReadKey(); } } @@ -170,10 +192,11 @@ namespace StardewModdingAPI.Inheritance if (s != null) { - Vector2 index1 = new Vector2((float)(x / Game1.tileSize), (float)(y / Game1.tileSize)); + Vector2 index1 = new Vector2(x - (Game1.tileSize / 2), y - (Game1.tileSize / 2)); if (!s.ModObjects.ContainsKey(index1)) { s.ModObjects.Add(index1, this); + Game1.player.position = index1; return true; } } |