Jump to content

  • Log In with Google      Sign In   
  • Create Account


DuckerDuck

Member Since 20 Jun 2012
Offline Last Active Jun 28 2012 10:05 AM

Posts I've Made

In Topic: [SDL] SDL_Rect array

26 June 2012 - 08:33 AM

Well, I found the problem. Somehow I got the function of code block 4 in a loop. Making NumberOfPlatforms grow far above 19.
Thanks everybody for the respones,

In Topic: [SDL] SDL_Rect array

26 June 2012 - 07:01 AM

If number of platforms is 20 and you are looping over i<=NumberOfPlatforms then the last element is 21st out of 20, because you are looping over 0, 1, ..., 20 and that's 21 elements. So it's likely out of bounds as already mentioned.


The "NumberOfPlatforms" int starts out as 0, than (with the function of code block 4) the number is increased.

Also, not rendering still makes the game crash.



Also, have you ever used a debugger? It allows you to step through your code while the program is running, so you can see when and why it's crashing.


I have not, but setting breakpoints doesn't seem to work for me, when debugging the app closes instantly. (Visual Studio 2010 Express)

In Topic: [SDL] Timer problem

20 June 2012 - 10:20 AM

Thanks BeerNutts, you're pseudo code got the job done.

In Topic: [SDL] Timer problem

20 June 2012 - 08:43 AM

A alternative way to overcome the problem is to set a flag on the portals, so that when you use a portal the exit portal will set the flag to cannot use until it stops detecting a collision with the player, and then it sets the flag to be can be used.

Portal A - > B , player walks up to Portal A (flag set to can use) , Portal A sets Portal B flag to cannot use and teleports the player to Portal B, and while player is colliding with Portal B the flag remains cannot use but when the player walks out of collision range, Portal B sets its own flag to can use.


Thanks for the response, I tried to go with your idea with the flags, though I'm doing somwthing wrong here. Take a look:

if (CheckCol(PlayerLocation,rPortal1Loc) == true && PortalFlag1 == true){// if player collides AND the portal can be used, continue
 
  PortalFlag2 = false;  //set the destination portal to: cannot use
  PlayerLocation.x = rPortal2Loc.x;//teleport
  PlayerLocation.y = rPortal2Loc.y;//teleport
 
  while (CheckCol(PlayerLocation,rPortal2Loc) == true){  //while colliding with the portal
   PortalFlag2 == false;		 // keep it set to false
  }
   PortalFlag2 = true;		 // not colliding? set back to true
 
 
 

}
if (CheckCol(PlayerLocation,rPortal2Loc) == true && PortalFlag2 == true){ // if player collides AND the portal can be used, continue
 
  PortalFlag1 = false; //set the destination portal to: cannot use
  PlayerLocation.x = rPortal1Loc.x;//teleport
  PlayerLocation.y = rPortal1Loc.y;//teleport
  while (CheckCol(PlayerLocation,rPortal1Loc) == true){  //while colliding with the portal
   PortalFlag1 == false;		 // keep it set to false
  }
   PortalFlag1 = true;	    // not colliding? set back to true
 

 
}

To me it seems like it should work, but it crashes the game.

PARTNERS