From ec3c5c253af20350afe1a7d9d7dbfb07dd904056 Mon Sep 17 00:00:00 2001 From: Seth Long Date: Wed, 21 Oct 2026 15:39:52 -0700 Subject: [PATCH] Trival change to test hook --- game.h | 2 +- game.h~ | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 game.h~ diff --git a/game.h b/game.h index 568adc8..71eedf9 100644 --- a/game.h +++ b/game.h @@ -1,7 +1,7 @@ #pragma once /* Set this to WINDOWS for Windows, UNIX for Linux, BSD, etc. */ -#define UNIX +#define WINDOWS /* This is needed to allow fopen, fread, etc. */ #ifdef WINDOWS diff --git a/game.h~ b/game.h~ new file mode 100644 index 0000000..568adc8 --- /dev/null +++ b/game.h~ @@ -0,0 +1,163 @@ +#pragma once + +/* Set this to WINDOWS for Windows, UNIX for Linux, BSD, etc. */ +#define UNIX + +/* This is needed to allow fopen, fread, etc. */ +#ifdef WINDOWS +#define _CRT_SECURE_NO_WARNINGS +#define M_PI 3.141592653 +typedef __int64 ssize_t; +#endif + +/* General-purpose C includes */ +#include +#include + +/* General-purpose C++ includes */ +#include +#include +#include + +/* Data Structures */ +#include +#include + +/* OpenGL Loader */ +#ifdef UNIX +#include // glad on Windows +#else +#include +#endif + +/* OpenGL Includes */ +#include +#include +#include +#include + +/* Tiny obj loader - loads Wavefront .obj files */ +#include "tiny_obj_loader.h" + +/* Provides stbi_image to load textures */ +#include "stb_image.h" + +using namespace std; +using namespace glm; + +struct globals { + float height = 800; + float width = 1280; + float gravity = 0.02f; + float jump_speed = 0.7f; + bool shutdown = false; + vec3 player_position; + float heading = 0.0; + float elevation = 0.0; + float vertical_speed = 0.0; + float player_height = 1.5; + float move_margin = 0.4f; + float runspeed = 0.8f; + float walkspeed = 0.2f; + bool forward = false; + bool backward = false; + bool left = false; + bool right = false; + bool run = false; + bool release_cursor = false; + int on_count = 0; +}; + +vec3 get_lookat_point(int direction = 0, float r = 0.0); +char* get_source(const char *filename); + +class GameObject { + public: + /* Identifiers for OpenGL resources */ + unsigned int v_attrib; + unsigned int tc_attrib; + unsigned int vp_uniform; + unsigned int program; + unsigned int vbuf; + unsigned int ebuf; + unsigned int tex; + unsigned int element_count; + unsigned int models_buffer; + + /* Properties related to initialization. Set these when initializing an object */ + string object_file, texture_file, vertex_shader, fragment_shader; + bool flip_yz = false; + string name; + bool moving = false; + + GameObject() { + object_file = "objects/cube.obj"; + vertex_shader = "shaders/vertex_shader.glsl"; + fragment_shader = "shaders/fragment_shader.glsl"; + } + + /* Properties not related to OpenGL */ + vector models; + bool visible = true; + + void add_location(vec3 location); + bool init(); + void draw(mat4 vp); + virtual void movement(float) {}; // takes the number of milliseconds since the last run + virtual void trigger_action(size_t instance, int action) {} + + /* Required for collision detection */ + virtual float fast_check_distance(size_t instance) {return 0;} + virtual vec3 closest_point(vec3 other, size_t instance) {return vec3(0, 0, 0);} + virtual vec3 get_center(size_t instance) {return vec3(0, 0, 0);} + virtual void report_collision(GameObject *other, size_t other_instance, size_t our_instance) {}; +}; + +class SolidObject : public GameObject { +public: + + /* Stuff we actually used */ + virtual ssize_t is_inside(vec3 point, float margin) {return false;} + virtual float get_top(size_t instance); + virtual float get_bottom(size_t instance); + virtual float get_topbottom(size_t instance, bool); + + /* Stuff we haven't used yet */ + bool collision = false; + bool blocks_player = false; + void collided(GameObject& other, size_t our_instance, size_t other_instance); + //some_format get_hit_box(); + bool is_over(); + /* Vector of sizes of instance? Or are all the instances the same size? */ + /* Something for bouncing? */ + +}; + +#ifdef MAIN +globals g; +vector game_objects; +vector solid_objects; +map gl_resources; +#else +extern globals g; +extern vector game_objects; +extern vector solid_objects; +extern map gl_resources; +#endif + +struct vertex { + float x, y, z, u, v; +}; +bool operator==(const vertex& a, const vertex& o); + +ostream& operator<<(ostream& out, vec3 v); + +#define PLAYER_ON_OBJECT 1 +#define ACTIVATE 2 + +/* Other objects that aren't base classes go next */ +#include "misc_objects.h" +#include "water_tank.h" +#include "projectile.h" +GameObject* add_object(GameObject *new_object, string name, bool solid = false); +void load_level(); -- 2.47.3