Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Platformer terrain styles

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Platformer terrain styles
Elverion
Member #6,239
September 2005
avatar

As far as I know, there are two basic platformer terrain styles: tiled and polygon. Tile based platformers usually feel very "square" and unnatural, so polygonal might be the way to go.

I liked the way Gunster felt. You could smoothly run over small hills and bumps, rather than get snagged on everything.
{"name":"591309","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/b\/8b8290be5fb358992c69bf2be9eb3d39.jpg","w":800,"h":600,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/b\/8b8290be5fb358992c69bf2be9eb3d39"}591309

More precisely, how do these terrains work? Using line segments with an overlaying bitmap would be efficient, but difficult to construct the maps. On the other hand, using masking sprites would be less efficient, but much easier to program and design maps.

As attached, you can see the problems with the segmented polygons for terrain. To have any decent collision, each chunk of land would need many segments...leading to difficult times making the maps, and "attaching" the polygon to the sprite within the map would be no easy task, either. Also, walking up inclines with masking tiles wouldn't be very effective or smooth. Actually, this could be difficult even with polygons. How would you find out which polygon you are standing on if there is the possibility for floating islands?

Any suggestions for overcoming these problems? Are there, perhaps, other terrain styles that could be used?

--
SolarStrike Software - MicroMacro home - Automation software.

Archon
Member #4,195
January 2004
avatar

Quote:

More precisely, how do these terrains work?

You could have masked sprites for it, but instead of one for each polygon, you could make a 'spriteset' (comes from tileset) of sprites that can be placed randomly within the polygons and many would overlap the collision lines.

kentl
Member #2,905
November 2002

Well your screenshot could have been from a tile based game as well. In that case they would have to be a clever and work hard to get a natural feeling. I would use masked sprites, it got to be efficient enough right?

Archon
Member #4,195
January 2004
avatar

Quote:

Actually, this could be difficult even with polygons. How would you find out which polygon you are standing on if there is the possibility for floating islands?

Just like tiles. You'll need to make list of references to the lines and find out which one is below you by getting the value of the 'y' which will most likely involve interpolating between x1y1 and x2y2.

Elverion
Member #6,239
September 2005
avatar

Quote:

You'll need to make list of references to the lines and find out which one is below you by getting the value of the 'y' which will most likely involve interpolating between x1y1 and x2y2.

So...a vector of line segments, sort by height, and start at the bottom, working your way up towards the player, using the last "collision"?

--
SolarStrike Software - MicroMacro home - Automation software.

Archon
Member #4,195
January 2004
avatar

Quote:

So...a vector of line segments, sort by height, and start at the bottom, working your way up towards the player, using the last "collision"?

Not necessarily sorted by height since you'd want it to be robust in case there are long vertical falls.

What I was thinking of doing was having 'tiles' of lists of references to lines/polygons that touch these 'proxy tiles' which should allow you to find the polygons nearest to your players to cut down the number you need to render and collide with.
Read here.

Epsi
Member #5,731
April 2005
avatar

Check the game "Soldat", especially it's map editor, which is using polygons.

Soldat only use tiled textures and some sceneries on top of the polygons (like grass) so it's not as good looking as your screen, but it's still very nice.

I've learned a lot just by using Soldat's editor.

___________________________________

piccolo: "soon all new 2d alegro games will be better. after i finsh my MMRPG. my game will serve as a code reference. so you can understand and grab code from."
piccolo: "just wait until my invetion comes out its going to take the wii to the next leave of game play. it will run sony and microsoft out of busness if i dont let them use it aswell."

Wilson Saunders
Member #5,872
May 2005
avatar

Polygons are not too hard for platformars. I used a ghetto Polygon ground system in the last speed hack. For the most part they are not even Polygons, they are just collision boxes that have slanted lines. You have to do a bit more math but I think some one who took high school geometry could figure it out. No sin(), cos(), or sqrt() needed.

________________________________________________
Play my games at http://monkeydev.com

Elverion
Member #6,239
September 2005
avatar

{"name":"591311","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/b\/7b12a825e0f167a8670b0d543846d684.gif","w":672,"h":282,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/b\/7b12a825e0f167a8670b0d543846d684"}591311
That's supposed to be ground. It's ugly. And the Allegro polygon rendering functions seem too slow to be using excessively. I'll be looking at Soldat, particularly the map maker.

--
SolarStrike Software - MicroMacro home - Automation software.

Epsi
Member #5,731
April 2005
avatar

Quote:

That's supposed to be ground. It's ugly. And the Allegro polygon rendering functions seem too slow to be using excessively. I'll be looking at Soldat, particularly the map maker.

If you choose the polygon way I would recommend using OpenLayer instead of pure allegro. It will be faster and easier to do.

btw Soldat use only Triangles to create its map, with lightning+color on each vertices.

___________________________________

piccolo: "soon all new 2d alegro games will be better. after i finsh my MMRPG. my game will serve as a code reference. so you can understand and grab code from."
piccolo: "just wait until my invetion comes out its going to take the wii to the next leave of game play. it will run sony and microsoft out of busness if i dont let them use it aswell."

OICW
Member #4,069
November 2003
avatar

Epsi: yes, and it must a pain in the butt to make rectangular shape if you want.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Elverion
Member #6,239
September 2005
avatar

Quote:

If you choose the polygon way I would recommend using OpenLayer instead of pure allegro. It will be faster and easier to do.

I think you are right. I was considering OpenLayer, but have not learned the first thing about it yet. A lot of people seem to get confused or misunderstand how to do many things with OpenLayer (There are a lot of "Why doesn't this work!?[OpenLayer]" threads), so I was hesitant. On the other hand, I do like it's capabilities and will need the hardware acceleration.

I don't mean to de-rail my own thread...but...OpenLayer contains many collision detection functions. Do any of these fill the "walking up an incline" need, or would I still implement that myself?

--
SolarStrike Software - MicroMacro home - Automation software.

CGamesPlay
Member #2,559
July 2002
avatar

Quote:

Epsi: yes, and it must a pain in the butt to make rectangular shape if you want.

???

Making a rectangle out of triangles isn't exactly one of mathematics hardest problems...

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

OICW
Member #4,069
November 2003
avatar

Well but matchin them together so you can't see the difference in the texture can be. But I should take a closer look at the latest Soldat map maker.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Elverion
Member #6,239
September 2005
avatar

Quote:

Well but matchin them together so you can't see the difference in the texture can be

I suppose this can be done fairly easily by calculating world coordinates and using them in the offset for the texture. And, yes, the newest Soldat map maker does, in fact, do this automatically.

--
SolarStrike Software - MicroMacro home - Automation software.

Thomas Harte
Member #33
April 2000
avatar

Quote:

To have any decent collision, each chunk of land would need many segments...

I don't understand why you say this.

Quote:

the Allegro polygon rendering functions seem too slow to be using excessively

The "will be incorporated into the distribution one day" new Allegro demo game (completed almost 2 years ago) draws using the ordinary polygon routines (not the textured/3d/whatever ones) and purposely sets and shifts a texture so that it moves with the ground. That's not so bad.

Elverion
Member #6,239
September 2005
avatar

Quote:

Quote:
To have any decent collision, each chunk of land would need many segments...
I don't understand why you say this.

Let me try again.
{"name":"591313","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/f\/0f0a4c0b50df3b8b4076f95263785eed.gif","w":561,"h":134,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/f\/0f0a4c0b50df3b8b4076f95263785eed"}591313

Image 1 shows where very few segments were used. A lot of the area around the edges would, then, not cause a collision, and it would feel as though you are walking through the ground much of the time. Image 2 shows where many segments were used to more properly fill the collision area of the land.

--
SolarStrike Software - MicroMacro home - Automation software.

Thomas Harte
Member #33
April 2000
avatar

Oh, I was being a thickie. The new Allegro demo game only uses "segments" in that the entire level is built of polygons, full stop. Look:

{"name":"DemoGame.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/c\/5c2001210e622cbcc3223606fc1a4894.png","w":720,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/c\/5c2001210e622cbcc3223606fc1a4894"}DemoGame.png

X-G
Member #856
December 2000
avatar

Why would that be a problem anyway?

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Elverion
Member #6,239
September 2005
avatar

Quote:

Why would that be a problem anyway?

It isn't...until you have many polygons with high vertex counts. I plan on partitioning the maps to minimize collision detection, though.

So after having played with OpenLayer, I feel like stabbing myself in the eyes. The lack of textured polygon drawing was quite irritating. First it was supported, now it isn't...so I was forced to try using the code Flad previously posted that works in a cookie-cutter fashion. No go (some of the functionality used was not in the version I had). So onto SVN...Well, it didn't want to detect freetype, but after putting up a mild fight it finally gave in only to give me plenty of errors. I couldn't be bothered to fix all the source files, as who knows what problem would haunt me next.

Flad, don't take what I just said the wrong way. I think OL is great. I just really wish it would support even basic texture mapping to shapes without much fuss.

But, the original plan was to have the graphics(tiles and bitmap chunks of land) separate from the collision polygons anyways. I think it would produce a much softer, non-square feel, and give more control. So, map editing would be done similar to the previous image I posted of a land chunk with it's separate collision poly. Does this sound like a viable solution?

--
SolarStrike Software - MicroMacro home - Automation software.

Matt Weir
Member #7,476
July 2006
avatar

Quote:

I couldn't be bothered to fix all the source files, as who knows what problem would haunt me next.

Sounds familiar to my experiences... I got there in the end so if you want the latest compiled Openlayer SVN lib for MSVC8 I can just send you it (I have no idea what IDE you use though so this may not even apply). When it comes to actual usage I found learning not too hard especially if your used to C++. :)

Matt.

Elverion
Member #6,239
September 2005
avatar

Quote:

I got there in the end so if you want the latest compiled Openlayer SVN lib for MSVC8 I can just send you it

I'll gladly take it, but I do use Dev-CPP. Who knows, maybe somebody else would want it as well.

--
SolarStrike Software - MicroMacro home - Automation software.

X-G
Member #856
December 2000
avatar

Quote:

It isn't...until you have many polygons with high vertex counts. I plan on partitioning the maps to minimize collision detection, though.

It isn't when you have a lot of them either. Space partitioning will drastically reduce the need to do collision detection, to the point where you can probably comfortably have hundreds of these things with no great expenditure of cycles. For instance, a simple way might be to calculate a bounding box for each such chunk of land, and do a preliminary (and faster) test for that bounding box at first and skip the rest of the checks if that fails. And/or you can go with some other partitioning scheme such as quadtrees or grids.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Tobias Dammers
Member #2,604
August 2002
avatar

If all else fails, you can divide your whole scene into a tile grid, and split all polygon outlines into pieces that fit into a single tile. If your character is not larger than one tile, you never need to check more than 4 tiles, and it is very unlikely that there are more than maybe 5 line segments inside a given tile (typically no more than 2 even). IIRC, Sonic The Hedgehog does something like this.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Elverion
Member #6,239
September 2005
avatar

I was considering splitting the map up into a grid, and each sector would be a list of polygons that are contained within or touch that part of the grid.

Onto movement now...Theres basically two ways I can do it. 1) When the character is on a polygon and moving across the top of it, use sin/cos to calculate the new position along the segment they are currently standing on and move to it, and 2)if the character is not colliding with a polygon, let gravity take effect. Otherwise, move the character left/right, and possibly up a few pixels to prevent them from walking through the ground when going up an incline. Which is the preferable method?

--
SolarStrike Software - MicroMacro home - Automation software.

 1   2 


Go to: