Author Topic: Issue with collision  (Read 1887 times)

Offline slythfox

  • Newbie
  • *
  • Posts: 2
Issue with collision
« on: March 05, 2009, 06:23:49 PM »
When I implemented collision from jnrdev #1, I was having some collision errors. Basically, there was a padding of 1px surrounding the character, and as a result, the character couldn't go between two tiles with a one tile gap.

I spent a lot of time figuring out what the problem was with my code. I found there is a +/- 1 added to the x or y position of the player after collision has been detected. This should be removed. Second, the while loop of the vertical and horizontal collision methods should be "<" not <="

I don't know why the jnrdev #1 Windows binary works fine... Did anyone else run into this issue?

Here's my code with the corrections if anyone wishes to see: (in character.cpp)
http://github.com/slythfox/platformer/tree/master

Offline Florian

  • Administrator
  • More Common Poster
  • *
  • Posts: 838
    • http://geeq.at
Re: Issue with collision
« Reply #1 on: March 10, 2009, 11:21:01 AM »
could be that i made a mistake while writing up the tutorial (oh how i loathe the +/-1 errors).

but super massive props for going through the tutorials in the first place (i always wondered if there's a single person on earth who did that).


so point made:
 i'm in the process of creating yet-another-jump-n-run (well... after pixelling is done, this time ressources first), so ... i might update jnrdev (as i forgot how to do collision detection yet-again).




to answer your question: i don't want to look at C++. ever. again. however i can tell you how things turn out once i re-implemented jnrdev #1 myself.

Offline formula1

  • Almost Regular
  • ***
  • Posts: 243
Re: Issue with collision
« Reply #2 on: March 10, 2009, 06:04:05 PM »
Quote from: "Florian"
to answer your question: i don't want to look at C++. ever. again. however i can tell you how things turn out once i re-implemented jnrdev #1 myself.

lol
:3
I want the wisest things to happen
If you like stuff. That stuff will always exsist.... IN YOUR MIND! OH SHNAP! UNLESS U FORGETZ IT! OR SHNAP! maybe...
Destryers Inc