Compare commits

..

No commits in common. "db01dcea2868663084d27b60e95284b1ca9a6ebb" and "3c08579ed91acde567ac3c0b3b6f13b5101ba3f3" have entirely different histories.

3 changed files with 19 additions and 29 deletions

View File

@ -8,8 +8,7 @@ namespace SemiColinGames {
const float DESIRED_ASPECT_RATIO = 1920.0f / 1080.0f; const float DESIRED_ASPECT_RATIO = 1920.0f / 1080.0f;
private readonly Color letterboxColor = Color.DarkSlateBlue; private readonly Color backgroundColor = Color.DarkBlue;
private readonly Color backgroundColor = Color.Black;
private readonly GraphicsDevice graphics; private readonly GraphicsDevice graphics;
private readonly RenderTarget2D sceneTarget; private readonly RenderTarget2D sceneTarget;
@ -36,6 +35,8 @@ namespace SemiColinGames {
public void Draw(bool isRunningSlowly, IWorld iworld, bool paused) { public void Draw(bool isRunningSlowly, IWorld iworld, bool paused) {
ShmupWorld world = (ShmupWorld) iworld; ShmupWorld world = (ShmupWorld) iworld;
graphics.SetRenderTarget(null);
graphics.Clear(Color.Black);
// Draw scene to sceneTarget. // Draw scene to sceneTarget.
graphics.SetRenderTarget(sceneTarget); graphics.SetRenderTarget(sceneTarget);
@ -63,7 +64,6 @@ namespace SemiColinGames {
// Get ready to draw sceneTarget to screen. // Get ready to draw sceneTarget to screen.
graphics.SetRenderTarget(null); graphics.SetRenderTarget(null);
graphics.Clear(letterboxColor);
// Letterbox the scene if needed. // Letterbox the scene if needed.
float aspectRatio = 1.0f * graphics.Viewport.Width / graphics.Viewport.Height; float aspectRatio = 1.0f * graphics.Viewport.Width / graphics.Viewport.Height;

View File

@ -16,33 +16,26 @@ namespace SemiColinGames {
public class Shot { public class Shot {
public TextureRef Texture = Textures.Projectile1; public TextureRef Texture = Textures.Projectile1;
public Vector2 Position; public Vector2 Position;
public Vector2 HalfSize = new Vector2(11, 4); public Vector2 HalfSize = new Vector2(11, 8);
public Rectangle Bounds;
public Vector2 Velocity; public Vector2 Velocity;
public Shot(Vector2 position, Vector2 velocity) { public Shot(Vector2 position, Vector2 velocity) {
Position = position; Position = position;
Velocity = velocity; Velocity = velocity;
Update(0); // set Bounds
}
public void Update(float modelTime) {
Position = Vector2.Add(Position, Vector2.Multiply(Velocity, modelTime));
Bounds = new Rectangle(
(int) (Position.X - HalfSize.X),
(int) (Position.Y - HalfSize.Y),
(int) HalfSize.X * 2,
(int) HalfSize.Y * 2);
} }
} }
public readonly Rectangle Bounds; public readonly Point Size;
public readonly ShmupPlayer Player; public readonly ShmupPlayer Player;
public readonly ProfilingList<Shot> Shots; public readonly ProfilingList<Shot> Shots;
public ShmupWorld() { public ShmupWorld() {
Bounds = new Rectangle(0, 0, 1920 / 4, 1080 / 4); Size = new Point(1920 / 4, 1080 / 4);
Player = new ShmupPlayer(); Player = new ShmupPlayer();
Shots = new ProfilingList<Shot>(100, "shots"); Shots = new ProfilingList<Shot>(100, "shots");
Vector2 velocity = new Vector2(100, 0);
Shots.Add(new Shot(new Vector2(96, 1080 / 8), velocity));
Shots.Add(new Shot(new Vector2(96 * 2, 1080 / 8), velocity));
Shots.Add(new Shot(new Vector2(96 * 4, 1080 / 8), velocity));
} }
~ShmupWorld() { ~ShmupWorld() {
@ -57,22 +50,19 @@ namespace SemiColinGames {
Vector2 motion = Vector2.Multiply(input[0].Motion, modelTime * Player.Speed); Vector2 motion = Vector2.Multiply(input[0].Motion, modelTime * Player.Speed);
Player.Position = Vector2.Add(Player.Position, motion); Player.Position = Vector2.Add(Player.Position, motion);
Player.Position.X = Math.Max(Player.Position.X, Player.HalfSize.X); Player.Position.X = Math.Max(Player.Position.X, Player.HalfSize.X);
Player.Position.X = Math.Min(Player.Position.X, Bounds.Size.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.Max(Player.Position.Y, Player.HalfSize.Y);
Player.Position.Y = Math.Min(Player.Position.Y, Bounds.Size.Y - Player.HalfSize.Y); Player.Position.Y = Math.Min(Player.Position.Y, Size.Y - Player.HalfSize.Y);
foreach (Shot shot in Shots) { foreach (Shot shot in Shots) {
shot.Update(modelTime); shot.Position = Vector2.Add(shot.Position, Vector2.Multiply(shot.Velocity, modelTime));
shot.Position.X = Math.Max(shot.Position.X, shot.HalfSize.X);
shot.Position.X = Math.Min(shot.Position.X, Size.X - shot.HalfSize.X);
shot.Position.X = Math.Max(shot.Position.X, shot.HalfSize.X);
shot.Position.X = Math.Min(shot.Position.X, Size.X - shot.HalfSize.X);
} }
if (input[0].Attack && !input[1].Attack) { // Shots.RemoveAll(shot => shot.Position.X > Size.X);
Vector2 shotOffset = new Vector2(12, 2);
Vector2 shotPosition = Vector2.Add(Player.Position, shotOffset);
Shot shot = new Shot(shotPosition, new Vector2(300, 0));
Shots.Add(shot);
}
Shots.RemoveAll(shot => !Bounds.Intersects(shot.Bounds));
} }
} }
} }

View File

@ -70,7 +70,7 @@ namespace SemiColinGames {
scene?.Dispose(); scene?.Dispose();
// scene = new SneakScene(GraphicsDevice, ((SneakWorld) world).Camera); // scene = new SneakScene(GraphicsDevice, ((SneakWorld) world).Camera);
// scene = new TreeScene(GraphicsDevice); // scene = new TreeScene(GraphicsDevice);
scene = new ShmupScene(GraphicsDevice, ((ShmupWorld) world).Bounds.Size); scene = new ShmupScene(GraphicsDevice, ((ShmupWorld) world).Size);
GC.Collect(); GC.Collect();
GC.WaitForPendingFinalizers(); GC.WaitForPendingFinalizers();