|
This thread is locked; no one can reply to it. |
1
2
|
Platformer terrain styles |
Elverion
Member #6,239
September 2005
|
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. 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? -- |
Archon
Member #4,195
January 2004
|
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
|
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
|
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"? -- |
Archon
Member #4,195
January 2004
|
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. |
Epsi
Member #5,731
April 2005
|
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." |
Wilson Saunders
Member #5,872
May 2005
|
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. ________________________________________________ |
Elverion
Member #6,239
September 2005
|
{"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"} -- |
Epsi
Member #5,731
April 2005
|
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." |
OICW
Member #4,069
November 2003
|
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] |
Elverion
Member #6,239
September 2005
|
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? -- |
CGamesPlay
Member #2,559
July 2002
|
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... -- Ryan Patterson - <http://cgamesplay.com/> |
OICW
Member #4,069
November 2003
|
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] |
Elverion
Member #6,239
September 2005
|
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. -- |
Thomas Harte
Member #33
April 2000
|
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. [My site] [Tetrominoes] |
Elverion
Member #6,239
September 2005
|
Quote:
Quote:
Let me try again. 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. -- |
Thomas Harte
Member #33
April 2000
|
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"} [My site] [Tetrominoes] |
X-G
Member #856
December 2000
|
Why would that be a problem anyway? -- |
Elverion
Member #6,239
September 2005
|
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? -- |
Matt Weir
Member #7,476
July 2006
|
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
|
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. -- |
X-G
Member #856
December 2000
|
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. -- |
Tobias Dammers
Member #2,604
August 2002
|
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. --- |
Elverion
Member #6,239
September 2005
|
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? -- |
|
1
2
|