The Mezunian

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

GBC Tribute: Pokémon Special Pikachu Edition ( Yellow )

I’ve already written most o’ what I have to say ‘bout the 1st generation games in my rambling post on the Pokémon main game series in general, so this post will be brief.

What I want to highlight is that part o’ this game that most pertains to the Game Boy Color: its peculiar color palettes. Though Game Boy Color games are capable o’ handling multiple palettes @ the same time, Pokémon Yellow uses the same palette system that the Super Game Boy versions o’ Red & Blue did: only 1 monochrome palette @ a time for the o’erworld, but which changes in different places, usually to reflect the place you’re in. Wild routes are green, while towns each have their own palette, usually similar to the town name — Viridian town is a green like viridian, Celedon City is a greenish-gray like celedon, Cerulean City is cerulean, & so on. Other than Pallet, which isn’t a color, but just a different spelling for the word “palette”, Vermilion City is the only exception for variety’s sake, as vermilion is actually just a synonym for cinnabar, which is the name o’ ‘nother town which has that color as its palette.

As a kid ( who didn’t realize the Super Game Boy versions o’ Red & Blue had this feature, too, not having a Super Game Boy ), this stood out to me, artistically, for reasons I didn’t know then, & now can only guess is ‘cause seeing a single hue @ a time makes each stand out mo’ on their own, than diluted in a mix ‘mong others.

I bring this up, ‘course, ‘cause this palette system o’ having a different monochrome palette for each place heavily inspired the palette system in Boskeopolis Land, where each level map & different sections o’ the o’erworld have a single monochrome palette.

Posted in GBC Tribute, Video Games

SNOOOOORE: Moderate Liberals Prove Themselves to Be Close to the Same Level of Fuck-up as Republicans

Sorry I haven’t been writing much. Nobody else has been saying much notable & I got distracted by this neat book called They Thought They Were Free by Milton Mayer. Not sure where I’d get the idea to read a book like that in a time like this. Unlike 2016, this election went just as everyone expected: Democrats barely win the House & barely lose the Senate.

If Democrats have any spine, the best they can do is cockblock Republican bills like Republicans did to Obama & pressure the Hairpiece administration into revealing its dirty laundry. I hope they a’least do the latter, as that will a’least be intriguing. ¡Don’t be boring for once in your life, Democrats!

According to DailyKos, this is 1 o’ the biggest waves ( keeping in mind that, in Democrats’ defense, they were unlucky with few senate seats up for grabs ). That’s not too surprising: 1 o’ the reasons I’m rather optimistic is that the obvious rancidness o’ Hairpiece has made mo’ people turn their nose & overtly oppose Republicans — when self-described centrists are mo’ & mo’ ending this “both sides” shit & going, “Yeah, no, clearly 1 side is much smellier than the other”.

For god’s sake, The New York Times, a newspaper that a decade ago was ‘fraid to call torture torture is warning ’bout fascism. Reddit, a forum with a somewhat undeserved notoriety with their alt-right forums & weirdness, has its main politics subforum mostly dominated with furious Democrats. While 538 tried to keep a nonpartisan visage, its comments are full o’ people sad when Democrats lose & happy when Democrats win, & you could see in Nate Silver’s mea culpa for his infamous misprediction o’ Trump’s loss that Nate Silver considered Trump, & to an extent, the Republicans in general kind o’ a joke. ¿& who could blame him? Halfway moderates have always known that Republicans are dumb; they just always tried to handwring round it ’cause they feel it’s too mean to tar an entire political class, ’cause they make that wrongheaded conflation conservatives try to feed that people who choose certain morals are the same as people who don’t choose their race, gender, sexual orientation, or economic stature ( a’least as much ), e’en though moral behavior is exactly what you should judge people on if your society is to survive. Turns out, this moral nihilism o’ “both sides are wrong” on behalf o’ centrists leads to a complete flouting o’ morals, & only by actually punishing those who flout good behavior do you actually lead people to act morally.

1 thing’s certain: intellectuals are certainly veering e’en mo’ ‘way from conservativism, which isn’t surprising, considering the geniuses they have. Studies prove it. This, ‘gain, we already know by the way conservatives attack intellectuals & colleges.

This is why I’m, as odd as it may seem for a cynic like me, totally dour ’bout the future. People compare conservative America to Nazi Germany but forget what Germany is like now: a progressive social democracy. That’s ’cause, if you look back @ history, you learn that, in the long run, the intellectuals always win, ’cause ideas are the only thing that outlasts people & are what basically all development comes from.

This is already happening. Climate change denialism is looking mo’ & mo’ ridiculous to mo’ & mo’ people; mo’ & mo’ moderates are becoming less enthralled with the ol’ “Washington Consensus” o’ neoliberalism. Economists who praised Bush’s tax cuts now roll their eyes @ the conspicuous cynicism o’ Hairpiece’s tax cuts. LGBQT rights has gone from a controversial issue to an issue as black-&-white, good-&-evil as racial equality, so that e’en nonpolitical children’s shows aren’t ‘fraid to embrace them.

Yes, there are still outspoken conservatives; but there are also outspoken flat-earthers. Mo’ & mo’ people are finding it hard to distinguish ‘tween the 2 — & most o’ those who can’t are ol’, &, in their defense, were raised on irrational ideas so long that it’s hard to break from them. Something you don’t e’en need empirical evidence to see is that the ideas o’ the young will definitely win in the long-run, since in the long-run, the young will be the only ones left.

That’s not to say that the US’s politics will get so good so quickly, since it is e’en mo’ corrupt than is dawning on moderates now. ( Though e’en normal people are starting to see it, as we shall get to soon ).

Which brings me to the actual important wins: Florida allowing ex-convicts to vote & Missouri passing a bill to weaken gerrymandering. The former will be vital since Florida is such a strong, unpredictable swing state, & Democrats tend to win when mo’ people vote, ‘specially lower-class people.

On the other end, you have righteous fury @ Georgia for letting someone running for representative monitor & control the very election machines. Conveniently, they had a shortage o’ machines in mostly inner-city, black areas. Then ‘gain, this is the same guy who “lost” voting records when they got sued.

Anyway, I may continue tomorrow, when I’m not too tired to write. ¿Why’d it take so long to get all these results? 2014 everyone knew by 8 PM.

Posted in Elections, Politics

Let’s Watch the Democrats Utterly Disappoint ‘Gain / Tie, Part II

Looks like Democrats got fucked out o’ the Senate. Everyone claims they’ll win the House, but Google still shows them below. I think maybe the blue states are waiting longer to count their votes, as my state still isn’t showing any results.

¿Why all the hate gainst 538? This time it seems like they’ve been accurate — as they’ve been for just ’bout every election ‘cept 1 particularly odd 1.

Posted in Elections, Politics

Let’s Watch the Democrats Utterly Disappoint ‘Gain / Tie, Part I

It’s that time o’ year: time to stay up far too late having my computer die trying to load political pundits’ haphazard websites made with templates & doused in advertisement JavaScript & autoloading video with Hairpiece’s loud mouth embarrassing me in front o’ anyone within a 5-meter radius.

As usual, not being a presidential election, this 1 was rather quiet & subdued. The fact that everyone expects Democrats & Republicans to be rather even in this outcome, with Democrats retaking the House & Republicans keeping the Senate. Since the opposite party o’ the party that recently took the presidency failing to take the House the next midterm only happened twice in the last 100 years or so, if the Democrats fail to take the House, they’ll prove themselves to be ultra mega utter fucking failures. Can’t wait to see that.

& what’s always predictable is the way pundits react:

DailyKos generally shows subdued optimism, which is the only way they can keep their teacher mom audience from slitting their wrists. I did find this fascinating post on California’s slow vote-counting. That’s what happens when you’re those filthy liberals who actually want everyone to vote.

Though this post seems bizarrely alarmist, e’en if trying to stem alarm.

O, wait, ne’er mind: I just checked & Democrats are a li’l below on the House. & they usually vote early, too. Wow, Democrats are fucking losers.

Meanwhile, “Interested Observer” is already prepared for a letdown:

Short diary.

Democrats are going to come up short in the house, lose ground in the senate and likely do nowhere near as well as they had hoped in the governors races.  Your country is run by an overt racist, sexist asshole and he is again being rewarded for that very behavior.

Nice country you have there.

I hate to break it to you, Interested Observer, but the US is run by overt racist & sexists whether the Democrats win or not.

Meanwhile, Naked Capitalism shows their typical cynicism by predicting that e’en if Democrats win anything, they won’t do shit ‘cause they’re filthy moderates. Then they do what these kind o’ cranks always do & point out the weaknesses in polling data & then care mo’ ‘bout their own arm-chair theories, which have no scientific backing, empirical or mathematical. They will then try to argue that this makes it better ‘cause science is flawed, unlike this 1 s’posedly enlightened beard-stroker, who knows all. I’ll stick to my tried-&-tested philosophy o’, “either science knows or nobody knows” ( economics falls in the latter ), which is why everyone who predicts some wacky amazing economics event is an idiot.

( To be fair, his claim that Democrats are filthy moderates is backed on data ).

FiveThirtyEight claims Democrats have a 9 in 10 chance o’ winning the House but a 5 in 100 chance o’ winning the Senate — the latter o’ which shows how naive people who thought Hairpiece’s 3 in 10 chance was “impossible” were. ¡Let’s still have hope for no reason!

Posted in Elections, Politics

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 XXXIX ( Stormy Skyscrapers )

Stormy Skyscrapers

It’s a good thing I didn’t promise anything specific, ’cause I ended up completing a completely unmentioned level. ’Cept, if you paid attention, you might have seen clues o’ the idea ’hind this level lurking in the background since my 5th post. I’m surprised I hadn’t shown off mo’: for the longest time I’ve had an unfinished city map with a grayscale palette, a few Hydrant enemies, & a long spike pit with horizontal & vertical moving platforms, with the plan o’ the level being mainly vertical.

None o’ that map made it into the current 1, which I started working on sometime last month, inspired by my playing Super Mario Bros. Deluxe, as I oft do during September, for some reason, & finding ’nother gimmick to steal. In this case, I basically completely ripped off the… ¿teeter-totter platforms? I don’t know what they’re s’posed to be called, but they’re called “weight platforms” in the game’s code. The 1 notable difference is the improved rope graphics, that was a pain to get to work right.

This level is heavily inspired by World 4-3 in Super Mario Bros., which I think is my favorite level in that game. However, the thin mushroom platforms are replaced by skyscrapers. I wanted this level to have a retro platformer feel, which is why it has a grayscale palette: much as mushrooms are sort o’ the natural, normal setting for Mario, urban landscapes are the natural, normal environment for Boskeopolis, — which is a city, after all — which is why it’s the 1st setting o’ each cycle.

The paper plane enemies, which grab you & drag you back to the start if you don’t struggle out o’ them quickly ’nough, are a riff on the randomly generated Bullet Bills. I thought making them drag you backward a bit was a nice way to balance having an extra projectile to dodge while not making it too hard to avoid being killed — while also rewarding you for being a fast button masher for struggling out o’ their grip. Then ’gain, some might find this mo’ annoying, ’specially when there’s an infinite healing heart block in the middle o’ the level. This is s’posed to be a 2nd-cycle level, so it shouldn’t be too difficult. It should be just a notch ’bove the 1st level.

I can’t remember exactly, but programming in the weight platforms probably took the most time out o’ everything, & became a barrier when I stumbled ’pon a bewildering glitch that caused 1 o’ the platforms to not budge, no matter how much I stepped on it ( but did work for the other 1 ), no matter how much I rolled back my code or recompiled it. Finally, I narrowed down the culprit in the silliest way: technically, ’twas caused by changing the map, which was why no amount o’ rolling back code fixed this bug — ’twas a bug that had been round since the start, but hidden till I added a block right ’tween the platforms. To make the platforms work, e’en when 1 is off-screen, I made the actual sprite go all round the limits o’ where the platforms can go till they fall. Thus, the block ’tween them was interacting with them & trying to block them from going downward. The fix was to simply turn off block interaction for that sprite, since they clearly didn’t need it.

I was updating this sprite up to near the end o’ developing this level. As I was demoing collecting gems in the level, trying to determine what I should set the gem score to be, I realized I’d ne’er implemented gaining points when breaking the platforms.

A’least the weight platforms sprite doesn’t seem to have much ugly kludge code, & I actually bothered to comment it properly.

The next boundary I ran into was, surprisingly, the gorilla sprites spawned by the big barrel sprite, an obvious reverse paean to Donkey Kong — the same problem I ran into on for “Ice Box Rock”, but far trickier to fix, since the platforms they walked o’er were sloped. @ 1st I just kept the level with the blocks_work_offscreen flag checked in the hopes that it wouldn’t be too slow, like “Rooftop Rumble”, which also has the option. I e’en tried optimizing the map by making all o’ the building blocks that weren’t the roofs background tiles, since you can’t interact with them, anyway. But, predictably for a much bigger level, there was noticeable slowdown. For, not only did this level have mo’ blocks than “Rooftop Rumble”, it had far mo’ sprites — sprites that all needed to interact with blocks, which was the point o’ making the blocks work offscreen in the 1st place. We’re talking ’bout up to 20 sprites, as opposed to “Rooftop Rumble”, which only has 2 sprites.

Surprisingly, I was able to optimize the handling o’ blocks when offscreen, so that the level seems to work in perfect speed now. ’Twas clear to me that the main problem was that every sprite was testing interaction with every block — 20 sprites times hundreds o’ blocks. The trick was to limit the blocks checked per sprite to only blocks near ’nough to actually be probably candidates. @ 1st I sat round thinking o’ complex patterns o’ dividing maps into screens, only to realize that that wouldn’t help when sprites enter the dividing line ’tween screens, till I tried a much simpler solution.

The way the block list works normally is that non-null blocks are added to the end o’ the list as they’re sequentially scanned from the map array, from top to bottom, left to right. Since empty tiles ( 0 in map data ) are ignored to save memory, & since no maps don’t have large gaps o’ empty tiles, the sequence o’ blocks in the block list have no relevance to their position, as shown below:

The position for each block is held in each block, & thus each sprite needs to test each block to see if they’re colliding.

Visual comparison o’ block data rendered based on position & data as its held in array:

The solution was to change it so that all tiles, including empty tiles, are added to the block list. This creates a consistent pattern ’tween the map & block list, like so:

Doing this, we can calculate where in the map a block will be by its location. We can be sure, for instance, that a block whose index into the block list has a remainder gainst the map width o’ 0 will have 0 as its x position value. Indeed, this is obvious when we remember that the blocks get their position in the 1st place from their position within the map’s block list.

Thus, rather than testing every block for each sprite, we only need to test blocks within a range o’ a block or so ( I picked 3 blocks @ a whim ) ’bove to below & left to right. Thus, the loop changes from

for ( Block& block : blocks )
{
    block.interact( sprite, ... );
}

to

const int first_x = floor( sprite.xPixels() / PIXELS_PER_BLOCK ) - 3;
const int first_y = floor( sprite.yPixels() / PIXELS_PER_BLOCK ) - 3;
const int last_x = ceil ( sprite.rightPixels() / PIXELS_PER_BLOCK ) + 3;
const int last_y = ceil ( sprite.bottomPixels() / PIXELS_PER_BLOCK ) + 3;

for ( int y = first_y; y < last_y; ++y )
{
    for ( int x = first_x; x < last_x; ++x )
    {
        const int n = y * map.widthPixels() + x;
        Block& block = blocks_[ n ];
        block.interact( sprite, ... );
    }
}

When I was 1st testing this out, I actually started by changing the rendering code to this, based on the hero’s position, which, when I figured it out, gave this cool effect where only the blocks right round the hero sprite appeared.

In hindsight, this is an obvious optimization: trading space for time, which is usually beneficial on modern computers with mo’ memory than it has processing power to use optimally. I think I thought adding mo’ blocks to memory was slower ’cause levels with the blocks_work_offscreen flag checked on were slower. But that was ’cause it had to process mo’ blocks, not just ’cause it had to keep them in memory.

This makes me think it might be mo’ efficient to use this kind o’ code with regular levels where only the blocks on screen & just round are live, ’specially since it would be less o’ a memory burden, being a few extra blocks ( probably barely mo’ than a kilobyte o’ extra memory ).

After that, the only snag was a slight bug with that paper airplane sprite: I thought it’d be cheap if you could get hurt by enemies if the paper airplane happened to move you through them, so I made the paper airplane sprite turn off the hero sprite’s ability to interact with sprites while in its grasp. The problem is, that meant the paper airplane sprite itself couldn’t interact with the hero sprite. The solution rather janky, but works: give the paper airplane sprite a pointer to the hero sprite it can keep @ all times &, when it sets the hero sprite to be grabbed, use the hero sprite’s pointer while updating to handle moving the hero & letting go.

In making the girder blocks, I did have to make a flatter slope than I had before. This gave me the ’scuse to finally stop screwing round & clean up the slope blocks, which I’ve mentioned before, were hackily copied & pasted from class to class. So these classes wouldn’t have to waste, like, a couple whole precious bytes out o’ the billions available, I made a single templated class with direction, steepness, & position within its slope ( since flatter slopes require mo’ blocks to form a complete slope ) as template arguments. The great thing ’bout this was that it not only cleaned the code, it made making the new flatter slope blocks ridiculously easy: I just had to quickly calculate some new #s to push into the template, & then it just worked perfectly. Turns out programming’s easier when you don’t do a hacky job o’ it.

Since the graphics are mostly reused, there wasn’t much to do there, & the girder & platform blocks were so simple, they took hardly any time to draw. In fact, I actually drew some fancy bridge blocks that I decided not to use till the very end o’ the level, preferring the plain building graphics ’stead. Using these familiar city graphics to replace the mushroom towers felt like a better parody than using some unfamiliar graphics. Plus, it allowed for layering towers o’er each other, like after the 1st pair o’ weight platforms.

Something I tried to emulate from the original Super Mario Bros. was making it so that while the weight platforms could help in certain ways, including getting gems & the hidden diamond, you wouldn’t have to wait for them to slowly move in order to just beat the level: if you play it right, you can hop straight from platform to platform in this level ( & in World 4-3 o’ Super Mario Bros. ) with minimal delay. Actually, I don’t know what happened, but somehow this level became easier to do quickly, as I easily got 18 seconds on my 1st try in this video, which took many tries before, which was why I set the time limit to 20 seconds. I should maybe change it to 18. However, I want some leeway, as this level can be kind o’ cheap with those randomly generated paper plane enemies.

In the process o’ making some o’ these code changes, I also made some other simple code refactoring. For instance, the same insight that led to turning the slope blocks into a templated class, probably from some C++ books I was reading, led me to realize that the Counter class, used in many places, could be a template.

I also finally got round to adding an autoformatter for text, such as the text that appears in message blocks. Before, to keep them formatted, I had to manually calculate where to put line breaks, as it would naturally just go to the next line when it ran to the end, e’en if ’twas in the middle o’ a word. Now, it runs the text through a function that checks if the letter @ the start o’ each line after the 1st is a space or line break, & if so, it eliminates it, if it’s a different character ( which means it’s a word that spans ’tween lines ), it goes backward till it finds a space & replaces that space with a line break so that the word spanning 2 lines starts @ the next line.

Here is a before & after shot that demonstrates this:

So for this message, the algorithm stops on the 1st letter o’ the 2nd line, sees it’s not a space or newline & goes backward till it reaches the next space, right before the “W” in “will”. It then replaces that space with a newline, causing the next letters, “will” to be printed on the 2nd line, as shown.

It’s probably not the most efficient algorithm, but that’s fine, since it only runs once @ the beginning o’ a level.

I hope to finally get round to other code refactorings, but I have to be conscious o’ my time, ’specially as I grow older & become e’er mo’ senile.

¿& who knows what the future holds?

This code is still sloppy as a hippo & probably won’t compile on your computer.

Posted in Boskeopolis Land, Programming