Show 80 post(s) from this thread on one page
Page 3 of 3 First 123
• 05-20-2007
Livijn
Still same problem..

Code:
Code:

```//Check if there is a collision bool check_coll( int sX, int sY, int pX, int pY ) {     //Square's position     int sXl = sX;     int sXr = sX + 29;     int sYl = sY;     int sYr = sY + 29;         //Piece's position     int pXl = pX;     int pXr = pX + 75;     int pYl = pY;     int pYr = pY + 148;         //Check if you hit the square     if ((pXr >= sXl && pXr < sXr) || (pXl <= sXr && pXl > sXl) || (sXl >= pXl && sXl <= pXr) || (sXr <= pXr && sXr >= pXl))     {             return true;     }     else     {         return false;     } } //Move square if there is a collision void move_and_show_square( int sX, int sY, int pX, int pY ) {     //Variables     int sXl;     sXl = 400;         //If there is a collision     if (check_coll( sX, sY, pX, pY ) == true)     {                     //New position for the square                     sXl = 50;                                         //Make the square move                     SDL_FillRect( screen, NULL, SDL_MapRGB(screen->format, 0x00, 0x00, 0x00) );                     apply_surface( 0, 0, background, screen );                     piece = load_image( "piece.png" );                     apply_surface( pX, pY, piece, screen );     }         //Apply the square     apply_surface( sXl, 300, square, screen ); }```
• 05-21-2007
Livijn
Only 2 weeks left to my girlfriends anniversary. Please help me out with this one and i'll help you so much i can. PLEASE! I BEG YOU! Actually, i don't wanna do this bump, but i must! I can't dissapoint here, seriously i can't.
• 05-21-2007
anon
Oh dear

Code:

```//Move square if there is a collision void move_and_show_square( int & sX, int sY, int pX, int pY ) {     //Variables     /*int sXl;     sXl = 400;*/ //What is that for? Want to change sX to either 400 or 50?     sX = 400;         //If there is a collision     if (check_coll( sX, sY, pX, pY ) == true)     {                     //New position for the square                     sX = 50;                                         //Make the square move                     SDL_FillRect( screen, NULL, SDL_MapRGB(screen->format, 0x00, 0x00, 0x00) );                     apply_surface( 0, 0, background, screen );                     piece = load_image( "piece.png" ); //do you remember to unload this? or why you keep loading it                     apply_surface( pX, pY, piece, screen );     }         //Apply the square     apply_surface( sX, 300, square, screen ); }```
These are just guesses. There are global stuff around and magical values, so I can really only guess what this function is meant to achieve.
• 05-22-2007
Livijn
If there aint a collision, i want the square to stay at it's position.
• 05-22-2007
anon
In that case don't change sX to 400. That's what your original code does.
Show 80 post(s) from this thread on one page
Page 3 of 3 First 123