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.

25 lines
792 B

  1. using Microsoft.Xna.Framework;
  2. using System;
  3. // Good background reading, eventually:
  4. // https://gamasutra.com/blogs/ItayKeren/20150511/243083/Scroll_Back_The_Theory_and_Practice_of_Cameras_in_SideScrollers.php
  5. namespace SemiColinGames {
  6. class Camera {
  7. private Rectangle bbox = new Rectangle(0, 0, 1920 / 4, 1080 / 4);
  8. public int Width { get => bbox.Width; }
  9. public int Height { get => bbox.Height; }
  10. public int Left { get => bbox.Left; }
  11. public void Update(GameTime time, Point player) {
  12. int diff = player.X - bbox.Center.X;
  13. if (Math.Abs(diff) > 16) {
  14. bbox.Offset((int) (diff * 0.1), 0);
  15. }
  16. if (bbox.Left < 0) {
  17. bbox.Offset(-bbox.Left, 0);
  18. }
  19. Debug.Toast($"p: {player.X}, {player.Y} c: {bbox.Center.X}");
  20. }
  21. }
  22. }