Page 1 of 1

Walking on steep platforms

Posted: Tue Dec 26, 2017 6:38 pm
by Ralf
I'm asking out of curiosity as I read recently about some solution but I'm not revealing it yet as would like to learn the options;)

So how would you implement a platform game with steep, not horizontal platforms so that player walking on the platform moves not only left/right but also up/down ?

I suppose it could also apply to some stairs.

See a screenshot from Transformers to see what I mean
Image

Re: Walking on steep platforms

Posted: Tue Dec 26, 2017 6:53 pm
by R-Tape
I'd be interested in various solutions too, over a year ago I spent time thinking about this while trying to get binman's Nirvana Donkey Kong graphics into a working demo.

The solution I thought of is not very sophisticated - just use a higher resolution block map for collision (so one step = one block). If each step is 2 pixels high then it's 4 blocks per char in the map. Single pixels obviously twice that and we get into a ridiculous waste of memory. Okay for DK though.

Off the top of my head I wonder about a collision map with a block type per step height within a char (or just a block type that says sprite is on a step), then you can have a normal map resolution. Not sure if that makes sense, would need to have a play.

Re: Walking on steep platforms

Posted: Tue Dec 26, 2017 7:54 pm
by Hikaru
Well, how about something like this. Let's say your maps are composed of regular 16x16 tiles. Reserve a portion of tile codes for sloped backgrounds. If a tile that is stepped on falls in that range, look up an additional offset to apply to the object's Y coordinate. This should be based on its X coordinate MOD 16. For instance, this will give the 45 degree slope effect: ObjectY += ObjectX & 15. A slope that is half as steep (22,5 degrees?) would be represented by two tiles, the first one would have ObjectY += (ObjectX & 15) / 2, the second oneObjectY += (ObjectX & 15) / 2 + 8. For the opposite direction, invert the value of ObjectX.

Re: Walking on steep platforms

Posted: Wed Dec 27, 2017 2:05 am
by AndyC
By the time you get that sophisticated, I'd tend towards separate attributes for tiles rather than relying on range numbers alone - partly because it makes adding/removing things easier but also because you start to want overlapping ranges (flat, sloped, flat + icy, sloped + icy etc.) but the principle beyond that is still reasonably sound. Of course it depends on how arbitrary your slopes need to be, in many cases you may well get away with just 45 and 22.5 degree slopes that you can just carefully combine to get a good enough approximation.

Re: Walking on steep platforms

Posted: Wed Dec 27, 2017 6:54 am
by Rorthron
R-Tape wrote: Tue Dec 26, 2017 6:53 pm I'd be interested in various solutions too, over a year ago I spent time thinking about this while trying to get binman's Nirvana Donkey Kong graphics into a working demo.
Which graphics do you mean? I am aware of Einar's:

https://www.worldofspectrum.org/forums/ ... ent_836298

And Mick Farrow's (not multicolour):

https://sites.google.com/site/zxgraph/h ... onkey-kong

And this set (also not multicolour):

http://zxart.ee/eng/authors/z/zombi2

In any case, please do this! I'd love to see a good version of Donkey Kong on the Spectrum.

Re: Walking on steep platforms

Posted: Wed Dec 27, 2017 11:05 am
by Ralf
Okay, here is the solution that I saw on some Amiga site:

You have two types of tiles: normal and sloped. Let's say tiles number 0-80 are normal and 81-100 are sloped or something like that.

For sloped tiles you keep a table of heights for each pixel column. If your tile is 16x16 pixels, your table will contain 16 heights

Let's take a 16x16 tile from Transformers. I didn't check how this game exactly works but let's assume it has 16x16 pixels tiles:

Image

The table for this tile would be [1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4]

So when player stands on sloped tile find his central pixel column: (playerX + playerWidth)/2

Then check data from the height table for this column and add found pixel offset to playerY.

Probably some implementations will differ in details but I hope you get the idea.


Hikaru, I suppose you are trying to do something similar, just without the table, using some logic to calculate the heights instead.

Re: Walking on steep platforms

Posted: Wed Dec 27, 2017 4:31 pm
by Hikaru
Nice, and makes sense in hindsight. :) You can practically do any sort of uneven terrain this way, let alone regular slopes at any angle.

Re: Walking on steep platforms

Posted: Wed Dec 27, 2017 5:58 pm
by AndyC
Yeah, tidy solution. And it should be relatively simple to share height tables between multiple tiles, which will keep memory usage down.

Re: Walking on steep platforms

Posted: Thu Dec 28, 2017 1:24 am
by HexTank
Yep, as already said. Normal way is to have tile meta data with heights on X.

Re: Walking on steep platforms

Posted: Fri Dec 29, 2017 2:28 pm
by Joefish
To make things easier you could use wider tiles, e.g. 32x16 so a slope goes up one whole tile for each whole tile along.