40 lines
No EOL
1.1 KiB
C#
40 lines
No EOL
1.1 KiB
C#
using SDL2;
|
|
|
|
using KumiScript.Renderer;
|
|
using KumiScript.Gearbox;
|
|
|
|
public class EngineWindow
|
|
{
|
|
internal ushort width {get; private set;}
|
|
internal ushort height {get; private set;}
|
|
internal string title {get; private set;}
|
|
|
|
public EngineWindow(ushort horizontalResolution, ushort verticalResolution, string windowTitle)
|
|
{
|
|
width = horizontalResolution;
|
|
height = verticalResolution;
|
|
title = windowTitle;
|
|
|
|
if (SDL.SDL_Init(SDL.SDL_INIT_VIDEO) < 0)
|
|
throw new Exception("SDL2 Video init failed!");
|
|
|
|
if (SDL_image.IMG_Init(SDL_image.IMG_InitFlags.IMG_INIT_PNG) < 0)
|
|
throw new Exception("SDL2 Image init failed!");
|
|
|
|
if (SDL_ttf.TTF_Init() < 0)
|
|
throw new Exception("SDL2 ttf init failed!");
|
|
}
|
|
|
|
public void show()
|
|
{
|
|
SDLWindow window = new SDLWindow(width, height, title);
|
|
SDLRenderer renderer = new SDLRenderer(window);
|
|
GameState state = new GameStateMain(renderer);
|
|
while (!state.IsQuitting())
|
|
{
|
|
state = state.UpdateState();
|
|
}
|
|
renderer.Dispose();
|
|
window.Dispose();
|
|
}
|
|
} |