Please read a book about C++. You are calling a METHOD (as opposed to function). A method belongs to an object. Therefore, you can access a pointer to object you are calling your method from using keyword 'this'. So you can write
void Entity::turning(char facing1, vector<Tile> mv) {
if (this->is_swing_hoe == false) {
if(this->facing != facing1) {
this->facing = facing1; this->wait_time = 0;
}
else if (this->can_pass(this->facing,mv,this)&& this->wait_time > 3) {
this->frame = 1; this->move_animation = true;
}
}
}
and 'this' will correspond to 'hero' if you call it like
hero->turning('d',mv);
Even better, you can remove all the 'this->' from above code. Your compiler knows that in methods, if you write a name of a variable you declared in the class of the object, that is the variable to use (if you didn't write a conflicting declaration in the method, of course).
You also should not pass a std::vector variable by value (that means, not using a pointer or, preferably, a reference). Why? Because your program needs to make a new copy of that vector. That means it must manually copy all the objects (in your case, tiles) your std::vector stores.
In fact, if you think about it, what should the Entity know? It should know on which map it is and its position. If you implement the Map class (which should probably have a vector of tiles), you can use something like
void Entity::turning(char facing1) {
//not sure what THIS code does, but it is yours, so I won't modify it (except showing the 'OOP way')
if (is_swing_hoe == false) {
if(facing != facing1) {
facing = facing1;
wait_time = 0;
}
//suppose that map can extract all the needed information from the entity using getters
else if (map->can_pass(this, facing1)&& wait_time > 3) {
frame = 1;
move_animation = true;
}
}
}
Voila! The function is much more readable. As a rule of thumb, you should always think twice before starting working on a new feature. How will I represent it? Who (which class) will use it? How should I implement it? If you ask and answer all the questions that come to your mind, you will find yourself writing much cleaner (and bug-free) code.