Compare commits
3 Commits
9b25a8a6e0
...
56bc1abe06
Author | SHA1 | Date | |
---|---|---|---|
56bc1abe06 | |||
5a9b98455f | |||
0f6424e4a1 |
@ -3,6 +3,5 @@
|
|||||||
namespace SemiColinGames {
|
namespace SemiColinGames {
|
||||||
public interface IWorld : IDisposable {
|
public interface IWorld : IDisposable {
|
||||||
void Update(float modelTime, History<Input> input);
|
void Update(float modelTime, History<Input> input);
|
||||||
Camera Camera { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,20 +7,20 @@ namespace SemiColinGames {
|
|||||||
public sealed class Scene : IScene {
|
public sealed class Scene : IScene {
|
||||||
const float DESIRED_ASPECT_RATIO = 1920.0f / 1080.0f;
|
const float DESIRED_ASPECT_RATIO = 1920.0f / 1080.0f;
|
||||||
|
|
||||||
Color backgroundColor = Color.CornflowerBlue;
|
private readonly Color backgroundColor = Color.CornflowerBlue;
|
||||||
|
|
||||||
readonly GraphicsDevice graphics;
|
private readonly GraphicsDevice graphics;
|
||||||
readonly Camera camera;
|
private readonly Camera camera;
|
||||||
|
|
||||||
readonly RenderTarget2D sceneTarget;
|
private readonly RenderTarget2D sceneTarget;
|
||||||
readonly BasicEffect basicEffect;
|
private readonly BasicEffect basicEffect;
|
||||||
readonly SpriteBatch spriteBatch;
|
private readonly SpriteBatch spriteBatch;
|
||||||
readonly SoundEffectInstance music;
|
private readonly SoundEffectInstance music;
|
||||||
|
|
||||||
// Draw() needs to be called without IsRunningSlowly this many times before we actually
|
// Draw() needs to be called without IsRunningSlowly this many times before we actually
|
||||||
// attempt to draw the scene. This is a workaround for the fact that otherwise the first few
|
// attempt to draw the scene. This is a workaround for the fact that otherwise the first few
|
||||||
// frames can be really slow to draw.
|
// frames can be really slow to draw.
|
||||||
int framesToSuppress = 2;
|
private int framesToSuppress = 2;
|
||||||
|
|
||||||
public Scene(GraphicsDevice graphics, Camera camera) {
|
public Scene(GraphicsDevice graphics, Camera camera) {
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
<Compile Include="$(MSBuildThisFileDirectory)Scene.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Scene.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)SneakGame.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)SneakGame.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Timer.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Timer.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)TreeScene.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)TreeWorld.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)World.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)World.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -64,9 +64,11 @@ namespace SemiColinGames {
|
|||||||
|
|
||||||
private void LoadLevel() {
|
private void LoadLevel() {
|
||||||
world?.Dispose();
|
world?.Dispose();
|
||||||
world = new World(GraphicsDevice, Content.LoadString("levels/demo.json"));
|
// world = new World(GraphicsDevice, Content.LoadString("levels/demo.json"));
|
||||||
|
world = new TreeWorld();
|
||||||
scene?.Dispose();
|
scene?.Dispose();
|
||||||
scene = new Scene(GraphicsDevice, world.Camera);
|
// scene = new Scene(GraphicsDevice, ((World) world).Camera);
|
||||||
|
scene = new TreeScene(GraphicsDevice);
|
||||||
|
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
GC.WaitForPendingFinalizers();
|
GC.WaitForPendingFinalizers();
|
||||||
|
25
Shared/TreeScene.cs
Normal file
25
Shared/TreeScene.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Audio;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace SemiColinGames {
|
||||||
|
public sealed class TreeScene : IScene {
|
||||||
|
|
||||||
|
readonly Color backgroundColor = Color.SkyBlue;
|
||||||
|
|
||||||
|
readonly GraphicsDevice graphics;
|
||||||
|
|
||||||
|
public TreeScene(GraphicsDevice graphics) {
|
||||||
|
this.graphics = graphics;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose() {
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Draw(bool isRunningSlowly, IWorld iworld, bool paused) {
|
||||||
|
graphics.Clear(backgroundColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
Shared/TreeWorld.cs
Normal file
15
Shared/TreeWorld.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SemiColinGames {
|
||||||
|
public sealed class TreeWorld : IWorld {
|
||||||
|
public void Dispose() {
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(float modelTime, History<Input> input) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,7 @@ namespace SemiColinGames {
|
|||||||
public readonly int Width;
|
public readonly int Width;
|
||||||
public readonly int Height;
|
public readonly int Height;
|
||||||
|
|
||||||
|
// TODO: it seems weird that World takes in a GraphicsDevice. Remove it?
|
||||||
public World(GraphicsDevice graphics, string json) {
|
public World(GraphicsDevice graphics, string json) {
|
||||||
Camera = new Camera();
|
Camera = new Camera();
|
||||||
LinesOfSight = new LinesOfSight(graphics);
|
LinesOfSight = new LinesOfSight(graphics);
|
||||||
|
Loading…
Reference in New Issue
Block a user