| Reply | « Previous Thread | Next Thread » |
|
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? |
|
That depends on how you're encoding you're map and/or objects (the level data).
shmoove |
|
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 |
|
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 | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|