Add TreeScene & TreeWorld.

This commit is contained in:
Colin McMillen 2020-07-15 15:01:28 -04:00
parent 5a9b98455f
commit 56bc1abe06
5 changed files with 46 additions and 3 deletions

View File

@ -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; }
} }
} }

View File

@ -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>

View File

@ -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
View 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
View 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) {
}
}
}