This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SAT collision check and resolution | |
// Public domain | |
// Usage example: | |
// if (testCollision(obb1, obb2, mtv)) { // obb1, obb2 - sf::RectangleShape, mtv - sf::Vector2f | |
// obb1.move(mtv); | |
// } | |
static const float NORMAL_TOLERANCE = 0.0001f; | |
using RectVertexArray = std::array<sf::Vector2f, 4>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handles = {} | |
local memoizedFuncs = {} | |
-- metatable which does magic | |
local mt = {} | |
mt.__index = function(handle, key) | |
if not handle.isValid then | |
print(debug.traceback()) | |
error("Error: handle is not valid!", 2) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sol.hpp> | |
#include <string> | |
#include <iostream> | |
using EntityId = int; | |
class Entity { | |
public: | |
explicit Entity(EntityId id) : | |
name("John"), id(id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <memory> | |
#include <string> | |
#include <unordered_map> | |
#include <json.hpp> | |
using json = nlohmann::json; | |
template <typename Class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <meta.h> | |
#include <json.h> | |
using json = nlohmann::json; | |
struct Entity { | |
int id; | |
}; | |
struct Character : Entity { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SFML/Graphics.hpp> | |
#include <SFML/Window/Keyboard.hpp> | |
#include <Eigen/Sparse> | |
#include <Eigen/Geometry> | |
namespace Eigen | |
{ | |
template <typename T> | |
using Vector2 = Eigen::Matrix<T, 2, 1>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void LevelEditor::update(math::Time dt) | |
{ | |
camera.update(dt); | |
{ | |
auto& rs = engine_system.getGame().getSystem<RenderingSystem>(); | |
rs.updateView("levelEditor", camera.getView()); | |
} | |
currentState->update(dt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"testing" | |
"github.com/kvartborg/vector" | |
) | |
// kvartborg/vector version | |
type vec = vector.Vector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"testing" | |
"github.com/go-gl/mathgl/mgl32" | |
"github.com/kvartborg/vector" | |
"github.com/ungerik/go3d/vec2" | |
"gonum.org/v1/gonum/mat" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- depends on https://github.com/kikito/inspect.lua | |
local inspect = require 'inspect' | |
local M = {} | |
local function tostring_impl(v) | |
if type(v) == "table" then | |
-- change to inspect(v, {newline=""}) if you want to print everything tables on one line | |
return inspect(v) | |
elseif type(v) == "nil" then |