2D sidescrollers and collision detection
I haven't really learned about graphics and C++ yet, so bare with me here. For anyone who has made a sidescroller before: I just was really curious about collision detection. How does it work? I remember when I was trying to make a game a long time ago in Qbasic...lol. I must of had a hundred of statements that looked like this (i forgot all the syntax in basic, so here it is in C++ form):
Code:
if (x > 10 && x < 20 && y > 5 && y < 90)
{
if (x < xtemp)
{
x--;
}
else
{
x++;
}
}
if (x > 7 && x > 18 &&....)
Since that's so tedious, can someone explain how else you would do it?