Thursday, January 21, 2021

The Great Refactoring of 2021

Mary stands on a raised block in front of camera. Beyond her is a big, blue ground with a lowered green area to the left. Behind that, a big pool of water is seen.
How's Magical Mary going? Well, I think this picture says it all; There's not much anymore...
Oh, wow... I really suck at ensuring things are up to date, aren't I? I mean, just visit the official Magical Mary 1 YouTube channel and you'll see the severe lack of any update videos, which is mainly due to the higher standard of quality that is expected of YouTube videos compared to the quick, short, and easy videos uploaded to the Facebook and Instagram🆕 pages.

Still, despite the silence, there's still ongoing development and updates being made to the game! It just isn't the most exciting thing to show in pictures since it basically required all of the existing levels to be thrown out; Right now, there's only a very simple test level with ramps, raised blocks, and water. I can still talk about the cool recent updates in this blog post, so let's get to that right now! 

Now, you might've seen the title of this blog post and started to wonder if I'm really going through with the refactoring this time, since I've hinted at it in the past but never showed proof... Well, yes. I wouldn't just throw out years of work and some good levels for nothing, but with a "refactoring" comes the very likely possibility that level scripts could break if I started editing the very scripts they depend on. Due to that, now there's only a test level, but this downgrade comes with its advantages.

Movement Improvements

Magical Mary's old scripts were basically held together with duct tape, doing questionable things to let Mary jump, land, and worst of all, perform her signature ability, the Air Dash. An image would be too small to read the text in, or too tall to make reading this blog post enjoyable, so please compare the new, improved script responsible for mid-air abilities (and jumping) to the horrible, hackish mess that was there prior to refactoring in this GitHub Gist.

Speaking of jumping, its behavior has changed in two ways, one being the addition of "late jumps", inspired by Doom Eternal. In that game, you can still perform a normal jump after walking off an edge, given you do it within a certain time frame. Magical Mary 1, as of the refactoring, treats you as if you were on the ground for up to a half-second after becoming airborne. This was done in both games to make first-person platforming less of a chore, as you can't see how close you are to an edge when looking forward.

This one change can really be noticeable if you go back to any previous version, even v2.1; There, if you push the jump button in quick succession after you move off an edge, you'll do the Air Dash. By comparison, doing that in the new version will instead do a mid-air jump, which can still be followed up by an Air Dash.

Another movement-related update is how I've brought back the double/triple jumps, absent since the game was called World of Kirbycraft! Now, they're more reliable and support variable jumping heights like the first jump. What's cool about this particular update is that these higher jumps were removed because of the addition of variable jumping heights, and now they live in harmony! To avoid these higher jumps, release forward right before you push jump, or lose speed before the jump.

Ah The last change I'll mention here is another one you probably wouldn't notice unless it was pointed out, but footstep sounds are now more "dynamic" in the new version. In v2.1, there's only like three or four distinct speeds that Mary animates at, which also controls the footstep sounds. The refactoring changed this so instead, it's an ACS script that uses Mary's current speed to use a wide range of speeds for Mary's footstep sounds, and in the future, it could control Mary's animation, allowing her movements to match the sound timing! In this video, notice how Mary's footstep timing jumps between speeds as she turns around and runs, then check the second part to see how she smoothly changes between speeds.

There Has to Be Something Else...

Alright, alright, fine... There is one more notable thing to talk about, and that's this old thing:

This crappy, outdated mechanism deserves to burn by Mary's wand. Someone needs to throw this thing out!

For at least a few versions, City Street Run (1-3) has had a radio, which plays backward (v1.6) or AI-generated (v2.1+) songs mostly, and men speaking complete gibberish other times. After listening to 101.5 BOB ROCKS enough, I started thinking...this "radio station" doesn't really behave like one; To everyone's annoyance, real stations run advertisements, and the "talk segments" have more structure to them!

Knowing this, I set out to re-write the radio script, making what became essentially a "state machine" of sorts, with modes it switches between based on conditions. For example, after playing a certain number of songs, it may switch to advertisements, but there's a chance a talk show will begin instead. The same thing happens when returning from advertisements. Also, like real radio stations, the radio station announces its name when transitioning between segments.

Oh, and those talk segments? They were made more believable, too! In the old system, it would pick from a large pool of ~20 samples, play it for a couple seconds, then do it again until the radio script would force it to stop. In the new system, there's multiple distinct "speakers" with their own variety of "questions" and responses, which each have different lengths. It picks three of them at random and assigns one as the "host" and the others as guests, which take turns prompting then reacting to said prompt.

There's a lot of randomness to this; For example, each guest can choose to not respond each round, which further adjusts how long a round lasts. Also, at the end of a round, the speakers can change roles, allowing other voice samples to be audible.

Let me tell you, all of these changes really breathed life into what's basically a series of sound files with logic behind them. There was one more thing that I felt needed to be done with the radio before I could move on, though: It needed a facelift; The old radio looked like one of those old game shows where there were physical parts of the board that people behind the scenes had to slide manually out of the way as needed. That just didn't seem technological enough or me, so I turned it into a screen.

Someone listened! This looks like they hacked an old iPod's screen to make this, though... 🤔

Look at that beauty; Gone are the wooden blocks, in is the LCD(?) display, with cover art, new songs, and smooth animations. It's impressive that I think I was able to throw this together within a day or two, and really proves that despite my ashaming amount of laziness in recent years, I can still push impressive changes like this out. I really don't need to talk much about this for you to know how awesome it is, and you'll see it for yourself once the refactoring is more complete.

Well, hopefully that made up for the months of not writing blog posts! It probably didn't...but oh well. Look forward to the eventual upcoming version, which will include these improvements and possibly more.

No comments:

Post a Comment