From aa08fb43d9babe81d2b27aad1a494a2518508350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulski?= Date: Tue, 23 Apr 2019 11:24:01 +0200 Subject: [PATCH] DisplayInfo --- Trunk/MonoGameView/Content/Content.mgcb | 7 +++ Trunk/MonoGameView/Content/File.spritefont | 60 ++++++++++++++++++++++ Trunk/MonoGameView/DataModels/ViewInfo.cs | 16 ++++++ Trunk/MonoGameView/Game1.cs | 24 ++++++++- Trunk/MonoGameView/MonoGameView.csproj | 1 + 5 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 Trunk/MonoGameView/Content/File.spritefont create mode 100644 Trunk/MonoGameView/DataModels/ViewInfo.cs diff --git a/Trunk/MonoGameView/Content/Content.mgcb b/Trunk/MonoGameView/Content/Content.mgcb index 131b7bf..ece1dae 100644 --- a/Trunk/MonoGameView/Content/Content.mgcb +++ b/Trunk/MonoGameView/Content/Content.mgcb @@ -25,6 +25,13 @@ /processorParam:TextureFormat=Color /build:collector.png +#begin File.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:File.spritefont;arial.spritefont + #begin glass.png /importer:TextureImporter /processor:TextureProcessor diff --git a/Trunk/MonoGameView/Content/File.spritefont b/Trunk/MonoGameView/Content/File.spritefont new file mode 100644 index 0000000..bd33ecf --- /dev/null +++ b/Trunk/MonoGameView/Content/File.spritefont @@ -0,0 +1,60 @@ + + + + + + + Arial + + + 12 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + diff --git a/Trunk/MonoGameView/DataModels/ViewInfo.cs b/Trunk/MonoGameView/DataModels/ViewInfo.cs new file mode 100644 index 0000000..996a98e --- /dev/null +++ b/Trunk/MonoGameView/DataModels/ViewInfo.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CzokoŚmieciarka.MonoGameView.DataModels.Models; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; + +namespace MonoGameView.DataModels +{ + class ViewInfo + { + + } +} diff --git a/Trunk/MonoGameView/Game1.cs b/Trunk/MonoGameView/Game1.cs index 45d82c2..a87418e 100644 --- a/Trunk/MonoGameView/Game1.cs +++ b/Trunk/MonoGameView/Game1.cs @@ -24,6 +24,8 @@ namespace CzokoŚmieciarka.MonoGameView private static int size; GraphicsDeviceManager graphics; SpriteBatch spriteBatch; + private SpriteFont font; + private int score = 0; MapLoader mapLoader = new MapLoader(); Vector2 roadPos; float timer; @@ -36,7 +38,7 @@ namespace CzokoŚmieciarka.MonoGameView { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; - graphics.PreferredBackBufferWidth = 500; + graphics.PreferredBackBufferWidth = 700; graphics.PreferredBackBufferHeight = 500; } @@ -98,6 +100,7 @@ namespace CzokoŚmieciarka.MonoGameView { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); + font = Content.Load("arial"); // TODO: use this.Content to load your game content here } @@ -157,11 +160,30 @@ namespace CzokoŚmieciarka.MonoGameView } } collector.Draw(spriteBatch, size); + Display(new Dictionary(){["Dupa"] = "123", ["Stefan"] = "555", ["Dupa1"] = "123", ["Stefan1"] = "555", ["Dupa2"] = "123", ["Stefan2"] = "555"}); + spriteBatch.End(); // TODO: Add your drawing code here base.Draw(gameTime); } + /// + /// + /// + /// + public void Display(Dictionary info) + { + int x = 510; + int y = 10; + foreach (KeyValuePair item in info) + { + spriteBatch.DrawString(font, item.Key, new Vector2(x, y),Color.Black); + y += 15; + spriteBatch.DrawString(font, item.Value, new Vector2(x, y), Color.White); + y += 30; + + } + } } } diff --git a/Trunk/MonoGameView/MonoGameView.csproj b/Trunk/MonoGameView/MonoGameView.csproj index 7b6617a..3a82a42 100644 --- a/Trunk/MonoGameView/MonoGameView.csproj +++ b/Trunk/MonoGameView/MonoGameView.csproj @@ -80,6 +80,7 @@ +