stuff
This commit is contained in:
parent
f199ab47dc
commit
a7f966376d
4 changed files with 46 additions and 14 deletions
12
NetClassic/InputHandler.cs
Normal file
12
NetClassic/InputHandler.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NetClassic
|
||||||
|
{
|
||||||
|
public class InputHandler
|
||||||
|
{
|
||||||
|
public static void HandleKeyboardInputs(object e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,7 +9,7 @@ namespace NetClassic
|
||||||
{
|
{
|
||||||
LoggerName = loggerName;
|
LoggerName = loggerName;
|
||||||
}
|
}
|
||||||
public void logInfo(string logData)
|
public void LogInfo(string logData)
|
||||||
{
|
{
|
||||||
ConsoleColor old = Console.ForegroundColor;
|
ConsoleColor old = Console.ForegroundColor;
|
||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
Console.ForegroundColor = ConsoleColor.Gray;
|
||||||
|
@ -17,7 +17,7 @@ namespace NetClassic
|
||||||
Console.ForegroundColor = old;
|
Console.ForegroundColor = old;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logWarning(string logData)
|
public void LogWarning(string logData)
|
||||||
{
|
{
|
||||||
ConsoleColor old = Console.ForegroundColor;
|
ConsoleColor old = Console.ForegroundColor;
|
||||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
|
@ -25,7 +25,7 @@ namespace NetClassic
|
||||||
Console.ForegroundColor = old;
|
Console.ForegroundColor = old;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logError(string logData)
|
public void LogError(string logData)
|
||||||
{
|
{
|
||||||
ConsoleColor old = Console.ForegroundColor;
|
ConsoleColor old = Console.ForegroundColor;
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
@ -33,7 +33,7 @@ namespace NetClassic
|
||||||
Console.ForegroundColor = old;
|
Console.ForegroundColor = old;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logFatal(string logData)
|
public void LogFatal(string logData)
|
||||||
{
|
{
|
||||||
ConsoleColor old = Console.ForegroundColor;
|
ConsoleColor old = Console.ForegroundColor;
|
||||||
Console.ForegroundColor = ConsoleColor.DarkRed;
|
Console.ForegroundColor = ConsoleColor.DarkRed;
|
||||||
|
|
0
NetClassic/Player.cs
Normal file
0
NetClassic/Player.cs
Normal file
|
@ -1,4 +1,4 @@
|
||||||
using SDL2;
|
using static SDL2.SDL;
|
||||||
using System;
|
using System;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
|
||||||
|
@ -8,24 +8,44 @@ namespace NetClassic
|
||||||
{
|
{
|
||||||
static bool gameRunning = true;
|
static bool gameRunning = true;
|
||||||
static Logger logger = new Logger("NetClassic.Program");
|
static Logger logger = new Logger("NetClassic.Program");
|
||||||
|
static long frameTime = 0;
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
logger.logInfo("Initializing SDL Video and Events...");
|
logger.LogInfo($"NetClassic vPreDev on {Environment.OSVersion.VersionString}");
|
||||||
SDL.SDL_Init(SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_EVENTS);
|
logger.LogInfo("Initializing SDL Video and Events...");
|
||||||
logger.logInfo("Creating Window...");
|
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
|
||||||
IntPtr window = SDL.SDL_CreateWindow("NetClassic", SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED, 1024, 768, SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL);
|
logger.LogInfo("Creating Window...");
|
||||||
logger.logInfo("Creating Renderer...");
|
IntPtr window = SDL_CreateWindow("NetClassic", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 854, 480, SDL_WindowFlags.SDL_WINDOW_OPENGL);
|
||||||
IntPtr renderer = SDL.SDL_CreateRenderer(window, -1, SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED);
|
logger.LogInfo("Creating Renderer...");
|
||||||
|
IntPtr renderer = SDL_CreateRenderer(window, -1, SDL_RendererFlags.SDL_RENDERER_ACCELERATED);
|
||||||
while(gameRunning)
|
while(gameRunning)
|
||||||
{
|
{
|
||||||
SDL.SDL_Event e;
|
// log last frame Timers
|
||||||
if (SDL.SDL_WaitEvent(out e) != 0)
|
if (frameTime != 0)
|
||||||
{
|
{
|
||||||
if (e.type == SDL.SDL_EventType.SDL_QUIT)
|
logger.LogInfo($"Last frame took {DateTimeOffset.Now.ToUnixTimeMilliseconds() - frameTime}ms");
|
||||||
|
}
|
||||||
|
frameTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
|
|
||||||
|
// handle input
|
||||||
|
SDL_Event e;
|
||||||
|
if (SDL_WaitEvent(out e) != 0)
|
||||||
|
{
|
||||||
|
if (e.type == SDL_EventType.SDL_QUIT)
|
||||||
{
|
{
|
||||||
gameRunning = false;
|
gameRunning = false;
|
||||||
}
|
}
|
||||||
}
|
else if (e.type == SDL_EventType.SDL_KEYDOWN)
|
||||||
|
{
|
||||||
|
InputHandler.HandleKeyboardInputs(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw
|
||||||
|
SDL_SetRenderDrawColor(renderer, 255, 0, 255, 255);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue