You Are Here:

Community: Developer Discussion Boards

#1 Old Collision detection between the level and Character - 2004-01-18, 15:47

Join Date: Aug 2003
Posts: 182
Location: Eire
Woody_FX
Offline
Regular Contributor
Hi I’m working on a Side scrolling game at the moment.

I was wondering how would you handle collision detection between the characters in the game and the actual level objects.

Such as platforms and boxes etc?
Reply With Quote

#2 Old 2004-01-18, 16:51

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
That depends on how you're encoding you're map and/or objects (the level data).

shmoove
Reply With Quote

#3 Old 2004-01-18, 18:47

Join Date: Aug 2003
Posts: 182
Location: Eire
Woody_FX
Offline
Regular Contributor
Thats what i'd like to know.

What way would you represent everything. Then how would you perform collison detection when a character walks off a platform and falls to another platform.

That kind of thing.

I know you can use bounding boxes to detect when 2 charcters hit each other.

Thanks
Reply With Quote

#4 Old 2004-01-18, 20:22

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
Well, there is no perfect way. It depends on the game. But for a simple platform game, your map will probably be a 2-dimensional array, where each entry represents a type of "terrain" on that spot. For example 0 means it's clear, 1 is floor, 2 is a box, etc. Then you just have to plug in the position of your character (probably scaled down, since you won't map every pixel of the level but every, let's say... 8 pixels) into that array to see if it is something that it can fo through (like 0 for nothing, but you might have other "passable" objects). That would take care of all the static stuff. If you wan't to have "moving scenery" then you'll have to think of a slightly different approach for them.
I'm sure there are more than a few open source platform games (not necesarilly J2ME games, or even Java games, since you're interested in the concepts) from where you can borrow some ideas.

shmoove
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia