Mex
January 31, 2018, 7:15pm
1
Hi im working on a little demo on andorid using sdl2 and the ndk , also in c++.
In the code i use an SDL_Point construct to save and modify the position of an object1.
now the problem is that the code i use to check if the two objects are in the same position, triggers on every position object1 has been before, even tough in mý code i dont save it.
Greetings
JonnyD
January 31, 2018, 7:38pm
2
This is very specific to your program, so if you need help, we’d need to
see some of the code you’re working with.
Mex
January 31, 2018, 8:20pm
3
Hey, here’s some code. Only side note destination and location are sdl_Point construct that i initilize like: SDL_Point destination = {0, 0};
DestinationTEMPx = Destination.x;
DestinationTEMPy = Destination.y;
LocationTEMPx = Location.x;
LocationTEMPy = Location.y;
if ( (DestinationTEMPx > LocationTEMPx) && (DestinationTEMPx > 50) && (LocationTEMPx > 50) )
{
DestinationTEMPx -= LocationTEMPx;
distanceTOpylonX = DestinationTEMPx;
}
if ( (DestinationTEMPy > LocationTEMPy) && (DestinationTEMPy > 50) && (LocationTEMPy > 50))
{
DestinationTEMPy -= LocationTEMPy;
distanceTOpylonY = DestinationTEMPy;
}
if ( (LocationTEMPx > DestinationTEMPx) && (LocationTEMPx > 50) && (DestinationTEMPx > 50))
{
LocationTEMPx -= DestinationTEMPx;
distanceTOpylonX = LocationTEMPx;
}
if ( (LocationTEMPy > DestinationTEMPy) && (LocationTEMPy > 50) && (DestinationTEMPy > 50) )
{
LocationTEMPy -= DestinationTEMPy;
distanceTOpylonY = LocationTEMPy;
}
if ( (loopTIMES > 2) && (distanceTOpylonX < 40) && (distanceTOpylonY < 40) && (distanceTOpylonX > 5) && (distanceTOpylonY > 5))
{
if ((Location.x > 50) && (Location.y > 50))
{
LocationPylon.x = ( rand() % ( gScreenRect.w - 50 ));
LocationPylon.y = ( rand() % ( gScreenRect.h - 100 ));
Location.x = 0;
Location.y = 0;
Destination.x = 0;
Destination.y = 0;
scoreVAR += 1;
}
}