|
-
Aug 24th, 2001, 11:55 AM
#1
Thread Starter
Frenzied Member
Jump and Run Collision
Hi Everoyone
Well I made tilebased Jump and Run games, but I was never happy with the outcome.
I have a slight problem with the collsion detection. I always used to have a tile either be walkthrough or not. Now I want things like diagonal pathes and stuff like that.
So should I use masks for the tiles? Has anyone ever done a fast running program, that used masks for the collision detection?
Than I would need some good code for collision detection anyways, because my code always was a little messy. If anyone has a good sample please tell me.
Sanity is a full time job
Puh das war harter Stoff!
-
Aug 24th, 2001, 01:39 PM
#2
Good Ol' Platypus
At VoodooVB (http://voodoovb.thenexus.bc.ca/) there are a few tutorials that discuss the usage of fast rectangular, circular and vertex-based collision detection. I suggest you look into that.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 25th, 2001, 05:58 AM
#3
Thread Starter
Frenzied Member
I am having a look right now
thanks
Sanity is a full time job
Puh das war harter Stoff!
-
Aug 26th, 2001, 09:42 AM
#4
Frenzied Member
I'd use rectangular collision for the tiles, and circular collision for the sprites.
A good technique I saw in professional games that use rectangular collision for the tiles is that when the player collides with a wall only partially, he will be moved in that direction (the player will never be stuck in walls, instead he will slip):
Code:
The player collides with a wall, but only with his left side
---
XX
The game automatically moves him/her a bit to the right each frame, so he can pass :)
---
XX
This is a trick that players hardly notice (so most small games don't have this) and usually makes them happy with your game
-
Aug 26th, 2001, 09:54 AM
#5
Thread Starter
Frenzied Member
In the moment I am only using rectangular collision and I have that move thing implemented. I would have no Idea how to work without it.
Once the game get's little more interesting I will probably post it so you can see why I need to implement this.
But I still don't know how to implement slopes if I use the rectangular.
Sanity is a full time job
Puh das war harter Stoff!
-
Aug 26th, 2001, 10:36 AM
#6
Frenzied Member
Just use a big "If...ElseIf...ElseIf...End If" like I did 
Like this:
VB Code:
'If there's a wall in the top-left corner of where the player is moving to, and there isn't in the top-right corner of where the player is moving to...
If DetectCollision(NewPlayerX,NewPlayerY) = True And DetectCollision(NewPlayerX+PlayerWidth,NewPlayerY) = False Then
'Move a bit to the right. Also don't move up!
PlayerNewX = PlayerX + PlayerSpeed
PlayerNewY = PlayerY
End If
That's when the player presses the Up key and you set the NewPlayerX/Y with his new coords. You'll need to make the same thing if the top-right corner is blocked, for when both of the corners are blocked (the player can't move there), and when both of them are not blocked. You'll also have to repeat this for the other 4 directions.
I know it's hard, but with some paper and a pen you'll get there
-
Aug 26th, 2001, 11:49 AM
#7
Thread Starter
Frenzied Member
no I got all that long ago, but my problem is tiles that have slopes.
somethig like this:
_______
\
\______________/
I need collision with the tiles that have different slopes!! I probably have to use masks.
Sanity is a full time job
Puh das war harter Stoff!
-
Aug 26th, 2001, 02:34 PM
#8
Frenzied Member
Nope, masks is a bad idea - it's too slow and you can get the same results by using polygon collision detection
-
Aug 26th, 2001, 02:42 PM
#9
Thread Starter
Frenzied Member
I kind of doubt that the polygon collision detection would be more efficient on tiles, than masking.
Does Anyone know Jazz Jack Rabbit 2 I believe it uses masks.
Sanity is a full time job
Puh das war harter Stoff!
-
Aug 26th, 2001, 02:49 PM
#10
-
Aug 27th, 2001, 11:05 AM
#11
-
Aug 27th, 2001, 01:07 PM
#12
Thread Starter
Frenzied Member
Well yeah I will have a closer look into all of that.
Thanks
Sanity is a full time job
Puh das war harter Stoff!
-
Aug 28th, 2001, 10:01 AM
#13
Frenzied Member
-
Aug 28th, 2001, 12:58 PM
#14
Thread Starter
Frenzied Member
Well I said I will take a look into all of that and decide for the fastest version of course.
Sanity is a full time job
Puh das war harter Stoff!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|