/* Pepy by @ohsqueezy [ohsqueezy.itch.io] */ #ifndef PEPY_H_ #define PEPY_H_ /* Enable swizzling in GLM */ #define GLM_ENABLE_EXPERIMENTAL #include #include /* [SPACE BOX] headers */ #include "Game.hpp" #include "VBO.hpp" /* Project headers */ #include "Model.hpp" class angle_sort { glm::vec2 m_origin; glm::vec2 m_dreference; // z-coordinate of cross-product, aka determinant static double xp(glm::vec2 a, glm::vec2 b) { return a.x * b.y - a.y * b.x; } public: angle_sort(const glm::vec2 origin, const glm::vec2 reference) : m_origin(origin), m_dreference(reference - origin) {} bool operator()(const glm::vec2 a, const glm::vec2 b) const { const glm::vec2 da = a - m_origin, db = b - m_origin; const double detb = xp(m_dreference, db); // nothing is less than zero degrees if (detb == 0 && db.x * m_dreference.x + db.y * m_dreference.y >= 0) return false; const double deta = xp(m_dreference, da); // zero degrees is less than anything else if (deta == 0 && da.x * m_dreference.x + da.y * m_dreference.y >= 0) return true; if (deta * detb >= 0) { // both on same side of reference, compare to each other return xp(da, db) > 0; } // vectors "less than" zero degrees are actually large, near 2 pi return deta > 0; } }; class Pepy : public Game { private: /* Convention for calling parent class in a consistent way across classes */ typedef Game super; bool shaking = true, flying = false, stopped = false; sb::VAO cuckoo_vao, wad_vao; sb::VBO vbo; GLuint shader; Model cuckoo; std::vector> wad; std::map uniform; float hue_offset = 0.0f, time_seconds = 0.0f, aspect_ratio = 1.0f, return_speed = 0.0075f, cuckoo_speed = 0.0f, countdown = 10.0f; glm::mat4 orthographic_projection {1}; glm::vec3 cuckoo_offset {0.0f, 0.0f, 0.0f}; bool grabbed = false; glm::ivec2 mouse_pixel = {0, 0}; Plane background; void load_gl_context(); void update(); public: Pepy(); void respond(SDL_Event&); }; #endif