The Mezunian

Die Positivität ist das Opium des Volkes, aber der Spott ist das Opium der Verrückten

Let’s Code a Crappy 2D Platformer Like Millions o’ Other People on the Internet & Lose Interest & Give Up Only a Few Months In, Part XVII

I already did this months ago, only I just found out it for some reason didn’t publish when I wanted it to.

Value Valhalla

You can probably guess that this is a parody o’ Super Mario Bros. coin heavens.

You’d be surprised what a pain ’twas to not just loop repeatedly, but to add that extra part after the 3rd loop with the diamond.

But fans o’ Pannekoek2012 will be excited ’bout one way it’s implemented — yes, that’s right: it involved parallel universes. No, this wasn’t as an intentional joke or reference; I actually experimented with having your character’s & the cloud’s positions revert back to the other edge, but couldn’t get it to work smoothly.

Thus, the way the loop actually works is that while you & the cloud you’re on keeps gaining X position, the Map class manipulates the rest o’ the level to give the illusion that it’s looping. The camera is changed so that it no longer stops @ the width o’ the map, but goes on fore’er, & the map code for giving block indexes to the block system changes so that it gives one relative to how it calculates what the left edge o’ the particular “current loop”, which is calculated based on the player’s position, rather than outputting invalid indices past the edge o’ the level. ( As a note, recall that I mentioned in the last post how the cart level required the horizontal edges o’ the screen to be even to making the cart not bump into blocks from 1 edge while on the other edge. I fixed that now. )

The sprites also had to be repositioned ( ‘cept for the main cloud platform sprite: it does loop back round if you let it go past the edge o’ the screen; but due to nuances for how it works, it has its own separate code for looping ). Said repositioning code only works if the sprites reset to their original position, for some reason. Luckily, the bees automatically do that, anyway, & the cloud block sprites can do so without any problem. ( Note: not only are the bouncy blocks sprites; so are the flat ones, to make it so their eyes follow you. Yes, I created extra work for myself just so I could make blocks watch your character. )

I should point out that this level theoretically works fine looping in the other direction, too ( though the diamond part’s only programmed to appear on the 3rd loop going rightward, e’en if going leftward from the 4th loop ). In the original version o’ this level, there was a 2nd cloud up top that went leftward. However, I felt it ruined the gimmick o’ this level, since it made looping horizontally unnecessary, since one could just go back & forth. Plus, it wasn’t all the useful, since you can reach close to the top already. Lastly, changing it to work with the extra diamond area made it impossible to keep the cloud platforms in sync. This impressive feat was the only reason I cared ’bout keeping the other cloud, & since it’s now gone, I see no reason to still want the cloud platform. I think the level works much better now.

Levels to come: a sewer level influenced by “Wet-Dry World” & a sky level where you’re a flying owl.

Download source code.

Believe it or not, I’m still working on this — just not doing anything productive or worthy showing.

¿Liked it? ¡Take a second to support this idiot on Patreon!
Posted in Boskeopolis Land, Programming