<commit_before>#include <SDL.h>
#include <GL/glew.h>
#include <SDL_opengl.h>
#include <gl/GLU.h>
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <lua.hpp>
#include <LuaBridge.h>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/transform.hpp>
#include <bass.h>
#include <queue>
#include "types.h"
#include "wrappers.h"
#include "auxiliary.h"
#include "player.h"
#include "entity_manager.h"
#include "transform_component.h"
#include "physics_component.h"
#include "physics_system.h"
#include "platformer_physics_system.h"
#include "bounding_box_component.h"
#include "collision_system.h"
#include "simple_render_component.h"
#include "render_system.h"
#include "texture.h"
#include "shader.h"
#include "tiled_map.h"
#include "game_state.h"

using namespace te;

namespace te
{
    struct Sprite
    {
        TexturePtr pTexture;
        int w;
        int h;
        Sprite(TexturePtr pTexture, int w, int h)
            : pTexture(pTexture), w(w), h(h) {}
    };

    class CollisionHandler : public Observer<CollisionEvent>, public Observer<MapCollisionEvent>
    {
    public:
        typedef std::pair<Entity, Entity> EntityPair;
        typedef std::pair<Entity, TiledMap*> EntityMapPair;

        std::map<EntityPair, std::function<void(Entity, Entity, float)>> map;
        std::map<EntityMapPair, std::function<void(Entity, TiledMap&, float)>> tiledCollisionMap;

        virtual void onNotify(const CollisionEvent& evt)
        {
            EntityPair pair = { evt.a, evt.b };
            auto it = map.find(pair);
            if (it != map.end())
            {
                it->second(evt.a, evt.b, evt.dt);
            }
        }

        virtual void onNotify(const MapCollisionEvent& evt)
        {
            EntityMapPair pair = { evt.entity, &evt.map };
            auto it = tiledCollisionMap.find(pair);
            if (it != tiledCollisionMap.end())
            {
                it->second(evt.entity, evt.map, evt.dt);
            }
        }
    };

    class PauseState : public GameState
    {
    public:
        bool processInput(const SDL_Event& evt)
        {
            if (evt.type == SDL_KEYDOWN)
            {
                if (evt.key.keysym.sym == SDLK_SPACE)
                {
                    queuePop();
                }
            }
            return false;
        }

        bool update(float dt)
        {
            return false;
        }

        void draw()
        {
            glClearColor(0.f, 1.f, 0.f, 0.5f);
            glClear(GL_COLOR_BUFFER_BIT);
        }
    };

    class LuaGameState : public GameState
    {
    public:
        LuaGameState(const glm::mat4& projection, const std::string& filename = "init.lua")
            : GameState()
            , mpMap(new TiledMap("tiled", "sample.lua", glm::ortho<GLfloat>(0, 16, 9, 0, 1, -1), glm::mat4()))
            , mCollisionHandler(new CollisionHandler())
            , mpTransformComponent(new TransformComponent())<commit_msg>Test stack clearing in test driver<commit_after>#include <SDL.h>
#include <GL/glew.h>
#include <SDL_opengl.h>
#include <gl/GLU.h>
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <lua.hpp>
#include <LuaBridge.h>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/transform.hpp>
#include <bass.h>
#include <queue>
#include "types.h"
#include "wrappers.h"
#include "auxiliary.h"
#include "player.h"
#include "entity_manager.h"
#include "transform_component.h"
#include "physics_component.h"
#include "physics_system.h"
#include "platformer_physics_system.h"
#include "bounding_box_component.h"
#include "collision_system.h"
#include "simple_render_component.h"
#include "render_system.h"
#include "texture.h"
#include "shader.h"
#include "tiled_map.h"
#include "game_state.h"

using namespace te;

namespace te
{
    struct Sprite
    {
        TexturePtr pTexture;
        int w;
        int h;
        Sprite(TexturePtr pTexture, int w, int h)
            : pTexture(pTexture), w(w), h(h) {}
    };

    class CollisionHandler : public Observer<CollisionEvent>, public Observer<MapCollisionEvent>
    {
    public:
        typedef std::pair<Entity, Entity> EntityPair;
        typedef std::pair<Entity, TiledMap*> EntityMapPair;

        std::map<EntityPair, std::function<void(Entity, Entity, float)>> map;
        std::map<EntityMapPair, std::function<void(Entity, TiledMap&, float)>> tiledCollisionMap;

        virtual void onNotify(const CollisionEvent& evt)
        {
            EntityPair pair = { evt.a, evt.b };
            auto it = map.find(pair);
            if (it != map.end())
            {
                it->second(evt.a, evt.b, evt.dt);
            }
        }

        virtual void onNotify(const MapCollisionEvent& evt)
        {
            EntityMapPair pair = { evt.entity, &evt.map };
            auto it = tiledCollisionMap.find(pair);
            if (it != tiledCollisionMap.end())
            {
                it->second(evt.entity, evt.map, evt.dt);
            }
        }
    };

    class PauseState : public GameState
    {
    public:
        bool processInput(const SDL_Event& evt)
        {
            if (evt.type == SDL_KEYDOWN)
            {
                if (evt.key.keysym.sym == SDLK_SPACE)
                {
                    queuePop();
                }
                else if (evt.key.keysym.sym == SDLK_q)
                {
                    queueClear();
                }
            }
            return false;
        }

        bool update(float dt)
        {
            return false;
        }

        void draw()
        {
            //glClearColor(0.f, 1.f, 0.f, 0.5f);
            //glClear(GL_COLOR_BUFFER_BIT);
        }
    };

    class LuaGameState : public GameState
    {
    public:
        LuaGameState(const glm::mat4& projection, const std::string& filename = "init.lua")
            : GameState()
            , mpMap(new TiledMap("tiled", "sample.lua", glm::ortho<GLfloat>(0, 16, 9, 0, 1, -1), glm::mat4()))
            , mCollisionHandler(new CollisionHandler())
            , mpTransformComponent(new TransformComponent())
{'fraction_non_alphanumeric': 0.1302149178255373, 'fraction_numerical': 0.004424778761061947, 'mean_word_length': 2.2045569620253165, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5288620', 'n_tokens_mistral': 2099, 'n_tokens_neox': 2064, 'n_words': 433}