Switched to LuaJIT and made some other misc. changes
This commit is contained in:
parent
02403b142a
commit
6e7bb8397f
14 changed files with 82 additions and 34 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -364,3 +364,4 @@ FodyWeavers.xsd
|
||||||
/Resources/weapons/.bubblegun.xml.swp
|
/Resources/weapons/.bubblegun.xml.swp
|
||||||
*.swp
|
*.swp
|
||||||
/Resources/scenes/.debugScene.xml.swp
|
/Resources/scenes/.debugScene.xml.swp
|
||||||
|
compile_commands.json
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,20 @@ endif()
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
SET(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
SET(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
||||||
|
#SET(SOL_LUAJIT 1)
|
||||||
|
|
||||||
SET(TRACY_ENABLE 1)
|
SET(TRACY_ENABLE 1)
|
||||||
SET(TRACY_ON_DEMAND 1)
|
SET(TRACY_ON_DEMAND 1)
|
||||||
SET(TRACY_ONLY_LOCALHOST 1)
|
SET(TRACY_ONLY_LOCALHOST 1)
|
||||||
|
|
||||||
|
SET(FT_DISABLE_BROTLI 1)
|
||||||
|
SET(FT_DISABLE_BZIP2 1)
|
||||||
|
SET(FT_DISABLE_HARFBUZZ 1)
|
||||||
|
SET(FT_DISABLE_PNG 1)
|
||||||
|
SET(FT_DISABLE_ZLIB 1)
|
||||||
|
|
||||||
|
option(GLM_ENABLE_FAST_MATH OFF)
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
tracy
|
tracy
|
||||||
GIT_REPOSITORY https://github.com/wolfpld/tracy.git
|
GIT_REPOSITORY https://github.com/wolfpld/tracy.git
|
||||||
|
|
@ -25,7 +34,34 @@ FetchContent_Declare(
|
||||||
GIT_PROGRESS TRUE
|
GIT_PROGRESS TRUE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
tinyxml2
|
||||||
|
GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git
|
||||||
|
GIT_TAG 10.0.0
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
GIT_PROGRESS TRUE
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
sol2
|
||||||
|
GIT_REPOSITORY https://github.com/ThePhD/sol2.git
|
||||||
|
GIT_TAG v3.3.1
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
GIT_PROGRESS TRUE
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
freetype
|
||||||
|
GIT_REPOSITORY https://github.com/freetype/freetype.git
|
||||||
|
GIT_TAG VER-2-13-3
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
GIT_PROGRESS TRUE
|
||||||
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(tracy)
|
FetchContent_MakeAvailable(tracy)
|
||||||
|
FetchContent_MakeAvailable(tinyxml2)
|
||||||
|
FetchContent_MakeAvailable(sol2)
|
||||||
|
FetchContent_MakeAvailable(freetype)
|
||||||
|
|
||||||
project ("YuppleMayham")
|
project ("YuppleMayham")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ moveLeft = true
|
||||||
function watchPosition(actor, pos)
|
function watchPosition(actor, pos)
|
||||||
local y = pos.y - actor.position.y
|
local y = pos.y - actor.position.y
|
||||||
local x = pos.x - actor.position.x
|
local x = pos.x - actor.position.x
|
||||||
local rotation = math.atan(y, x)
|
local rotation = math.atan2(y, x)
|
||||||
actor.rotation = math.deg(rotation)
|
actor.rotation = math.deg(rotation)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,30 +2,31 @@
|
||||||
# project specific logic here.
|
# project specific logic here.
|
||||||
#
|
#
|
||||||
|
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 2.30.2 REQUIRED)
|
||||||
find_package(SDL2_IMAGE REQUIRED)
|
find_package(SDL2_IMAGE 2.8.2 REQUIRED)
|
||||||
|
#find_package(luajit CONFIG REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/YuppleMayham/include")
|
|
||||||
include_directories(SYSTEM "c:/sdks/glad/include")
|
include_directories(SYSTEM "c:/sdks/glad/include")
|
||||||
include_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/include")
|
#include_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/include")
|
||||||
include_directories(SYSTEM "c:/sdks/glm")
|
include_directories(SYSTEM "c:/sdks/glm")
|
||||||
include_directories(SYSTEM "C:/sdks/sol2-3.3.0/single/single/include")
|
#include_directories(SYSTEM "C:/sdks/sol2-3.3.0/single/single/include")
|
||||||
include_directories(SYSTEM "c:/sdks/lua-5.4.6/include")
|
#include_directories(SYSTEM "c:/sdks/lua-5.4.6/include")
|
||||||
include_directories(SYSTEM "C:/sdks/freetype-2.13.2/include")
|
#include_directories(SYSTEM "C:/sdks/freetype-2.13.2/include")
|
||||||
link_directories(SYSTEM "C:/sdks/freetype-2.13.2/objs")
|
#link_directories(SYSTEM "C:/sdks/freetype-2.13.2/objs")
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
#if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/lib")
|
# link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/lib")
|
||||||
else()
|
#else()
|
||||||
link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/release/lib")
|
# link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/release/lib")
|
||||||
endif()
|
#endif()
|
||||||
link_directories(SYSTEM "c:/sdks/lua-5.4.6/lib")
|
#link_directories(SYSTEM "c:/sdks/lua-5.4.6/lib")
|
||||||
|
|
||||||
include_directories("${PROJECT_SOURCE_DIR}/YuppleMayham/include")
|
#include_directories("${PROJECT_SOURCE_DIR}/YuppleMayham/include")
|
||||||
|
|
||||||
# Add source to this project's executable.
|
# Add source to this project's executable.
|
||||||
add_executable (YuppleMayham
|
add_executable (YuppleMayham
|
||||||
"src/main.cpp"
|
"src/main.cpp"
|
||||||
"c:/sdks/glad/src/glad.c"
|
"c:/sdks/glad/src/glad.c"
|
||||||
"src/graphics/sprite.cpp"
|
"src/graphics/sprite.cpp"
|
||||||
"src/graphics/mesh.cpp"
|
"src/graphics/mesh.cpp"
|
||||||
"src/gameplay/entity.cpp"
|
"src/gameplay/entity.cpp"
|
||||||
|
|
@ -87,6 +88,12 @@ if (CMAKE_VERSION VERSION_GREATER 3.12)
|
||||||
set_property(TARGET YuppleMayham PROPERTY CXX_STANDARD 20)
|
set_property(TARGET YuppleMayham PROPERTY CXX_STANDARD 20)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(YuppleMayham SDL2::SDL2main SDL2::SDL2 SDL2_image::SDL2_image tinyxml2 lua_static freetype Tracy::TracyClient)
|
target_include_directories(YuppleMayham PRIVATE "C:/sdks/luajit/include")
|
||||||
|
target_include_directories(YuppleMayham PRIVATE "${PROJECT_SOURCE_DIR}/YuppleMayham/include")
|
||||||
|
target_include_directories(YuppleMayham PRIVATE ${freetype_SOURCE_DIR})
|
||||||
|
target_include_directories(YuppleMayham PRIVATE ${tinyxml2_SOURCE_DIR})
|
||||||
|
target_include_directories(YuppleMayham PRIVATE "${sol2_SOURCE_DIR}/include")
|
||||||
|
|
||||||
|
target_link_libraries(YuppleMayham SDL2::SDL2main SDL2::SDL2 SDL2_image::SDL2_image "C:/sdks/luajit/lib/luajit.lib" "C:/sdks/luajit/lib/lua51.lib" tinyxml2 freetype Tracy::TracyClient)
|
||||||
|
|
||||||
# TODO: Add tests and install targets if needed.
|
# TODO: Add tests and install targets if needed.
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ private:
|
||||||
void loadMap();
|
void loadMap();
|
||||||
void createCollisionMap();
|
void createCollisionMap();
|
||||||
|
|
||||||
int getTileSetIndex(int id) const;
|
size_t getTileSetIndex(int id) const;
|
||||||
|
|
||||||
std::shared_ptr<MapData> mapData;
|
std::shared_ptr<MapData> mapData;
|
||||||
std::vector<std::shared_ptr<TileSetData>> tileSetData;
|
std::vector<std::shared_ptr<TileSetData>> tileSetData;
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ class GLWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GLWindow(const char* windowName, int width, int height) :
|
GLWindow(const char* windowName, int width, int height) :
|
||||||
name(windowName),
|
|
||||||
w(width),
|
w(width),
|
||||||
h(height) {};
|
h(height),
|
||||||
|
name(windowName) {};
|
||||||
~GLWindow();
|
~GLWindow();
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ class Script;
|
||||||
class AnimationSet;
|
class AnimationSet;
|
||||||
class AIScript;
|
class AIScript;
|
||||||
class WeaponScript;
|
class WeaponScript;
|
||||||
class TileSetData;
|
|
||||||
class SpriteComponent;
|
class SpriteComponent;
|
||||||
|
|
||||||
class ResourceManager
|
class ResourceManager
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,11 @@ void AI::attachBehaviourScript(const std::shared_ptr<AIScript>& behaviour)
|
||||||
// pay special attention each ai script has control of only their own instance of ai!
|
// pay special attention each ai script has control of only their own instance of ai!
|
||||||
this->behaviour = behaviour;
|
this->behaviour = behaviour;
|
||||||
this->behaviour->lua["raycaster"] = raycaster;
|
this->behaviour->lua["raycaster"] = raycaster;
|
||||||
this->behaviour->lua["ai"] = shared_from_this();
|
this->behaviour->lua["ai"] = sol::make_reference(this->behaviour->lua, shared_from_this());
|
||||||
|
|
||||||
if (this->behaviour->lua["idle"].valid())
|
idleFunc = this->behaviour->lua["idle"];
|
||||||
idleFunc = this->behaviour->lua["idle"];
|
patrolFunc = this->behaviour->lua["patrol"];
|
||||||
if (this->behaviour->lua["patrol"].valid())
|
alertFunc = this->behaviour->lua["alert"];
|
||||||
patrolFunc = this->behaviour->lua["patrol"];
|
|
||||||
if (this->behaviour->lua["alert"].valid())
|
|
||||||
alertFunc = this->behaviour->lua["alert"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AI::update()
|
void AI::update()
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ void Map::loadMap()
|
||||||
glm::translate(glm::mat4(1.f), glm::vec3(x * mapData->tileSize, y * mapData->tileSize, 0.0f)) *
|
glm::translate(glm::mat4(1.f), glm::vec3(x * mapData->tileSize, y * mapData->tileSize, 0.0f)) *
|
||||||
glm::scale(glm::mat4(1.f), glm::vec3(mapData->tileSize, mapData->tileSize, 1.0f));
|
glm::scale(glm::mat4(1.f), glm::vec3(mapData->tileSize, mapData->tileSize, 1.0f));
|
||||||
|
|
||||||
int textureIndex = getTileSetIndex(tileIds[layer][y][x]);
|
int textureIndex = static_cast<int>(getTileSetIndex(tileIds[layer][y][x]));
|
||||||
glm::vec2 originalSize = (textureIndex != -1) ?
|
glm::vec2 originalSize = (textureIndex != -1) ?
|
||||||
glm::vec2(tileSetData[textureIndex]->width, tileSetData[textureIndex]->height) :
|
glm::vec2(tileSetData[textureIndex]->width, tileSetData[textureIndex]->height) :
|
||||||
glm::vec2(0.0f);
|
glm::vec2(0.0f);
|
||||||
|
|
@ -81,7 +81,7 @@ void Map::createCollisionMap()
|
||||||
for (int x = 0; x < tileIds[layer][y].size(); x++)
|
for (int x = 0; x < tileIds[layer][y].size(); x++)
|
||||||
{
|
{
|
||||||
int id = tileIds[layer][y][x];
|
int id = tileIds[layer][y][x];
|
||||||
int tileSetIndex = getTileSetIndex(id);
|
size_t tileSetIndex = getTileSetIndex(id);
|
||||||
if (tileSetIndex == -1)
|
if (tileSetIndex == -1)
|
||||||
collisionMap[y][x] = 0;
|
collisionMap[y][x] = 0;
|
||||||
else
|
else
|
||||||
|
|
@ -111,7 +111,7 @@ the index of the tileSet is the same index as the texture index used in the inst
|
||||||
returns tileSetIndex of the tile id passed. Unless the id is either 0 or
|
returns tileSetIndex of the tile id passed. Unless the id is either 0 or
|
||||||
the returned tileSetIndex is out of bounds, returns -1
|
the returned tileSetIndex is out of bounds, returns -1
|
||||||
*/
|
*/
|
||||||
int Map::getTileSetIndex(int id) const
|
size_t Map::getTileSetIndex(int id) const
|
||||||
{
|
{
|
||||||
// work from the bottom, break if ID > startID
|
// work from the bottom, break if ID > startID
|
||||||
// If we get a textureIndex of -1 then we are on an empty tile
|
// If we get a textureIndex of -1 then we are on an empty tile
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,11 @@ std::shared_ptr<GameActor> Scene::getPlayer() const
|
||||||
|
|
||||||
void Scene::update(double deltaTime)
|
void Scene::update(double deltaTime)
|
||||||
{
|
{
|
||||||
|
#if _DEBUG
|
||||||
|
#else
|
||||||
ZoneScoped;
|
ZoneScoped;
|
||||||
|
#endif
|
||||||
|
|
||||||
for (const auto& [id, e] : entities)
|
for (const auto& [id, e] : entities)
|
||||||
{
|
{
|
||||||
e->update(deltaTime);
|
e->update(deltaTime);
|
||||||
|
|
@ -145,7 +149,10 @@ void Scene::update(double deltaTime)
|
||||||
|
|
||||||
void Scene::render(std::shared_ptr<Renderer> renderer)
|
void Scene::render(std::shared_ptr<Renderer> renderer)
|
||||||
{
|
{
|
||||||
|
#if _DEBUG
|
||||||
|
#else
|
||||||
ZoneScoped;
|
ZoneScoped;
|
||||||
|
#endif
|
||||||
renderer->clear();
|
renderer->clear();
|
||||||
|
|
||||||
renderer->setProjAndViewMatrix(camera->getProjectionMatrix(), camera->getViewMatrix());
|
renderer->setProjAndViewMatrix(camera->getProjectionMatrix(), camera->getViewMatrix());
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "gameplay/camera.h"
|
#include "gameplay/camera.h"
|
||||||
#include "utility/events.h"
|
#include "utility/events.h"
|
||||||
#include "utility/component.h"
|
#include "utility/component.h"
|
||||||
|
#include "utility/logger.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,6 @@ void Postprocessor::applyPostProcess(bool worldOrHud)
|
||||||
postProcessData.dt = curTime - lastTime;
|
postProcessData.dt = curTime - lastTime;
|
||||||
|
|
||||||
tickEffectTime(worldOrHud);
|
tickEffectTime(worldOrHud);
|
||||||
LOG(DEBUG, "Blur duration: {}", postProcessData.blurDuration);
|
|
||||||
|
|
||||||
postProcessShader->use();
|
postProcessShader->use();
|
||||||
postProcessShader->setBool("worldOrHud", worldOrHud);
|
postProcessShader->setBool("worldOrHud", worldOrHud);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#undef GLM_FORCE_FAST_MATH
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_image.h>
|
#include <SDL_image.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -437,7 +437,7 @@ bool XMLLoader::loadTile(tinyxml2::XMLElement* tileElement, TileSetData::TileDat
|
||||||
/*
|
/*
|
||||||
May support multiple properties in the future with a future property struct to hold any value type
|
May support multiple properties in the future with a future property struct to hold any value type
|
||||||
But this may not be needed, so we'll just capture the walkable property for now.
|
But this may not be needed, so we'll just capture the walkable property for now.
|
||||||
Notice we just return true if there is no property, we can just safely default to walkable = true
|
Assume default of there is no properties tag or walkable property, just use nested if's
|
||||||
*/
|
*/
|
||||||
tinyxml2::XMLElement* properties = tileElement->FirstChildElement("properties");
|
tinyxml2::XMLElement* properties = tileElement->FirstChildElement("properties");
|
||||||
if (properties == NULL) {
|
if (properties == NULL) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue