2020-11-19 19:44:12 +00:00
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace SemiColinGames {
|
|
|
|
|
public sealed class ShmupWorld : IWorld {
|
2020-11-19 21:36:21 +00:00
|
|
|
|
public class ShmupPlayer {
|
|
|
|
|
public TextureRef Texture = Textures.Yellow2;
|
2020-11-19 19:44:12 +00:00
|
|
|
|
// Center of player sprite.
|
2020-11-19 21:36:21 +00:00
|
|
|
|
public Vector2 Position = new Vector2(32, 1080 / 8);
|
|
|
|
|
public Vector2 HalfSize = new Vector2(16, 10);
|
2020-11-19 19:44:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-19 21:36:21 +00:00
|
|
|
|
public readonly Point Size;
|
|
|
|
|
public readonly ShmupPlayer Player;
|
2020-11-19 19:44:12 +00:00
|
|
|
|
|
|
|
|
|
public ShmupWorld() {
|
2020-11-19 21:36:21 +00:00
|
|
|
|
Size = new Point(1920 / 4, 1080 / 4);
|
2020-11-19 19:44:12 +00:00
|
|
|
|
Player = new ShmupPlayer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~ShmupWorld() {
|
|
|
|
|
Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose() {
|
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(float modelTime, History<Input> input) {
|
|
|
|
|
float speed = 150f;
|
|
|
|
|
Vector2 motion = Vector2.Multiply(input[0].Motion, modelTime * speed);
|
|
|
|
|
Player.Position = Vector2.Add(Player.Position, motion);
|
2020-11-19 21:36:21 +00:00
|
|
|
|
Player.Position.X = Math.Max(Player.Position.X, Player.HalfSize.X);
|
|
|
|
|
Player.Position.X = Math.Min(Player.Position.X, Size.X - Player.HalfSize.X);
|
|
|
|
|
Player.Position.Y = Math.Max(Player.Position.Y, Player.HalfSize.Y);
|
|
|
|
|
Player.Position.Y = Math.Min(Player.Position.Y, Size.Y - Player.HalfSize.Y);
|
|
|
|
|
|
2020-11-19 19:44:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|