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.
 
 
 

86 lines
2.6 KiB

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
namespace SemiColinGames {
public sealed class SpiderWorld : IWorld {
public class Spider {
public TextureRef Texture = Textures.Yellow2;
public Vector2 Position;
private Vector2 anchor;
private float radius;
private float angle;
private float momentum = -300; // radians / second * pixels
public Spider(float x, float y, float radius, float angle) {
Position = new Vector2();
anchor = new Vector2(x, y);
this.angle = angle;
this.radius = radius;
}
public void Update(float modelTime, History<Input> input) {
radius += 150 * modelTime * input[0].Motion.Y;
radius = Math.Min(radius, 200);
radius = Math.Max(radius, 50);
float angleChange = modelTime * momentum / radius;
angle += angleChange;
float x = anchor.X + radius * (float) Math.Sin(angle);
float y = anchor.Y + radius * (float) Math.Cos(angle);
Position.X = x;
Position.Y = y;
}
public void Draw(SpriteBatch spriteBatch) {
Texture2D texture = Texture.Get;
Vector2 spriteCenter = new Vector2(texture.Width / 2, texture.Height / 2);
Vector2 drawPos = Vector2.Floor(Vector2.Subtract(Position, spriteCenter));
spriteBatch.Draw(texture, drawPos, Color.White);
}
}
public class Anchor {
public TextureRef Texture = Textures.Terran;
public Vector2 Position;
public Anchor(float x, float y) {
Position = new Vector2(x, y);
}
public void Draw(SpriteBatch spriteBatch) {
Texture2D texture = Texture.Get;
Vector2 spriteCenter = new Vector2(texture.Width / 2, texture.Height / 2);
Vector2 drawPos = Vector2.Floor(Vector2.Subtract(Position, spriteCenter));
spriteBatch.Draw(texture, drawPos, Color.White);
}
}
public readonly Rectangle Bounds;
public Spider Player;
public ProfilingList<Anchor> Anchors;
public SpiderWorld() {
Bounds = new Rectangle(0, 0, 1280, 720);
Player = new Spider(200, 720 / 2, 200, 0);
Anchors = new ProfilingList<Anchor>(100, "anchors");
Anchors.Add(new Anchor(200, 720 / 2));
Anchors.Add(new Anchor(600, 720 / 4));
Anchors.Add(new Anchor(800, 640));
}
~SpiderWorld() {
Dispose();
}
public void Dispose() {
GC.SuppressFinalize(this);
}
public void Update(float modelTime, History<Input> input) {
Player.Update(modelTime, input);
}
}
}