Builds and runs on windows
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ end)
|
|||||||
|
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
generator, msg = loadfile("rsc/roguegenerator.lua")
|
generator, msg = loadfile("../rsc/roguegenerator.lua")
|
||||||
|
|
||||||
if generator == nil then
|
if generator == nil then
|
||||||
print("error: ", msg)
|
print("error: ", msg)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 540 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
+19
-1
@@ -22,6 +22,7 @@
|
|||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
@@ -40,6 +41,9 @@ void Application::Init(int argc, char* argv[]) {
|
|||||||
msg << "Failed to create the window: " << SDL_GetError();
|
msg << "Failed to create the window: " << SDL_GetError();
|
||||||
throw(std::runtime_error(msg.str()));
|
throw(std::runtime_error(msg.str()));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
std::cout << "Created the window" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
//create and check the renderer
|
//create and check the renderer
|
||||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||||
@@ -49,20 +53,28 @@ void Application::Init(int argc, char* argv[]) {
|
|||||||
msg << "Failed to create the renderer: " << SDL_GetError();
|
msg << "Failed to create the renderer: " << SDL_GetError();
|
||||||
throw(std::runtime_error(msg.str()));
|
throw(std::runtime_error(msg.str()));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
std::cout << "Created the renderer" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
//screen scaling
|
//screen scaling
|
||||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best");
|
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best");
|
||||||
SDL_RenderSetLogicalSize(renderer, 800, 600);
|
SDL_RenderSetLogicalSize(renderer, screenWidth, screenHeight);
|
||||||
|
|
||||||
//set the hook for the renderer
|
//set the hook for the renderer
|
||||||
BaseScene::SetRenderer(renderer);
|
BaseScene::SetRenderer(renderer);
|
||||||
|
|
||||||
|
std::cout << "Initialized screen scaling" << std::endl;
|
||||||
|
|
||||||
//setting up SDL2_ttf
|
//setting up SDL2_ttf
|
||||||
if (TTF_Init()) {
|
if (TTF_Init()) {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Failed to initialize SDL2_ttf: " << SDL_GetError();
|
msg << "Failed to initialize SDL2_ttf: " << SDL_GetError();
|
||||||
throw(std::runtime_error(msg.str()));
|
throw(std::runtime_error(msg.str()));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
std::cout << "Initialized SDL2_ttf" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
//setup lua
|
//setup lua
|
||||||
lua = luaL_newstate();
|
lua = luaL_newstate();
|
||||||
@@ -71,8 +83,13 @@ void Application::Init(int argc, char* argv[]) {
|
|||||||
msg << "Failed to create the lua state";
|
msg << "Failed to create the lua state";
|
||||||
throw(std::runtime_error(msg.str()));
|
throw(std::runtime_error(msg.str()));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
std::cout << "Initialized lua" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
luaL_openlibs(lua);
|
luaL_openlibs(lua);
|
||||||
|
|
||||||
|
std::cout << "Initialization sucessful" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::Proc() {
|
void Application::Proc() {
|
||||||
@@ -124,6 +141,7 @@ void Application::Proc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Application::Quit() {
|
void Application::Quit() {
|
||||||
|
std::cout << "Closing the APIs" << std::endl;
|
||||||
lua_close(lua);
|
lua_close(lua);
|
||||||
TTF_Quit();
|
TTF_Quit();
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ ExampleScene::ExampleScene(lua_State* L) {
|
|||||||
lua = L;
|
lua = L;
|
||||||
|
|
||||||
//TODO: non-hardcoded source
|
//TODO: non-hardcoded source
|
||||||
tileSheet.Load(GetRenderer(), "./rsc/terrain.bmp", 32, 32);
|
tileSheet.Load(GetRenderer(), "../rsc/terrain.png", 32, 32);
|
||||||
|
|
||||||
//set the pager's hook
|
//set the pager's hook
|
||||||
regionPager.SetLuaState(lua);
|
regionPager.SetLuaState(lua);
|
||||||
|
|
||||||
//load the file as a chunk
|
//load the file as a chunk
|
||||||
luaL_loadfile(lua, "./rsc/startup.lua");
|
luaL_loadfile(lua, "../rsc/startup.lua");
|
||||||
|
|
||||||
//push the pager as an arg
|
//push the pager as an arg
|
||||||
lua_pushlightuserdata(lua, static_cast<void*>(®ionPager));
|
lua_pushlightuserdata(lua, static_cast<void*>(®ionPager));
|
||||||
@@ -49,8 +49,10 @@ ExampleScene::ExampleScene(lua_State* L) {
|
|||||||
camera.scale = 0.25;
|
camera.scale = 0.25;
|
||||||
|
|
||||||
//DEBUG: testing buttons
|
//DEBUG: testing buttons
|
||||||
buttonBG.Load(GetRenderer(), "./rsc/button.png");
|
buttonBG.Load(GetRenderer(), "../rsc/button.png");
|
||||||
font = TTF_OpenFont("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 12);
|
//Ubuntu: "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
|
||||||
|
|
||||||
|
font = TTF_OpenFont("C:\\Windows\\Fonts\\Arial.ttf", 12);
|
||||||
if (!font) {
|
if (!font) {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Failed to load a font: " << SDL_GetError();
|
msg << "Failed to load a font: " << SDL_GetError();
|
||||||
@@ -70,6 +72,9 @@ ExampleScene::ExampleScene(lua_State* L) {
|
|||||||
|
|
||||||
//
|
//
|
||||||
blankImage.Create(GetRenderer(), 256, 256);
|
blankImage.Create(GetRenderer(), 256, 256);
|
||||||
|
|
||||||
|
//
|
||||||
|
std::cout << "Scene setup finished" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExampleScene::~ExampleScene() {
|
ExampleScene::~ExampleScene() {
|
||||||
|
|||||||
Reference in New Issue
Block a user