#ifndef HELPINGCAT_H #define HELPINGCAT_H struct HelpingCat : public GameObject { vector active; vector reload; float radius = 4.0; HelpingCat() : GameObject("HelpingCat") {} static vec3 input_transform(float x, float y, float z){ return vec3(x*2, z*2, y*2); } bool init() override { init_from_object("cube.obj", input_transform); setup_standard_shaders(); setup_texture("cat.jpg"); setup_locations(); return true; } void draw(mat4 vp){ draw_object(vp); } void add(float x, float y, float z){ locations.push_back(vec4(x, y, z, 0)); active.push_back(false); reload.push_back(0); } void activate(float x, float y, float z){ int contact = in_contact(x, y, z); if(contact != -1) active[contact] = !active[contact]; } void movement(){ for(auto go : objects){ if(!go->hostile) continue; if(!go->locations.size()) continue; vec4 target_loc = go->locations[0]; for(int i = 0; i < locations.size(); i++){ if(!active[i]) continue; reload[i]--; if(reload[i] <= 0){ printf("Active cat! Firing\n"); vec3 tv3 = 0.5f * normalize(vec3(target_loc.x - locations[i].x, target_loc.y - locations[i].y, target_loc.z - locations[i].z)); projectiles->addnew_direct(locations[i], vec4(tv3.x, tv3.y, tv3.z, 400.0f)); reload[i] = 20; } } } } }; #endif