2019-08-07 22:25:33 +02:00
|
|
|
using System;
|
|
|
|
using Microsoft.Xna.Framework;
|
2019-08-09 15:15:22 +02:00
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2019-08-07 22:25:33 +02:00
|
|
|
using Microsoft.Xna.Framework.Input;
|
2019-08-09 15:15:22 +02:00
|
|
|
using MLEM.Extended.Extensions;
|
2019-08-07 22:25:33 +02:00
|
|
|
using MLEM.Input;
|
2019-08-07 21:26:16 +02:00
|
|
|
using MLEM.Startup;
|
2019-08-09 15:15:22 +02:00
|
|
|
using MLEM.Textures;
|
|
|
|
using MonoGame.Extended.TextureAtlases;
|
2019-08-07 21:26:16 +02:00
|
|
|
|
|
|
|
namespace Tests {
|
|
|
|
public class GameImpl : MlemGame {
|
|
|
|
|
2019-08-09 15:15:22 +02:00
|
|
|
private Texture2D testTexture;
|
|
|
|
private TextureRegion testRegion;
|
|
|
|
private NinePatch testPatch;
|
|
|
|
private NinePatchRegion2D extendedPatch;
|
|
|
|
|
|
|
|
protected override void LoadContent() {
|
|
|
|
base.LoadContent();
|
|
|
|
this.testTexture = LoadContent<Texture2D>("Textures/Test");
|
|
|
|
this.testRegion = new TextureRegion(this.testTexture, 32, 0, 8, 8);
|
|
|
|
this.testPatch = new NinePatch(new TextureRegion(this.testTexture, 0, 8, 24, 24), 8);
|
|
|
|
this.extendedPatch = this.testPatch.ToExtended();
|
|
|
|
}
|
|
|
|
|
2019-08-07 22:25:33 +02:00
|
|
|
protected override void Update(GameTime gameTime) {
|
|
|
|
base.Update(gameTime);
|
|
|
|
|
|
|
|
// Input tests
|
|
|
|
if (Input.IsKeyPressed(Keys.A))
|
|
|
|
Console.WriteLine("A was pressed");
|
|
|
|
if (Input.IsMouseButtonPressed(MouseButton.Left))
|
|
|
|
Console.WriteLine("Left was pressed");
|
|
|
|
if (Input.IsGamepadButtonPressed(0, Buttons.A))
|
|
|
|
Console.WriteLine("Gamepad A was pressed");
|
|
|
|
}
|
2019-08-07 21:26:16 +02:00
|
|
|
|
2019-08-09 15:15:22 +02:00
|
|
|
protected override void Draw(GameTime gameTime) {
|
|
|
|
base.Draw(gameTime);
|
|
|
|
this.GraphicsDevice.Clear(Color.Black);
|
|
|
|
|
|
|
|
// Texture region tests
|
|
|
|
this.SpriteBatch.Begin(samplerState: SamplerState.PointClamp);
|
|
|
|
this.SpriteBatch.Draw(this.testRegion, new Vector2(10, 10), Color.White);
|
|
|
|
this.SpriteBatch.Draw(this.testRegion, new Vector2(30, 10), Color.White, 0, Vector2.Zero, 10, SpriteEffects.None, 0);
|
|
|
|
this.SpriteBatch.End();
|
|
|
|
this.SpriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: Matrix.CreateScale(10));
|
|
|
|
this.SpriteBatch.Draw(this.testPatch, new Rectangle(20, 20, 40, 20), Color.White);
|
|
|
|
this.SpriteBatch.Draw(this.extendedPatch, new Rectangle(80, 20, 40, 20), Color.White);
|
|
|
|
this.SpriteBatch.End();
|
|
|
|
}
|
|
|
|
|
2019-08-07 21:26:16 +02:00
|
|
|
}
|
|
|
|
}
|