added absolutely broken cpp code after painfull debugging session
This commit is contained in:
0
src/core/.gitkeep
Normal file
0
src/core/.gitkeep
Normal file
41
src/core/Engine.cpp
Normal file
41
src/core/Engine.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "Engine.h"
|
||||
#include <iostream>
|
||||
#include <SDL3/SDL.h>
|
||||
#include "WindowManager.h"
|
||||
|
||||
bool running = true;
|
||||
WindowManager wm;
|
||||
|
||||
bool Engine::Init() {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
std::cerr << "SDL_Init failed: " << SDL_GetError() << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
wm = new WindowManager();
|
||||
|
||||
if (!wm.InitWindow("ShadowCrest", 800, 600)) {
|
||||
std::cerr << "SDL_Init failed: " << SDL_GetError() << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Engine::Run() {
|
||||
SDL_Event event;
|
||||
while (running) {
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_EVENT_QUIT) {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Delay(16);
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::Shutdown() {
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
}
|
||||
8
src/core/Engine.h
Normal file
8
src/core/Engine.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
class Engine {
|
||||
public:
|
||||
bool Init();
|
||||
void Run();
|
||||
void Shutdown();
|
||||
};
|
||||
0
src/core/Logger.cpp
Normal file
0
src/core/Logger.cpp
Normal file
0
src/core/Logger.h
Normal file
0
src/core/Logger.h
Normal file
12
src/core/WindowManager.cpp
Normal file
12
src/core/WindowManager.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "WindowManager.h"
|
||||
#include <iostream>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <Windows.h>
|
||||
|
||||
SDL_Window* window = nullptr;
|
||||
|
||||
bool WindowManager::InitWindow(char *name, int width, int height) {
|
||||
// creates window
|
||||
window = SDL_CreateWindow(name, width, height, SDL_WINDOW_RESIZABLE);
|
||||
return window != nullptr;
|
||||
}
|
||||
10
src/core/WindowManager.h
Normal file
10
src/core/WindowManager.h
Normal file
@ -0,0 +1,10 @@
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
#pragma once
|
||||
|
||||
class WindowManager {
|
||||
public:
|
||||
bool InitWindow(char *name, int width, int height);
|
||||
void Draw();
|
||||
};
|
||||
Reference in New Issue
Block a user