KumiScript/Game.cs

40 lines
1.1 KiB
C#
Raw Normal View History

2024-01-26 05:37:51 +00:00
using SDL2;
using KumiScript.Renderer;
using KumiScript.Gearbox;
2024-01-26 05:37:51 +00:00
public class EngineWindow
{
internal ushort width {get; private set;}
internal ushort height {get; private set;}
internal string title {get; private set;}
2024-01-26 05:37:51 +00:00
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!");
2024-01-26 05:37:51 +00:00
}
public void show()
{
SDLWindow window = new SDLWindow(width, height, title);
SDLRenderer renderer = new SDLRenderer(window);
GameState state = new GameStateMain(renderer);
while (!state.IsQuitting())
2024-01-26 05:37:51 +00:00
{
state = state.UpdateState();
2024-01-26 05:37:51 +00:00
}
renderer.Dispose();
window.Dispose();
2024-01-26 05:37:51 +00:00
}
}