so i am doing homework 13 from the poo game i had the goal made and made it pulse color in a neat way(Had a lot of problems but solved them all like a boss) so the next step was to add a custom hitdetection i could repurpose it to make the poos bounce off the goal
so i wrote a hit detec function like this//disclaimer :i don,t know if this code will even run nicely
but i think it should or at least i think i can make it work
Code: Select all
bool Goal::HitDetection(Player & P)
{
int GP = Point;
int PX = P.GetX();
int PY = P.GetY();
int GDim = Point + GoalWH;
int PXDim = P.GetX() + P.GetWH();
int PYDim = P.GetY() + P.GetWH();
if (GP <= PXDim && GDim >= PX && GP <= PYDim && GDim >= PY)
{
Test = true;
}
return Test;
}
but when i run this bs it starts trowing a hissy fit at the getter function after a look in MR.debugeur
i found out that the member vars that the getters get are not init when the code above runs
my anwser was i need to load them at start pefferbly when Goal class get loaded so i made a constructor in that class to init it
Code: Select all
Goal::Goal(Player& P)
:
P(P)
{
}
this dini,t happen tho and i could not quite get why but it is what it is
so i was thinking that i maby could load the member var itself instead of the whole class
so underneath here is the things i try,d
Code: Select all
Goal::Goal(Player& P)
:
P(P),
X(X)
{
}
Goal::Goal(Player& P)
:
P(P),
P.X
{
}
Goal::Goal(Player& P)
:
P(P),
Player::X
{
}
Goal::Goal(Player& P)
:
P(P),
X(P)
{
}
but and the end the member var is still not loaded
it might be that cus the class im calling is lower in the header list so it loads later or it only loads when a functon gets called of that class honestly i have no idea
but at this point im out of ideas
ofcourse i could trow alot of code around until i get it working but that would be way way way less shiny the having it work like i intended
that and this is what my brain came up with so i want to followtrough and get it working correctly
i don,t have git hub just yet the tut for that is a little further so ist a bit messy in here
but i hope i made some sense and that
someone with that sweet liquid code knowledge goodness can spray some on my face so i can rub it on my eyes and come to see the error of my ways
yours trully that random guy from a year ago that said that he had a good idea (not that great of an idea turns out )
and in advance thank you verry much for the help your willing to give me
Skyver