Skip to content

Instantly share code, notes, and snippets.

View Symphonym's full-sized avatar

Jakob Larsson Symphonym

View GitHub Profile
#include <EntityPool.hpp>
#include <ScenePool.hpp>
Scene& Game::createScene(const std::string &name)
{
return m_scenePool->createScene(name);
}
Entity& Game::createEntity()
{
return m_entityPool->createEntity();
class Game
{
public:
// ... game loop functions and createX functions for scenes, systems and entities
// as well as functions like running a lua script in the global lua environment
EntityPool& getEntityPool();
ScenePool& getScenePool();
@Symphonym
Symphonym / LagSpike
Created June 6, 2014 12:37
Weird consistent ubuntu 14.04 lag spikes
icmp_seq=17 ttl=64 time=1.07 ms
icmp_seq=18 ttl=64 time=0.836 ms
icmp_seq=19 ttl=64 time=0.887 ms
icmp_seq=20 ttl=64 time=0.907 ms
icmp_seq=21 ttl=64 time=0.895 ms
icmp_seq=22 ttl=64 time=0.874 ms
icmp_seq=23 ttl=64 time=0.916 ms
icmp_seq=24 ttl=64 time=0.795 ms
icmp_seq=25 ttl=64 time=3.29 ms
icmp_seq=26 ttl=64 time=197 ms
namespace internal
{
// Forward declare OpenAL dependant classes
class ALSourceWrapper;
}
print(type(SWAG))
SWAG:Add(55)
SWAG:Print()
SWAG:Add("This should report an error, but it doesn't")
-- Everything below not called, since the above add call results in an error
SWAG:Print()
SWAG:Add()
Saurobyte::LuaEnvironment env;
env.createClass("Jebus",
{
{ "Print", [] (Saurobyte::LuaEnvironment& env) -> int
{
printf("\nVal %i\n", env.toObject<int>("Jebus"));
return 0;
}
},
{ "Add", [] (Saurobyte::LuaEnvironment& env) -> int
Saurobyte::LuaEnvironment env;
env.createClass("Testeru",
{
{ "Print", [] (Saurobyte::LuaEnvironment& env) -> int
{
printf("\nVal %i\n", *env.toObject<int>("Testeru"));
return 0;
}
},
{ "Add", [] (Saurobyte::LuaEnvironment& env) -> int
template<typename TType, typename ...TArgs>
typename std::enable_if<std::is_arithmetic<TType>::value && !std::is_same<bool, TType>::value, int>::type pushArgToLua(TType arg, TArgs... args)
{
lua_pushnumber(m_luaContext, arg);
return 1 + pushArgToLua(args...);
};
@Symphonym
Symphonym / Audio.hpp
Created April 1, 2014 22:12
Audio stuff
bool AudioDevice::playSound(const std::string &name)
{
auto threadFunc = [] (void *data) -> int
{
AudioSource *audio = static_cast<AudioSource*>(data);
audio->updateData();
AudioDevice::deleteSound(audio);
return 0;
};
function init()
print("INIT")
SubscribeEvent("KeyDown")
end
local r, g, b = 1,1,1
function update(delta)
local x, y = GetMousePos()
if (IsMousePressed("left")) then