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
|
||||
*.swp
|
||||
/Resources/scenes/.debugScene.xml.swp
|
||||
compile_commands.json
|
||||
|
|
|
|||
|
|
@ -12,11 +12,20 @@ endif()
|
|||
include(FetchContent)
|
||||
|
||||
SET(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
||||
#SET(SOL_LUAJIT 1)
|
||||
|
||||
SET(TRACY_ENABLE 1)
|
||||
SET(TRACY_ON_DEMAND 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(
|
||||
tracy
|
||||
GIT_REPOSITORY https://github.com/wolfpld/tracy.git
|
||||
|
|
@ -25,7 +34,34 @@ FetchContent_Declare(
|
|||
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(tinyxml2)
|
||||
FetchContent_MakeAvailable(sol2)
|
||||
FetchContent_MakeAvailable(freetype)
|
||||
|
||||
project ("YuppleMayham")
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ moveLeft = true
|
|||
function watchPosition(actor, pos)
|
||||
local y = pos.y - actor.position.y
|
||||
local x = pos.x - actor.position.x
|
||||
local rotation = math.atan(y, x)
|
||||
local rotation = math.atan2(y, x)
|
||||
actor.rotation = math.deg(rotation)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,25 +2,26 @@
|
|||
# project specific logic here.
|
||||
#
|
||||
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(SDL2_IMAGE REQUIRED)
|
||||
find_package(SDL2 2.30.2 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/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/sol2-3.3.0/single/single/include")
|
||||
include_directories(SYSTEM "c:/sdks/lua-5.4.6/include")
|
||||
include_directories(SYSTEM "C:/sdks/freetype-2.13.2/include")
|
||||
link_directories(SYSTEM "C:/sdks/freetype-2.13.2/objs")
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/lib")
|
||||
else()
|
||||
link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/release/lib")
|
||||
endif()
|
||||
link_directories(SYSTEM "c:/sdks/lua-5.4.6/lib")
|
||||
#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/freetype-2.13.2/include")
|
||||
#link_directories(SYSTEM "C:/sdks/freetype-2.13.2/objs")
|
||||
#if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
# link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/lib")
|
||||
#else()
|
||||
# link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/release/lib")
|
||||
#endif()
|
||||
#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_executable (YuppleMayham
|
||||
|
|
@ -87,6 +88,12 @@ if (CMAKE_VERSION VERSION_GREATER 3.12)
|
|||
set_property(TARGET YuppleMayham PROPERTY CXX_STANDARD 20)
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ private:
|
|||
void loadMap();
|
||||
void createCollisionMap();
|
||||
|
||||
int getTileSetIndex(int id) const;
|
||||
size_t getTileSetIndex(int id) const;
|
||||
|
||||
std::shared_ptr<MapData> mapData;
|
||||
std::vector<std::shared_ptr<TileSetData>> tileSetData;
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ class GLWindow
|
|||
{
|
||||
public:
|
||||
GLWindow(const char* windowName, int width, int height) :
|
||||
name(windowName),
|
||||
w(width),
|
||||
h(height) {};
|
||||
h(height),
|
||||
name(windowName) {};
|
||||
~GLWindow();
|
||||
|
||||
bool Init();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ class Script;
|
|||
class AnimationSet;
|
||||
class AIScript;
|
||||
class WeaponScript;
|
||||
class TileSetData;
|
||||
class SpriteComponent;
|
||||
|
||||
class ResourceManager
|
||||
|
|
|
|||
|
|
@ -18,13 +18,10 @@ void AI::attachBehaviourScript(const std::shared_ptr<AIScript>& behaviour)
|
|||
// pay special attention each ai script has control of only their own instance of ai!
|
||||
this->behaviour = behaviour;
|
||||
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"];
|
||||
if (this->behaviour->lua["patrol"].valid())
|
||||
patrolFunc = this->behaviour->lua["patrol"];
|
||||
if (this->behaviour->lua["alert"].valid())
|
||||
alertFunc = this->behaviour->lua["alert"];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ void Map::loadMap()
|
|||
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));
|
||||
|
||||
int textureIndex = getTileSetIndex(tileIds[layer][y][x]);
|
||||
int textureIndex = static_cast<int>(getTileSetIndex(tileIds[layer][y][x]));
|
||||
glm::vec2 originalSize = (textureIndex != -1) ?
|
||||
glm::vec2(tileSetData[textureIndex]->width, tileSetData[textureIndex]->height) :
|
||||
glm::vec2(0.0f);
|
||||
|
|
@ -81,7 +81,7 @@ void Map::createCollisionMap()
|
|||
for (int x = 0; x < tileIds[layer][y].size(); x++)
|
||||
{
|
||||
int id = tileIds[layer][y][x];
|
||||
int tileSetIndex = getTileSetIndex(id);
|
||||
size_t tileSetIndex = getTileSetIndex(id);
|
||||
if (tileSetIndex == -1)
|
||||
collisionMap[y][x] = 0;
|
||||
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
|
||||
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
|
||||
// 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)
|
||||
{
|
||||
#if _DEBUG
|
||||
#else
|
||||
ZoneScoped;
|
||||
#endif
|
||||
|
||||
for (const auto& [id, e] : entities)
|
||||
{
|
||||
e->update(deltaTime);
|
||||
|
|
@ -145,7 +149,10 @@ void Scene::update(double deltaTime)
|
|||
|
||||
void Scene::render(std::shared_ptr<Renderer> renderer)
|
||||
{
|
||||
#if _DEBUG
|
||||
#else
|
||||
ZoneScoped;
|
||||
#endif
|
||||
renderer->clear();
|
||||
|
||||
renderer->setProjAndViewMatrix(camera->getProjectionMatrix(), camera->getViewMatrix());
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "gameplay/camera.h"
|
||||
#include "utility/events.h"
|
||||
#include "utility/component.h"
|
||||
#include "utility/logger.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ void Postprocessor::applyPostProcess(bool worldOrHud)
|
|||
postProcessData.dt = curTime - lastTime;
|
||||
|
||||
tickEffectTime(worldOrHud);
|
||||
LOG(DEBUG, "Blur duration: {}", postProcessData.blurDuration);
|
||||
|
||||
postProcessShader->use();
|
||||
postProcessShader->setBool("worldOrHud", worldOrHud);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#undef GLM_FORCE_FAST_MATH
|
||||
#include <SDL.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
|
||||
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");
|
||||
if (properties == NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue