The Mezunian

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

Boskeopolis Land: 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 LIV: Cometropolis

Cometropolis

This level started with just the idea o’ a neon palette, the implementation o’ which probably did take the bulk o’ the time I spent on this level. The “palette changes” as they seem to be in the actual game use completely different coding, bending this game’s flimsy ’scuse for a palette system e’en farther. Unlike ol’ consoles & computers, wherein changing palettes was much quicker than changing tiles that many ol’ games would cycle palettes to create the illusion o’ animation, changing the palette in this game requires regenerating textures, which is much slower than just animating tiles. Theoretically it’d be possible to do it rather quickly using shaders; howe’er, SDL doesn’t allow shaders, & it’s much too late in development to switch o’er to the much mo’ complex & much less intuitive OpenGL. What I did do to create the illusion o’ a cycling palette is take advantage o’ 2 caveats to this problem: 1. I can render a rectangle o’ any color that covers the whole screen in no time; 2. SDL allows me to apply the equivalent to Photoshop’s “multiply” blending mode to textures, which, when used with a white & black image makes whate’er is ’hind show through the white while still concealing what’s ’hind the black.1 Thus, I just set whate’er palette entries I want to show the shifting rainbow color ( which are dark gray & black ) to white while everything else is black.

I had originally planned to use the city theme for this palette, since I felt the city would look nice in neon, but since I had all 4 city slots filled, I ’stead considered making a space level, since that theme has the fewest slots filled & it would fit there, too. I think I played with the idea o’ focusing on dodging horizontally-moving sparks on wire or something; howe’er, none o’ this felt fun, so I shelved it for a while. I don’t remember where my mind went from there, but as some point I came up with the idea o’ dodging falling stars, — probably from the 1 memorable level from New Super Mario Bros., the 1 wherein lava rocks fall from the sky — & then decided to move “Sleet Streets” to the “domestic” theme ( since it’s mo’ ’bout homes than the city ) & make this a city level. Then, finally, I decided to make this a space level ’gain, despite keeping the city graphics, & would just say this was a city on ’nother planet. It’s not as if I haven’t been blending themes together & sticking them into whate’er slot was most convenient, & if any theme deserved to dip into other themes’ slots, it would be the city theme.

The falling stars are just a bit mo’ complicated than just randomly placing them round. To ensure the player could not outrun stars in either direction & that there was a steady supply, I made it so that every time it generated a falling star it not only placed it on the current screen, but also on the next & previous. & to decrease the chance so’ stars congregating in 1 area I made it so that it had to spawn the next star a few blocks ’way from where the last spawned.

Recording the time & gem scores were surprisingly smoothly. I made the time score somewhat lenient to make up for the delays falling stars can sometimes force on the player when they form walls. E’en then, I still couldn’t help myself from just running thru stars when I knew a heart was close ’head, which I try not to do, since I want these challenges to be possible without taking any hits. Shockingly, I was able to record the gem score on my 1st try, which I always found very hard to get during practice. Then ’gain, here you can see me moving as carefully as I can. I should point out that this will definitely replace “Stop & Go Space Station” as the 4th-cycle space level, pushing “Stop & Go Space Station” down to the 3rd cycle, as it is much mo’ difficult.

Learn mo’ ’bout this project @ boskeopolis-land.com.

“I will multiply thy bugs as the stars o’ the heaven…”.

Posted in Boskeopolis Land, Programming

Boskeopolis Land: 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 LIII: Don’t Touch Me, I’m a Real Live Wire

Don’t Touch Me, I’m a Real Live Wire

This level’s main gimmick, electric walls that could only be deactivated with switches in ’nother area, forcing the player to race from the switch to the electric walls, was originally going to be a space level, but I felt it would be better to use this mechanic to spice up an attic maze level idea I’d been toying with, since I feel exploring a maze just to find a keycane or collect a certain # o’ gems had already been done ’nough in this game. This gimmick also helps set this level apart from the attic levels in Cool Spot whence this level takes perhaps a bit too much inspiration otherwise.

I’m mixed on the size o’ this level. I insisted on constructing the maze so that all space is used for something, with no large chunks o’ solid wood ( which the Cool Spot levels also do ). While I feel like I did a rather good job o’ that, I do worry that the level might be too big. Then ’gain, a maze needs to be large ’nough to get lost in & have plenty o’ dead ends to offer any challenge, & players who know their way will be able to beat the level within less than a minute. Still, part o’ me can’t help feeling like some pieces — specially the lower left section — feel like filler that exists just to collect gems.

I like the proportions ’tween the pre-1st-wall & after-1st-wall sections, with the early section being much smaller & having fewer dead ends, acting as a subtle training wheels before the boost in trickiness for the 2nd half. This 2nd half immediately starts with 1-way sections down. If you fail to make it to the 2nd electric wall before the switch runs out, you have to go up a longer path round where you went do to fall back down to where the switches are.

If you’re wondering why there’s switch blocks right after the 1st electric wall with switches on either side, this was just a way to force players to reset the switch after the 1st electric wall. E’en with the warning telling you outright that the switches are timed, I can imagine players rushing & forgetting to reset the switch on their own, which will almost guarantee that the switch, which would be getting low just after passing the 1st electric wall, would turn off long before the player gets close to the 2nd electric wall, which felt too much like a frustrating gotcha to let stand.

The time score is so easy I was able to do it 1st try when recording. I intentionally made it less demanding, since players needed to remember the path they needed to take & ne’er take wrong turns to have a chance to make it in time. The gem score was much harder for me & required an embarrassing # o’ tries. As the video shows, this level has the largest gem score o’ any level so far, requiring 40,000₧, which is 400 individual gems. If you pay close attention to the video, you’ll see that there are many gems hidden ’hind the foreground pipes ( 1 o’ the many elements I ripped off from Cool Spot’s attic levels ). Howe’er, there are so many gems in this level, I doubt you need to collect any. I didn’t go too out o’ my way to collect them & e’en flub up collecting the large star formation o’ gems in the top area, falling down a 1-way area before collecting most o’ them. Howe’er, by that point I’d already reached the required 40,000₧.

I was planning on having this released in September, but was delayed by major programming renovations. Graphical layering glitches in this level, specially when someone dies, was the last straw for this game’s unbelievably naïve layering system inspired by Super Mario World under the mistaken belief that code aimed for a 90s game console would work well for modern computer architectures. This scheme used dumb boolean flags on all blocks & sprites & looping o’er all blocks & sprites twice ’tween map backgrounds & foregrounds, 1st blocks & then sprites without priority, & then blocks & then sprites with priority. To draw sprites ’bove the foreground, I resorted to some hacky virtual function that did nothing for the vast majority o’ sprites.

I completely o’erhauled all this, removing all traces o’ “priority” flags. I replaced this with 171 layers o’ lists o’ generic renderable objects, which can render blocks, sprites, or map layers, which are simply all looped o’er every frame. This allows blocks, sprites, & map layers to be on any layer & to be easily moved to any other layer.

To better fit this new mo’ generic system, I also o’erhauled how maps & level files are read: explicit “backgrounds” & “foregrounds” are replaced with generic “layers”, which can be set on any o’ the 17 layers ( tho to make it convenient for me, they default to the default “background” layer & their “layer” can be set to “foreground”, which will put it on the default “foreground” layer ). I also changed the map tile layers to use generic types like “Blocks”, “Texture”, “BlocksTexture”, “Tiles”, & “Fade”, followed by a # that represents which layer it should go on or the strings “BG”, “BG1”, “BG2”, “FG”, “FG1”, “FG2” to simply put it into those default layers so I don’t have to remember their #s. I also changed it so that the BlocksSystem has multiple blocks lists to accommodate this mo’ generic scheme. Since the priority flag is completely ignored now, blocks that should be drawn ’bove the player should be put on a 2nd “Blocks” layer set to “FG”. This new scheme also allows for mo’ opportunities for rendering optimizations. For instance, both block & tile layers ( tile layers are drawn but cannot be interacted with ) can be made textures, wherein they are all combined into a single texture, simplifying them into a single draw call @ the cost o’ not being able to be animated or affected by level events.

There are also some subtler changes I made. For instance, I fixed a glitch that may have seeped into earlier videos wherein the “GAME START” text on the title screen would randomly spread onto 1 or 2 lines. ’Ventually I found out this was caused by a mistake in the look-’head code for the autoline code that would read 1 character beyond the end o’ the list o’ characters, which would be random data. In hindsight, the fact that this clearly involved randomness should’ve clued me in that there was garbage data being read; for some reason, I was stuck for a while on the hypothesis o’ a rounding error in some division or float-to-int conversion. The fact that this only e’er seemed to affect the “GAME START” text & ne’er caused segmentation faults, despite this error technically occurring everywhere there is text, astounds me.

A mo’ noticeable change is that the diamond has been replaced by a spinning card ( I think I also fixed a bug that would cause already-collected cards to still appear when re-entering a level & would only disappear if the player went near them due to optimizations in the block-collision code ), which was a change I had planned for a while, but for some reason had trouble getting the animation right before. Someday I plan on implementing a way to view each level’s card from the o’erworld menu.

Learn mo’ ’bout Boskeopolis Land @ boskeopolis-land.com

Look @ this project’s eldritch code

Posted in Boskeopolis Land, Programming