That's not to hard there are a few ways you could do that. a simple way is declare four integers that you want the names of the case to be. It would look something like this.
//length of X = 11
//length of Y = 35
void NoTouchy();
int Collision;
int Under = 1;
int Above = 2;
int RightOf = 3;
int LeftOf = 4;
void NoTouchy()
{
switch ( Collision )
{
case Under: //Under:
if ( FloorlvlY <= mY )//Floor is 35px below main sprite?
{
mY = ( FloorlvlY + 35 );
mX = mX;
}
break;
//if (!=not mX is in corner touching two boundaries) break;
case Above: //Above:
if ( FloorlvlY >= mY )
{
mY = ( FloorlvlY - 35 );
mX;
}
break;
case RightOf: //RightOf:
if ( FloorlvlX >= mX )
mY = ( FloorlvlX + 11 );
break;
case LeftOf: //LeftOf:
if ( FloorlvlX <= mX );
mY = ( FloorlvlX - 11 );
break;
default:
FreeFall();
}
}
Now when you want to switch to a different case you just equal Collision to whichever case you want it to be in like so:
Now say you start getting more cases later on, it would be easier to make an enumeration like in the dark invaders game. So it might look something like this:
void NoTouchy();
enum e_Collision {Under, Above, RightOf, LeftOf};
e_Collision Collision;
void NoTouchy()
{
switch ( Collision )
{
case Under: //Under:
if ( FloorlvlY <= mY )//Floor is 35px below main sprite?
{
mY = ( FloorlvlY + 35 );
mX = mX;
}
break;
//if (!=not mX is in corner touching two boundaries) break;
case Above: //Above:
if ( FloorlvlY >= mY )
{
mY = ( FloorlvlY - 35 );
mX;
}
break;
case RightOf: //RightOf:
if ( FloorlvlX >= mX )
mY = ( FloorlvlX + 11 );
break;
case LeftOf: //LeftOf:
if ( FloorlvlX <= mX );
mY = ( FloorlvlX - 11 );
break;
default:
FreeFall();
}
}
Just like the example before when you want to change cases you just equal Collision to whatever enumeration name you specified like so:
Hope this helps.