public MultiThreadComponentGame() { PerfMon.InitializeStarted(); this.graphics = new GraphicsDeviceManager(this); this.Content.RootDirectory = "Content"; this.IsMouseVisible = true; this.IsFixedTimeStep = false; }
public ObjectOrientedGame() { PerfMon.InitializeStarted(); this.graphics = new GraphicsDeviceManager(this); this.Content.RootDirectory = "Content"; this.IsMouseVisible = true; this.IsFixedTimeStep = false; var random = new Random(); for (int i = 0; i < DotCount; i++) { var dot = new Dot(random); s_GameObjects.Add(dot); } for (int i = 0; i < BubbleCount; i++) { var bubble = new Bubble(random); s_GameObjects.Add(bubble); } }
public CompositionGame() { PerfMon.InitializeStarted(); this.graphics = new GraphicsDeviceManager(this); this.Content.RootDirectory = "Content"; this.IsMouseVisible = true; this.IsFixedTimeStep = false; this.texture2Ds = new Texture2D[2]; var worldBoundsGameObject = new GameObject("World Bounds"); var worldBoundsComponent = new WorldBoundsComponent(this.graphics); worldBoundsGameObject.AddComponent(worldBoundsComponent); s_GameObjects.Add(worldBoundsGameObject); var random = new Random(); for (var i = 0; i < BubbleCount; i++) { var gameObject = new GameObject($"Bubble #{i}"); var positionComponent = new PositionComponent(random); gameObject.AddComponent(positionComponent); var velocityComponent = new VelocityComponent(random, Bubble.MinVelocity, Bubble.MaxVelocity); gameObject.AddComponent(velocityComponent); var velocityModifier = (float)random.NextDouble() * (Bubble.MaxModifier - Bubble.MinModifier) + Bubble.MinModifier; var spriteComponent = new SpriteComponent(); spriteComponent.ColorR = MathB.Select(0, byte.MaxValue, velocityModifier < 0.0f); spriteComponent.ColorG = MathB.Select(0, byte.MaxValue, velocityModifier >= 0.0f); spriteComponent.ColorB = byte.MinValue; var scaleMax = MathF.Select(Bubble.MinModifier, Bubble.MaxModifier, velocityModifier >= 0.0f); spriteComponent.Alpha = (byte)(int)(128 * (velocityModifier / scaleMax)); spriteComponent.Index = Sprites.Bubble; gameObject.AddComponent(spriteComponent); var velocityModifierComponent = new VelocityModifierComponent(); velocityModifierComponent.VelocityModifier = velocityModifier; gameObject.AddComponent(velocityModifierComponent); var sizeComponent = new SizeComponent(); sizeComponent.Size = 64; gameObject.AddComponent(sizeComponent); s_GameObjects.Add(gameObject); } for (int i = 0; i < DotCount; i++) { var gameObject = new GameObject($"Dot #{i}"); var positionComponent = new PositionComponent(random); gameObject.AddComponent(positionComponent); var velocityComponent = new VelocityComponent(random, Dot.MinVelocity, Dot.MaxVelocity); gameObject.AddComponent(velocityComponent); var spriteComponent = new SpriteComponent(); var colors = new byte[3]; random.NextBytes(colors); spriteComponent.ColorR = colors[0]; spriteComponent.ColorG = colors[1]; spriteComponent.ColorB = colors[2]; spriteComponent.Alpha = byte.MaxValue; spriteComponent.Index = Sprites.Dot; gameObject.AddComponent(spriteComponent); var modifyVelocityComponent = new ModifyVelocityComponent(); gameObject.AddComponent(modifyVelocityComponent); s_GameObjects.Add(gameObject); } }