Walking on steep platforms

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
Ralf
Manic Miner
Posts: 213
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Walking on steep platforms

Post by Ralf » Tue Dec 26, 2017 6:38 pm

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
0 x

User avatar
R-Tape
Site Admin
Posts: 494
Joined: Thu Nov 09, 2017 11:46 am

Re: Walking on steep platforms

Post by R-Tape » 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.

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.
0 x

Hikaru
Dizzy
Posts: 89
Joined: Mon Nov 13, 2017 1:42 pm
Location: Russia
Contact:

Re: Walking on steep platforms

Post by Hikaru » Tue Dec 26, 2017 7:54 pm

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.
0 x

AndyC
Berk
Posts: 46
Joined: Mon Nov 13, 2017 5:12 am

Re: Walking on steep platforms

Post by AndyC » Wed Dec 27, 2017 2:05 am

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.
0 x

User avatar
Rorthron
Site Admin
Posts: 215
Joined: Sun Nov 12, 2017 10:35 pm

Re: Walking on steep platforms

Post by Rorthron » Wed Dec 27, 2017 6:54 am

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.
0 x

Ralf
Manic Miner
Posts: 213
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: Walking on steep platforms

Post by Ralf » Wed Dec 27, 2017 11:05 am

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.
1 x

Hikaru
Dizzy
Posts: 89
Joined: Mon Nov 13, 2017 1:42 pm
Location: Russia
Contact:

Re: Walking on steep platforms

Post by Hikaru » Wed Dec 27, 2017 4:31 pm

Nice, and makes sense in hindsight. :) You can practically do any sort of uneven terrain this way, let alone regular slopes at any angle.
0 x

AndyC
Berk
Posts: 46
Joined: Mon Nov 13, 2017 5:12 am

Re: Walking on steep platforms

Post by AndyC » Wed Dec 27, 2017 5:58 pm

Yeah, tidy solution. And it should be relatively simple to share height tables between multiple tiles, which will keep memory usage down.
0 x

HexTank
Berk
Posts: 16
Joined: Sun Nov 12, 2017 9:11 pm

Re: Walking on steep platforms

Post by HexTank » Thu Dec 28, 2017 1:24 am

Yep, as already said. Normal way is to have tile meta data with heights on X.
0 x

Joefish
Dizzy
Posts: 83
Joined: Tue Nov 14, 2017 10:26 am

Re: Walking on steep platforms

Post by Joefish » Fri Dec 29, 2017 2:28 pm

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.
0 x

Post Reply