]> isoptera.lcsc.edu Git - engine26/.git/commitdiff
The suggest in class that the cat was blocking its own vision was spot-on. Adding...
authorSeth Long <sslong@lcsc.edu>
Wed, 4 Nov 2026 01:06:59 +0000 (17:06 -0800)
committerSeth Long <sslong@lcsc.edu>
Wed, 4 Nov 2026 01:06:59 +0000 (17:06 -0800)
cat.h
game.h
load_level.cpp
main.cpp

diff --git a/cat.h b/cat.h
index f7813a500c50ff53b5c9270135dcc7a601aee55f..3260f7d3430cd6f1fbc77806bf46c5107274ab4a 100644 (file)
--- a/cat.h
+++ b/cat.h
@@ -10,6 +10,7 @@ public:
        };
        void add_location(vec3 loc){
                models.push_back(translate(mat4(1.0), loc));
+               specials.push_back(0);
        }
        void movement(float time) {
                for(size_t i = 0; i < models.size(); i++) {
@@ -28,12 +29,12 @@ public:
                                        for(size_t mouse_inst = 0; mouse_inst < mouse->models.size(); mouse_inst++){
                                                vec3 mcp = mouse->closest_point(our_center, mouse_inst);
                                                vec3 ocp = closest_point(mcp, i);
-                                               if(can_see(mcp, ocp)){
-                                                       printf("We can see a mouse!\n");
+                                               if(can_see(mcp, ocp, 2.0f)){
+                                                       specials[i] = 1;
+                                                       mouse->specials[mouse_inst] = 2;
                                                } else {
-                                                       if(switchtime > 900){
-                                                               cout << "Can't see mouse, our_center = " << our_center << " mcp = " << mcp << endl;
-                                                       }
+                                                       specials[i] = 0;
+                                                       mouse->specials[mouse_inst] = 0;
                                                }
                                        }
                                }       
diff --git a/game.h b/game.h
index 00c61ec2b2a4403b0eaa5acfb97512653861b417..15b6e089c927c85975162608d09cca0fca642dca 100644 (file)
--- a/game.h
+++ b/game.h
@@ -162,7 +162,7 @@ ostream& operator<<(ostream& out, vec3 v);
 GameObject* add_object(GameObject *new_object, string name, bool solid = false);
 void load_level();
 GameObject* find_object(string name);
-bool can_see(vec3 A, vec3 B);
+bool can_see(vec3 A, vec3 B, float start_distance = 0.0f);
 
 #define PLAYER_ON_OBJECT 1
 #define ACTIVATE 2
index c26283f011ce6c158158a83a7adbdc0df9d86732..c2c5f8f3550048f845289397381311fc1ca0039e 100644 (file)
@@ -54,11 +54,13 @@ void load_level(){
        targ->add_location_size(vec3(20, 40, 40), vec3(6, 6, 6));
 
        Cat *cat = (Cat*)add_object(new Cat, "Cat", true);
-       cat->add_location(vec3(5, 2, 40));
+       cat->add_location(vec3(10, 2, 40));
        cat->texture_file = "textures/cat.jpg";
 
+       targ->add_location_size(vec3(0, 2, 40), vec3(5, 5, 5));
+
        FloorPanel *mouse = (FloorPanel*)add_object(new FloorPanel, "Mouse", true);
-       mouse->add_location(vec3(-5, 0, 40));
+       mouse->add_location(vec3(-10, 0, 40));
        mouse->texture_file = "textures/mouse.jpg";
 }
 
index 7a49e949e98cd622f26dcdfbe3c2c0aec6c5c0cf..621fbfbec9d08a5599d09a58af4aabfb515218e9 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -90,8 +90,9 @@ float closest_check(vec3 pointcheck){
        return min_distance;
 }
 
-bool can_see(vec3 A, vec3 B){
+bool can_see(vec3 A, vec3 B, float start_distance){
        vec3 D = normalize(B - A);
+       A += D * start_distance;
        while(true){
                float move_distance = closest_check(A);
                /* Should the 0.01 be a parameter like "Open space width"? */