## Walking on steep platforms

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

### Walking on steep platforms

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

R-Tape
Posts: 1603
Joined: Thu Nov 09, 2017 11:46 am

### Re: Walking on steep platforms

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
Microbot
Posts: 100
Joined: Mon Nov 13, 2017 1:42 pm
Location: Russia
Contact:

### Re: Walking on steep platforms

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
Inactive account

AndyC
Microbot
Posts: 169
Joined: Mon Nov 13, 2017 5:12 am

### Re: Walking on steep platforms

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

Rorthron
Manic Miner
Posts: 586
Joined: Sun Nov 12, 2017 10:35 pm

### Re: Walking on steep platforms

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):

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: 837
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

### Re: Walking on steep platforms

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:

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
Microbot
Posts: 100
Joined: Mon Nov 13, 2017 1:42 pm
Location: Russia
Contact:

### Re: Walking on steep platforms

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
Inactive account

AndyC
Microbot
Posts: 169
Joined: Mon Nov 13, 2017 5:12 am

### Re: Walking on steep platforms

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

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

Joefish
Manic Miner
Posts: 300
Joined: Tue Nov 14, 2017 10:26 am

### Re: Walking on steep platforms

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