DisplayInfo

This commit is contained in:
Michał Dulski 2019-04-23 11:24:01 +02:00
parent d26d9e1bc8
commit aa08fb43d9
5 changed files with 107 additions and 1 deletions

View File

@ -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

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file contains an xml description of a font, and will be read by the XNA
Framework Content Pipeline. Follow the comments to customize the appearance
of the font in your game, and to change the characters which are available to draw
with.
-->
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:FontDescription">
<!--
Modify this string to change the font that will be imported.
-->
<FontName>Arial</FontName>
<!--
Size is a float value, measured in points. Modify this value to change
the size of the font.
-->
<Size>12</Size>
<!--
Spacing is a float value, measured in pixels. Modify this value to change
the amount of spacing in between characters.
-->
<Spacing>0</Spacing>
<!--
UseKerning controls the layout of the font. If this value is true, kerning information
will be used when placing characters.
-->
<UseKerning>true</UseKerning>
<!--
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive.
-->
<Style>Regular</Style>
<!--
If you uncomment this line, the default character will be substituted if you draw
or measure text that contains characters which were not included in the font.
-->
<!-- <DefaultCharacter>*</DefaultCharacter> -->
<!--
CharacterRegions control what letters are available in the font. Every
character from Start to End will be built and made available for drawing. The
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
character set. The characters are ordered according to the Unicode standard.
See the documentation for more information.
-->
<CharacterRegions>
<CharacterRegion>
<Start>&#32;</Start>
<End>&#126;</End>
</CharacterRegion>
</CharacterRegions>
</Asset>
</XnaContent>

View File

@ -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
{
}
}

View File

@ -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<SpriteFont>("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<string, string>(){["Dupa"] = "123", ["Stefan"] = "555", ["Dupa1"] = "123", ["Stefan1"] = "555", ["Dupa2"] = "123", ["Stefan2"] = "555"});
spriteBatch.End();
// TODO: Add your drawing code here
base.Draw(gameTime);
}
/// <summary>
///
/// </summary>
/// <param name="info"></param>
public void Display(Dictionary<string, string> info)
{
int x = 510;
int y = 10;
foreach (KeyValuePair<string, string> 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;
}
}
}
}

View File

@ -80,6 +80,7 @@
<Compile Include="DataModels\Models\Steps\SpillStep.cs" />
<Compile Include="DataModels\Models\TrashCan.cs" />
<Compile Include="DataModels\Models\TypeOfGarbage.cs" />
<Compile Include="DataModels\ViewInfo.cs" />
<Compile Include="Game1.cs" />
<Compile Include="DataModels\Models\GarbageCollector.cs" />
<Compile Include="Program.cs" />