NouVeL/ADVect/ADVect.cpp

60 lines
1.4 KiB
C++
Raw Normal View History

2022-05-09 01:50:09 -04:00
#include "ADVect.h"
#include "Bindings.h"
#include "Graphics.h"
#include <iostream>
#include <Environment.h>
namespace ADVect {
Game::Game(std::string name, std::vector<NVL::Parse::Scene>& scenes) : m_name(name), m_running(false), m_scenes(scenes) {
if (SDL_Init(SDL_INIT_EVERYTHING)) {
std::cerr << "SDL shit itself : " << SDL_GetError() << std::endl;
}
m_window = SDL_CreateWindow(m_name.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_SHOWN);
m_surface = SDL_GetWindowSurface(m_window);
ADVect::Graphics::Init();
}
Game::~Game() {
SDL_DestroyWindow(m_window);
SDL_Quit();
}
void Game::Render() {
SDL_FillRect(m_surface, nullptr, SDL_MapRGBA(m_surface->format, 0, 0, 0, 255));
const std::string text = "test!!! :DD";
ADVect::Graphics::RenderString(text, m_surface);
SDL_UpdateWindowSurface(m_window);
SDL_Delay(10);
}
void Game::Run() {
m_running = true;
while (m_running) {
for (SDL_Event event; SDL_PollEvent(&event);) {
switch (event.type) {
case SDL_QUIT:
m_running = false;
break;
}
}
Render();
}
}
}
int main(int argc, char* argv[]) {
ADVect::bind_NVL();
const std::string PJ_DIR = "E:\\Archive\\Projects\\NouVeL\\NVL\\";
std::vector<NVL::Parse::Scene> SCENES = NVL::Parse::ParseFile(PJ_DIR + "test.nvl");
ADVect::Game game("Test", SCENES);
game.Run();
return 0;
}