Jump to content

  • Log In with Google      Sign In   
  • Create Account

0026sd

Member Since 20 Sep 2012
Offline Last Active Jun 22 2016 08:05 AM

Posts I've Made

In Topic: Help With 2D Collision (Sticky Wall Sliding)

10 June 2016 - 08:26 AM

When you loop through your list of tiles, you use localBoundsRect against each tile. You move the location of the player but don't update the value of localBoundsRect. If your player intersects with two blocks then the overlap is corrected for each block moving the player twice as far as needed. I would recommend setting the position of the player relative to localBoundsRect using the depth as an offset. You can repeat that multiple times without any negative side effects.

 

Updated JS FIDDLEhttps://jsfiddle.net/L7an0c1g/3/

 

OK, so I've applied the changes you suggested and it works except for one thing. The ELSE portion of my IF statement, checking intersection depths beginning on line 203, was intending to correct the player's position if the depth on both axes were the same (hit a corner). When I set my position x,y to the localBoundsRect + depth, it stops the player when sliding on a wall. I think it's because the player is hitting the corner of the tile it's moving into and correcting both the x and the y, stopping him.

 

Right now, after commenting out the else block, if you press W + A simultaneously, the player should pass through the corner tile and stop when it is fully in that tile. Uncommenting the else block will fix this but cause the issue mentioned above (sticky wall sliding).

 

I have read that this is a common issue with corners and maybe it just comes down to level design to minimize that from happening, but if you have any thoughts on how to correct this it would be greatly appreciated.

 

Thanks!


In Topic: Help With 2D Collision (Sticky Wall Sliding)

09 June 2016 - 08:53 PM

When you loop through your list of tiles, you use localBoundsRect against each tile. You move the location of the player but don't update the value of localBoundsRect. If your player intersects with two blocks then the overlap is corrected for each block moving the player twice as far as needed. I would recommend setting the position of the player relative to localBoundsRect using the depth as an offset. You can repeat that multiple times without any negative side effects.

 

Thank you for your reply!! Sounds like it's exactly what my problem is - I'll give it a try tomorrow and let you know how it went!


In Topic: SFML Frame Per Second feedback

31 October 2012 - 11:12 AM

What is the cpu % if you don't make the FPS call in your loop?


I believe it's around 3% or so..

In Topic: SFML Frame Per Second feedback

31 October 2012 - 10:18 AM

I'm bascially just wondering if there's any way to optimize the performance as it sometimes eats up more CPU than I would have thought it should

What amount of CPU usage were you expecting, and why? Generally, it is a good thing that no one tries to pre-emptively throttle your program - that way when you need to use the maximum available system resources you can (more or less). The OS is usually happy for your game to soak up any remaining CPU time. If your game knows that it doesn't need to use all the CPU, it can tell the OS this by issuing blocking calls.

I'm not overly familar with SFML, but some places to start include:
  • SetFramerateLimit - does reducing this value to 60 change anything?
  • Have you tried UseVerticalSync()?


Reducing the value to 60 doesn't change much in terms of CPU usage and I have used vertical sync with the same result.

The amount of CPU it's using is a similar amount to the amount that World of Warcraft runs on the same computer!! My CPU meter basically goes from 0% to 12-17%.

Anyway, if it's not something to worry too much about then I won't. I'm still new to low level programming and am trying to learn best practices.

thanks for you feedback.

In Topic: Games with menus

21 September 2012 - 05:26 AM

Thank you both for your insight! This is excalty what I'm looking for!

PARTNERS