Compare commits
No commits in common. "3c08579ed91acde567ac3c0b3b6f13b5101ba3f3" and "5732d6004712c945cdd071bf4790939468c3eacf" have entirely different histories.
3c08579ed9
...
5732d60047
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
@ -61,10 +60,6 @@ namespace SemiColinGames {
|
|||||||
return items.Remove(item);
|
return items.Remove(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int RemoveAll(Predicate<T> match) {
|
|
||||||
return items.RemoveAll(match);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CopyTo(T[] array, int arrayIndex) {
|
public void CopyTo(T[] array, int arrayIndex) {
|
||||||
items.CopyTo(array, arrayIndex);
|
items.CopyTo(array, arrayIndex);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +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 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,7 +36,7 @@ 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.SetRenderTarget(null);
|
||||||
graphics.Clear(Color.Black);
|
graphics.Clear(backgroundColor);
|
||||||
|
|
||||||
// Draw scene to sceneTarget.
|
// Draw scene to sceneTarget.
|
||||||
graphics.SetRenderTarget(sceneTarget);
|
graphics.SetRenderTarget(sceneTarget);
|
||||||
@ -51,15 +51,6 @@ namespace SemiColinGames {
|
|||||||
Vector2 spriteCenter = new Vector2(playerTexture.Width / 2, playerTexture.Height / 2);
|
Vector2 spriteCenter = new Vector2(playerTexture.Width / 2, playerTexture.Height / 2);
|
||||||
Vector2 drawPos = Vector2.Floor(Vector2.Subtract(world.Player.Position, spriteCenter));
|
Vector2 drawPos = Vector2.Floor(Vector2.Subtract(world.Player.Position, spriteCenter));
|
||||||
spriteBatch.Draw(playerTexture, drawPos, Color.White);
|
spriteBatch.Draw(playerTexture, drawPos, Color.White);
|
||||||
|
|
||||||
// Draw shots.
|
|
||||||
foreach (ShmupWorld.Shot s in world.Shots) {
|
|
||||||
Texture2D texture = s.Texture.Get;
|
|
||||||
Vector2 center = new Vector2(texture.Width / 2, texture.Height / 2);
|
|
||||||
spriteBatch.Draw(texture, Vector2.Floor(Vector2.Subtract(s.Position, center)), Color.White);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finish drawing sprites.
|
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
|
|
||||||
// Get ready to draw sceneTarget to screen.
|
// Get ready to draw sceneTarget to screen.
|
||||||
|
@ -8,34 +8,16 @@ namespace SemiColinGames {
|
|||||||
public class ShmupPlayer {
|
public class ShmupPlayer {
|
||||||
public TextureRef Texture = Textures.Yellow2;
|
public TextureRef Texture = Textures.Yellow2;
|
||||||
// Center of player sprite.
|
// Center of player sprite.
|
||||||
public Vector2 Position = new Vector2(48, 1080 / 8);
|
public Vector2 Position = new Vector2(32, 1080 / 8);
|
||||||
public Vector2 HalfSize = new Vector2(16, 10);
|
public Vector2 HalfSize = new Vector2(16, 10);
|
||||||
public float Speed = 150f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Shot {
|
|
||||||
public TextureRef Texture = Textures.Projectile1;
|
|
||||||
public Vector2 Position;
|
|
||||||
public Vector2 HalfSize = new Vector2(11, 8);
|
|
||||||
public Vector2 Velocity;
|
|
||||||
public Shot(Vector2 position, Vector2 velocity) {
|
|
||||||
Position = position;
|
|
||||||
Velocity = velocity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly Point Size;
|
public readonly Point Size;
|
||||||
public readonly ShmupPlayer Player;
|
public readonly ShmupPlayer Player;
|
||||||
public readonly ProfilingList<Shot> Shots;
|
|
||||||
|
|
||||||
public ShmupWorld() {
|
public ShmupWorld() {
|
||||||
Size = new Point(1920 / 4, 1080 / 4);
|
Size = new Point(1920 / 4, 1080 / 4);
|
||||||
Player = new ShmupPlayer();
|
Player = new ShmupPlayer();
|
||||||
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() {
|
||||||
@ -47,22 +29,14 @@ namespace SemiColinGames {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Update(float modelTime, History<Input> input) {
|
public void Update(float modelTime, History<Input> input) {
|
||||||
Vector2 motion = Vector2.Multiply(input[0].Motion, modelTime * Player.Speed);
|
float speed = 150f;
|
||||||
|
Vector2 motion = Vector2.Multiply(input[0].Motion, modelTime * 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, 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, Size.Y - Player.HalfSize.Y);
|
Player.Position.Y = Math.Min(Player.Position.Y, Size.Y - Player.HalfSize.Y);
|
||||||
|
|
||||||
foreach (Shot shot in Shots) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shots.RemoveAll(shot => shot.Position.X > Size.X);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user