Organic Code
Felt like doing a little blerbin' but hopefully not too much blerbin' cuz i gotta save some energy for work!
When we first start coding, we're so amazed that anything we make works at all, that we kinda just leave things as is without much thought for how our workflows can improve. And we're convinced that in order to get better at code and to write better code we must learn to work in increasingly complex logic with more advanced math with more and more things going on at a given time.
I wish we as game developers did more to encourage the notion of making our jobs more manageable, and one of the big epiphanies I had making SeaCrit was the notion of making code "organic".
What do I man by making code "organic"? I mean code that lives on its own, code that works in a very intuitive and relatable way to us analogue creatures with our own imperfections. Oganic code always wants to try to fix itself, it wants to revert to a state where everything functions and is fine, no matter what hardships you throw at it.
Dialogue really kicked my ass. If you were mid conversation with a fish, there would be a dialogue box on the screen and a giant fish as well smiling and looking you in the face. And if you happened to enter a teleporter and unload the fish you were talking to, that giant dialogue box would sit there staring you in the face and it would never go away because the system that needed to tell it to stop bugging hte player was now unloaded.
So often we make clunky systems that are at any moment one mistake away from total disaster, and it's so important that we make systems that are able to revert to a default and safe state if no other systems are telling them to act up and break things.
So now my dialogue always wants to go back to "stop showing me" and as it reaches this state it ergonomically fires off all the things it needs to do. The end result is a super simple, easy to use bit of logic that isn't prone to ruining our life in the future.
The code looks something lie:
var targetOpacity = 0f;
If(player.talking) targetOpacity = 1f;
math.lerp(ref dialogueMaterial.opacity, targetOpacity);
if(dialogueMaterial.opacity <= .01) DisableDIalogueOverlay();
else EnableDIalogueOverlay();
So simple! If the player is talking it fades in all the overlay UI, and once the overlay UI is nearly invisible from no longer talking it disables the overlay reducing draw calls.
This is just one tiny example. But this design philosophy of trying to keep things super simple with logic similar to how we think about things has really served SeaCrit well. Too often we get lost in the weeds of how these annoying systems work and how they call for asinine values and logical bits of things and we start to form our logic around these bizarre initial setups.
But if we take the time to think about how we think things work, and reverse engineer it from there, our systems are WAY better. So i like to start with a sentence type outline:
"The UI is only enabled when there is dialogue to show, and the dialogue box should fade in and out as the player leaves and enters dialogue. If the player is talking every frame we need to dialogue to want to lerp to 1, otherwise 0."
Then we break this down into bits of logic and arrange them in order that fits the gameplay loop, so we need to think about initialization of things first and take actions second. So once breaking that sentence into functionality and arranging it in the proper order we get this.
if the player is talking every frame we need to dialogue to want to lerp to 1, otherwise 0
the dialogue box should fade in and out as the player leaves and enters dialogue
The UI is only enabled when there is dialogue to show
From here we simply turn it into the logic above and boom! We have our working system. It has taken a bit of time to create custom functions that I feel are way more ergonomic like the above lerp function that works as a ref and doesn't require a lerp input and defaults to .03f.
Truth be told I was planning on deep diving this stuff at another time with a more whole hearted blog post, but I really just wanted to link some Grateful Dead tonight and Sugaree. Some days that one song just really gets stuck in your head and I'm having one of those days right now.
Some bad news, I was excited to ween off the Lexapro, but after just 2 days the breathlessness REALLY started setting in, so it would appear i'm stuck with this stuff. I guess I should feel blessed to live in a world where we have access to these medications, in another era i'd be dead in a ditch at this point. Truth be told, I've got neckbeard energy to spare so maybe it's a good thing I'm taken down a notch or two XD, I'm not even joking, but if you've read any of my other blogs you already know that...
I know when people think of "the dead" they think of these crazy live shows, and people loving the music because they're off their ass on psychedelics and whatever other gnarly shit. But that does a disservice to their music. It's just so fucking good. Sugaree for me is one of those songs that's able to evoke this wonderous emotion as euphoric as any drug.
Any more you hear about bitches and hoes in music and it's all surface level, gaudy, and thoughtless. Sugaree evokes a poignant relationship that goes deeper when showcasing the plight of those dealing in less savory elements of humanity and avoiding authoritarian repercussions to whatever was going down in the song.
I mean, it's all just raw emotion evoked from some simple lyric's intentionally kept vague with vocal inflections and melody... but isn't that what music is anyhow? Damn these guys are able to capture these really human feelings you don't get from other bands. They never had the catchiest riffs or one liners that got stuck in your head. But The Grateful Dead more than any other band, were able to summon these psychedelic and heartfelt responses while talking about very mundane stories. But when you think about it, that's what most of our lives are anyway, and there's something very poetic about that.
Anyhow! Sugaree is a fun little ride to go on once in a while, not unlike what I hope to accomplish with SeaCrit.
Bonus blog post! TITLE: Much ado about nothing
As I wrap up this blog post, I came to think about all the coding talk most like to blather about, to neckbeard over and to beat their chest to. And so much of it is so damned silly. Not to take anything away from those incredible coders who move mountains and use math and top of the line logic I could only dream of to the the most advanced matrices and effects that make lighting look fantastic and trillions of polys run seamlessly in realtime. You guys are fucking rock stars.
But there are so many damned neckbeards who like to gatekeep others from making cool stuff or flex their nerd muscles in a vain attempt to look self important. In the face of how difficult it is to make a an actually good game, many love to make mountains out of molehills. Because let's face it most don't know how the SeaCrit sauce is made and we all want to feel important in our own little hero's journeys.
Am I insinuating that I DO know how the SeaCrit sauce is made? Am I another self-aggrandized neckbeard in a sea of annoying self aggrandized neckbeards all vying for the throne to be God Emperor of the Neckbeards?
Am I in the end the greatest, most insufferable neckbeard of all?
I ask myself these questions often, it genuinely weighs on me.
Get SeaCrit
SeaCrit
Deceptively Deep!
Status | In development |
Author | illtemperedtuna |
Genre | Action, Role Playing, Shooter |
Tags | Beat 'em up, Casual, Indie, Roguelike, Roguelite, Side Scroller, Singleplayer |
More posts
- A Mi Manera13 hours ago
- We gotta get some thoughts together2 days ago
- Blah, blah, blah3 days ago
- We Back5 days ago
- Down to Donkey Park6 days ago
Leave a comment
Log in with itch.io to leave a comment.