A stealth-based 2D platformer where you don't have to kill anyone unless you want to. https://www.semicolin.games
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System;
  4. using System.Collections.Generic;
  5. namespace SemiColinGames {
  6. public sealed class ShmupWorld : IWorld {
  7. public class ShmupPlayer {
  8. public TextureRef Texture = Textures.Yellow2;
  9. // Center of player sprite.
  10. public Vector2 Position = new Vector2(32, 1080 / 8);
  11. public Vector2 HalfSize = new Vector2(16, 10);
  12. }
  13. public readonly Point Size;
  14. public readonly ShmupPlayer Player;
  15. public ShmupWorld() {
  16. Size = new Point(1920 / 4, 1080 / 4);
  17. Player = new ShmupPlayer();
  18. }
  19. ~ShmupWorld() {
  20. Dispose();
  21. }
  22. public void Dispose() {
  23. GC.SuppressFinalize(this);
  24. }
  25. public void Update(float modelTime, History<Input> input) {
  26. float speed = 150f;
  27. Vector2 motion = Vector2.Multiply(input[0].Motion, modelTime * speed);
  28. Player.Position = Vector2.Add(Player.Position, motion);
  29. Player.Position.X = Math.Max(Player.Position.X, Player.HalfSize.X);
  30. Player.Position.X = Math.Min(Player.Position.X, Size.X - Player.HalfSize.X);
  31. Player.Position.Y = Math.Max(Player.Position.Y, Player.HalfSize.Y);
  32. Player.Position.Y = Math.Min(Player.Position.Y, Size.Y - Player.HalfSize.Y);
  33. }
  34. }
  35. }