Basic rendering with camera controls are functional.

This commit is contained in:
2020-06-23 20:07:12 -05:00
parent 1c4ca6c97b
commit 6a19d1f5c7
58 changed files with 8386 additions and 2224 deletions

View File

@@ -25,11 +25,11 @@ namespace SlatedGameToolkit.Tools.CommandSystem
string[] args = new string[splitMessage.Length - 1];
Array.Copy(splitMessage, 1, args, 0, splitMessage.Length - 1);
if (!invocable.Execute(interactable, args)) {
interactable.Tell(string.Format("The command \"{0}\" was recognized, but arguments were incorrect. Please refer to Please type \"help {0}\" for more information.", invocation));
interactable.Tell(string.Format("The command \"{0}\" arguments were incorrect. Please refer to Please type \"help {0}\" for more information.", invocation));
}
return;
}
interactable.Tell(string.Format("The input \"{0}\" was not understood. Please type \"help\" for more information.", invocation));
interactable.Tell(string.Format("The command \"{0}\" was not understood. Please type \"help\" for more information.", invocation));
}
}
}

View File

@@ -21,7 +21,7 @@ namespace SlatedGameToolkit.Tools.Commands
if (invocable == null) interactable.Tell("Unable to find command {0}. Please type \"help\" for more a list of commands.");
StringBuilder builder = new StringBuilder();
builder.AppendJoin(", ", invocable.GetInvokers());
interactable.Tell("Possible aliases: " + builder.ToString() + ": ");
interactable.Tell("Possible aliases: " + builder.ToString());
interactable.Tell("Description: " + invocable.getDescription());
interactable.Tell("Usage: " + invocable.getUsage(args.Length > 0 ? args[0] : null));
} else {

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -1,12 +1,13 @@
using System;
using System.Drawing;
using System.Numerics;
using SlatedGameToolkit.Framework.Exceptions;
using SlatedGameToolkit.Framework.Graphics.Programs;
using SDL2;
using SlatedGameToolkit.Framework.Graphics.Render;
using SlatedGameToolkit.Framework.Graphics.Shaders;
using SlatedGameToolkit.Framework.Graphics.Render.Programs;
using SlatedGameToolkit.Framework.Graphics.Textures;
using SlatedGameToolkit.Framework.Graphics.Window;
using SlatedGameToolkit.Framework.Input;
using SlatedGameToolkit.Framework.Input.Devices;
using SlatedGameToolkit.Framework.Loader;
using SlatedGameToolkit.Framework.StateSystem;
using SlatedGameToolkit.Framework.StateSystem.States;
@@ -16,9 +17,8 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
public class MainState : IState
{
private WindowContext window;
private GLShaderProgram program;
private Camera2D camera;
private Renderer renderer;
private MeshBatch renderer;
private Texture texture;
private Sprite2D sprite;
@@ -36,10 +36,9 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
public void Deinitialize()
{
window.Dispose();
program.Dispose();
texture.Dispose();
renderer.Dispose();
window.Dispose();
}
public string getName()
@@ -50,25 +49,35 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
public void Initialize(StateManager manager)
{
window = new WindowContext("SlatedGameToolkit Playground");
camera = new Camera2D();
camera.Width = window.WindowBoundaries.Width;
camera.Height = window.WindowBoundaries.Height;
camera.Position = new Vector2(camera.Width / 2, camera.Height / 2);
program = new GLShaderProgram(new NormalVertexShader(), new NormalFragmentShader());
renderer = new Renderer(camera, program);
texture = new TextureLoader("Resources/Playground/yhdnbgnc.png").Load();
camera = new Camera2D(2, 2);
renderer = new MeshBatch(camera);
texture = CommonLoaders.LoadTexture("Resources/Playground/yhdnbgnc.png", null);
sprite = new Sprite2D(texture, Color.White);
sprite.X = -0.5f;
sprite.Y = -0.5f;
}
public void Render(double delta)
{
OpenGLErrorException.CheckGLErrorStatus();
renderer.Queue(sprite, Matrix4x4.Identity);
renderer.Render();
renderer.Begin(Matrix4x4.Identity);
renderer.Draw(sprite);
renderer.End();
}
public void Update(double delta)
{
if (Keyboard.IsKeyPressed(SDL.SDL_Keycode.SDLK_DOWN)) {
camera.Position += new Vector2(0, (float)(-0.5f * delta));
}
if (Keyboard.IsKeyPressed(SDL.SDL_Keycode.SDLK_UP)) {
camera.Position += new Vector2(0, (float)(0.5f * delta));
}
if (Keyboard.IsKeyPressed(SDL.SDL_Keycode.SDLK_LEFT)) {
camera.Position += new Vector2((float)(-0.5f * delta), 0);
}
if (Keyboard.IsKeyPressed(SDL.SDL_Keycode.SDLK_RIGHT)) {
camera.Position += new Vector2((float)(0.5f * delta), 0);
}
}
}
}