Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi I am making a 2d scrolling beat em up, I am working on the collision with obstacles like drums and platforms.

So far I have the player jumping and falling from platforms but having problem stopping the player when colliding with the left and right side of the platform.

For each player you can assign a bounding box (rect) around player which I use to do the collision. The bounding box position is updated that of the player.

At the moment when I do the collision it always moves the player too far when hitting the platform from the right side. Now when my player looks left I have to offset the bounding box more to the left as the player sprite is mirrored left, which I think where the problem resides.

Also issue happens with obstacles with same width.

I was wondering if anyone can look at my code (full source: https://github.com/lodossDev/gameengine), please don't laugh :(. The main part to look at is the CollisionManager.cs and its checkbounds method lines 220-228.

Project is done in mono game. To control player user arrow keys, space bar = jump, a = attack, k = drum3 move left, l = drum3 move right

share|improve this question
    
I would recommend posting your code on github or bitbucket (or a similar service). With either of those, we can browse your source without having to download anything (and risk our machines). Better yet, include the relevant bits of code in your question so there is no need for an external service. :) – Cypher Jan 28 at 23:06
    
moved to github, I think by try running the game you will get a better understanding of my problem :) – user10262 Jan 28 at 23:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.