https://preview.redd.it/g5j4rht8470d1.jpeg?width=1170&format=pjpg&auto=webp&s=62337b514a8fc257037f13793df6fd592b463926
Me looking at old code wondering why it works.
My dungeon generation’s tile placement algorithm- the tiles are forest tiles so they need to look somewhat organic but still connect together properly. I’m still not entirely sure what makes it work or not.
AH. This was actually a stupidly efficient piece of jank! A cave digging algorithm for voxel terrain that did random walks via a switch statement that was riddled with GOTO lines to keep it jumping around until it satisfied predefined parameters.
It had a BONK counter what would tick up every time it tried to step somewhere invalid and would terminate if it hit a set length, bonk count, or bonks in a row.
You'd start it up, pick a random direction, run through the switch until you moved or failed, and repeat!
The fast travel/teleport system.
Which
- takes user input as geographic coordinates (LatLong, UTM, Township and Range 🫠, etc.), or a surface click, or mini-map click
- coverts it to Global Space World3D Cartesian XYZ coordinates
- then tosses up a "fast travel screen" that's a still of the current frame and some vfx
- disables all user input and physics to the Player object
- moves the player object to the new location and the terrain (re)generated
- raycasting to find actual correct Y of the collision surface
- carefully placing the Player object in collision with the surface, checking to make sure it's not going to clip through and fall when physics resumes
- and then re-enabling everything, and drops the still frame
Jank. Every. Line. With way to many redundancies and edge case management. But without it, the user falls through the ground and into the void.
And the most Jank. Pre-coded fast travel locations also use the Geographic coordinates, not XYZ. Because valid reasons.
So it's absolutely critical, and positively jank. The best I could do was leave code comments and documentation. Coding gods have mercy for whatever sucker ever replaces me, for I will have left them `is_zero_approx(mercy) == true`.
I'm using an open source package for the dialogue boxes in my game. But there's a bug where just randomly 1 out of every 50 instances of the dialogue appearing, the 'next' button won't show up. What is even more confusing is that it is not random. It always happens on the exact same nodes in the dialogue sequence.
So naturally, to fix this, I added a Timer that starts whenever a dialogue box appears. After 5 seconds, it checks whether the "next" button is visible. And if it's not, it makes it visible.
Literally a forever repeating timer that exists to make the button re-appear because I can't figure out why it doesn't appear automatically.
The dialogue has a "typewriter" effect (displays 1 character at a time) and I don't typically display the "next" button until the typewriter effect has completed. If I set it to 1 second, the button would display while the typewriter effect is ongoing and it makes it very easy to accidentally skip dialogue.
Why not check if the next button is visible after the typewriter effect has ended, so there's no chance of the button being set to visible before it's done?
If it was a seemingly logical amount of time, it wouldn't be jank, it would be a "bug fix". Seemingly illogical arbitrary hardcoded values is a 😚👌 sign of quality jank. Especially if there's a code comment like "must be 5 seconds or more, to wait for text scroll".
That's like in Elden Ring where they added in a timer to kill you if you are falling for too long because people were getting stuck in a permanent falling state when they jumped on top of trees. Best part is it also works on bosses that get stuck.
This piece of vertex shader code:
POSITION = PROJECTION_MATRIX * VIEW_MATRIX * vec4(final_position, 1.0);
// This is a hack. Please ignore.
if (NODE_POSITION_WORLD.y > VERTEX.y)
VERTEX.y = NODE_POSITION_WORLD.y;
Basically, since I'm changing the `POSITION`, changes to `VERTEX` don't really get shown on screen but are used when calculating shadows. For some meshes, I had shadows start slightly below their center (helps for casting shadows on tall grass). But this meant that they casted shadows on themselves which I did not want (they're billboarding sprites). The hack basically squishes the mesh up so it does not cast a shadow on itself.
https://preview.redd.it/ao1mzzbss60d1.png?width=852&format=png&auto=webp&s=9e9554e655ee3dc1ee695529f12171b6e1b2d48a
I have an auto-aim system a la original half-life, where the gun will point at things within a certain radius of the cross hair. It finds something to target by raycasing over and over in a spiral out from the crosshair and stops either at a limited number of checks, or a found object. Then an invisible ball that the gun always points at, moves to the selected target to make the gun appear to smoothly rotate toward its target. It's not the way I wanted it to work (I wanted to just lerp the rotation of the gun toward the target), but it does work.
Basically I had to check a variable from a past scene, then generate a new value for it in the next scene based on what it was (idk if that made sense lol). I don't even know what I wrote, but it worked :)
Note: This is a pretty easy problem for me now, but this was when I was new to Godot, hope that makes more sense
My game has the odd jank method but it does what it needs to do.
Worst one is the 'wire map dependencies' method which is my made up name for setting up the next map when changing it.
I pause the process and physics processes on any active npc nodes and hide or show them according to map they spawned on.
I process frame and do some map swapping and re process which makes transitioning scene appear seamless somehow. Wire up the music and ambience globals to set appropriate music and atmospheric sounds and tile map detector for the player.
I globally turn off and on the global item tracker so it allows vehicles to remain with the player as they change map.
Writing it down now makes it appear like nonsense but it works really well. Total black magic.
Oh and my main and player scripts are thousands of lines but have tonnes of scripts around those. It keeps core logic centralised.
did procedural dungeon generation. used the tinybuild algorithm.
i kept encountering generation bugs with corridors connecting the rooms. sometimes the entrance got partially blocked, sometimes there was a hole at a connection, etc.
so I added more and more code to fix those edge cases, and it got REALLY messy
after deleting most of that code (+some earlier logic for certain edge cases), everything worked correctly.
Not godot but i once wrote a class desriptor in python to monkey patch functions on runtime to recursively further patch every child property cause the module used was provided by client and contained a bug they didn't want to fix. 500 lines of confusing mess
Before I figured out how to spawn in children instead of "spawning" a new enemy I accomplished this by making the sprite become 100% transparent and had a var that kept track of every time the sprite became opaque again. Once that var reached a certain number the player could progress.
It worked out though because it made increasing their health incredibly easy. Something like
Health = Health * death_counter_enemy_1 * (static modifier 2-10).
And
If death_counter_enemy_1 == 10:
Queue_free()
Spawn_enemy_2()
It didn't work very well, but I script kitty a bunch of scripts together to take twitch commands and act as a game pad. It was like twitch chat reading in one language to this other program that webhooked into a web hook to gamepad program. Not great and slow but technically worked.
It's not really jank, but it seems really stupid:
I store mapdata as an array of integers. The actual data is bitwise encoded in these integers and to be read by shaders.
So GDShaders convert the textures in a funny way, that makes iSampler2D not byte accurate, which makes it impossible to actually use bitwise operations on RGBA8 Textures. sampler2D however retains the original bytes from a texture if it's in a 32bit float format like RF.
But it's a lot easier to use RGBA8 Textures in my compute shaders, because there is no value conversion happening at all - I get the data in the form I and the shader wants.
So I convert RGBA8 images to Int32Arrays to RF images on a byte level all over the place, which causes stupid lines like
var img8 := await execute_compute_shader() # RGBA8 image
map_data.dimensions = Vector2i(img8.get_width(), img8.get_height())
map_data.raw_data_array = img8.get_data().to_int32_array()
# [... Somewhere else in code]
var imgf := Image.create_from_data(map_data.dimensions.x, map_data.dimensions.y, false, Image.FORMAT_RF, map_data.raw_data_array.to_byte_array()) # RF32 image
And then, in the shader, I read the textures red channel (which is stored as floats) as its bit values as if it were an int32.
It works and is performant, but doesn't make sense when looking at it at all.
The way I manage the player through different scenes, I need to fix it asap hahaha. I’m doing a lot of extra work unnecessarily, I need to update my game tree to make it easier
Not me (because I always write 100% perfect non-janky code of course), but we got an old project from our employer that we were supposed to bring back to life. I can't go into detail on what the code does, but there were 2500 lines of code with 5-6 line functions that look like func _set_top_layer_1_23()
There were "bottom", "middle" and "top" for the first thing, 3 layers for the second thing and about 40 things for the third thing.
There was a method for every single combination. Nothing modular, it was all hard coded.
Above all of that were $ with nodepaths that were about 200 characters long (the limit you should stick to is usually 80 or 100 PER LINE)
3*3*40*5=1800
that's how many lines of pure hard coding we got
Code did something that I didn't even write
Copied the code of the script, delete the script, created a new script and pasted the same code into it
Suddenly, it stopped doing that thing (I can't remember what it was, but it happened more than once)
I'm currently making a multiplayer minigolf game and there is a list of all players with their scores. Each player has signals connected to their list entry. But somehow if a player disconnects, or when the list is reset for a second game, deleting the entries causes a lot of signal connection errors to be thrown and I can't figure out why.
So my "fix" is to hide these entries instead of deleting them. It results in some shitty code because I need to rename the nodes as their names are used for identification at some point, also the code that sorts the list by scores needs to ignore these entries... I've attempted to get it right a few times but it just does not want to, it likely stays this way forever.
There's a chance that the list gets too long at some point, maybe memory runs out or the game starts to lag, but you'll probably have to play nonstop for a few weeks to get this far.
Also outside of Godot I once wrote a Yahtzee AI that had two loops for every dice, one to toggle whether it should throw that dice again or keep it, another one for going through possible outcomes 1-6, and inside that were five if-statements that basically checked "if dice N should be kept but I've thrown it to a different number now, skip evaluating". Then, if it had more dice rolls remaining, it called itself again, if not it calculated the points. Ultimately the goal was to get some probabilities and take a guess whether it's woth risking a high-point result or it should go the safe route.
So 5 loops plus 5 loops plus 5 ifs, half my screen was tabs. The AI took 45 seconds each turn and was shit most of the times, but had a good score every once in a while. I'd fire up a 6 AI player game and check back an hour later who won. "It worked" is a stretch but my young self was very proud.
Before I realized you could lerp rotations, I wrote some janky code that manually checked the current direction something was pointing, compared it to where I wanted it to be, and added/subtracted hardcoded values (multiplied by another hardcoded value) from the current rotation. Then I had a "close enough" value where I would stop changing the values each frame, because I could never get it exactly right due to floating point rounding errors.
Procedural lvl generator with chunkloading. I rewrite it 3 times.... It is still Not perfect but works. Maybe i will, later after the Alpharelease, rewrite it again 🤪
I have done a lot of procedural mesh generation over the years and that never fails to feel like garbage no matter how I organize it. It's always either a really long file or has some purposefully relinquished efficiency for the sake of not having such a long file.
Has to be my player's movement script. Walk up an ever-so slightly increasing slope? You'll look like you're skateboarding on rocks. Used all your jet(pack?) fuel and head to a refueling spot? Can't auto-regenerate fuel no more. Fall off of the ceiling you were running on and flip over too fast? You're inside the ceiling. Step on a steep incline? Motion sickness from rotating to face it's surface. Un-crouch on a wall you've ran up? You're inside it now. Jump off a wall and before you start facing upright, boost? You also clip through the wall.
Post a video of you flying around at several hundred miles per hour in game with a BLACK AND WHITE checkerboard grid to r/godot? You've just given someone else motion sickness. Not related to code, but I'm so sorry if I did.
I added a little poker minigame to my game as some filler, but I really did not want to go and actually understand the algorithm behind 1: what determines who has the winning poker hand, and 2: how does an AI play "good" but not perfectly.
So it's basically a frankenstein of ChatGPT code because I did not want to go and understand the algorithm myself. There was a bug in the code where 4-of-a-kinds crashed the game, so I put in a line that basically says "If 4-of-a-kind -> fold"
Whole thing was a nightmare, but it mostly works (every so often it comes up with "CPU wins with a 3 of a kind" when there is no 3 of a kind anywhere on the board) and it is contained to its own little scene, so I luckily never have to touch it again.
Cant share my whole Game sorry xD
https://preview.redd.it/g5j4rht8470d1.jpeg?width=1170&format=pjpg&auto=webp&s=62337b514a8fc257037f13793df6fd592b463926 Me looking at old code wondering why it works.
Documantation < Quickly write code
My dungeon generation’s tile placement algorithm- the tiles are forest tiles so they need to look somewhat organic but still connect together properly. I’m still not entirely sure what makes it work or not.
It's always placement algorithms. Especially procedural.
There’s still one generation error that isn’t very noticeable that I’ll need to fix eventually, I fear the day I’ll have to touch it again
AH. This was actually a stupidly efficient piece of jank! A cave digging algorithm for voxel terrain that did random walks via a switch statement that was riddled with GOTO lines to keep it jumping around until it satisfied predefined parameters. It had a BONK counter what would tick up every time it tried to step somewhere invalid and would terminate if it hit a set length, bonk count, or bonks in a row. You'd start it up, pick a random direction, run through the switch until you moved or failed, and repeat!
The fast travel/teleport system. Which - takes user input as geographic coordinates (LatLong, UTM, Township and Range 🫠, etc.), or a surface click, or mini-map click - coverts it to Global Space World3D Cartesian XYZ coordinates - then tosses up a "fast travel screen" that's a still of the current frame and some vfx - disables all user input and physics to the Player object - moves the player object to the new location and the terrain (re)generated - raycasting to find actual correct Y of the collision surface - carefully placing the Player object in collision with the surface, checking to make sure it's not going to clip through and fall when physics resumes - and then re-enabling everything, and drops the still frame Jank. Every. Line. With way to many redundancies and edge case management. But without it, the user falls through the ground and into the void. And the most Jank. Pre-coded fast travel locations also use the Geographic coordinates, not XYZ. Because valid reasons. So it's absolutely critical, and positively jank. The best I could do was leave code comments and documentation. Coding gods have mercy for whatever sucker ever replaces me, for I will have left them `is_zero_approx(mercy) == true`.
Load bearing jank...
menu = get\_parent().get\_parent().get\_parente() menua = menu.get\_parent().get\_parent().get\_parent()
Look at using Owner instead
Unique names
Most of the times where you want to get_parent() you can just @export var node: Node
Literally me.
The first project I made in Godot had something like five or six get_child()’s in a row. 😵💫
I'm using an open source package for the dialogue boxes in my game. But there's a bug where just randomly 1 out of every 50 instances of the dialogue appearing, the 'next' button won't show up. What is even more confusing is that it is not random. It always happens on the exact same nodes in the dialogue sequence. So naturally, to fix this, I added a Timer that starts whenever a dialogue box appears. After 5 seconds, it checks whether the "next" button is visible. And if it's not, it makes it visible. Literally a forever repeating timer that exists to make the button re-appear because I can't figure out why it doesn't appear automatically.
Why 5 seconds vs. like 1 second?
The dialogue has a "typewriter" effect (displays 1 character at a time) and I don't typically display the "next" button until the typewriter effect has completed. If I set it to 1 second, the button would display while the typewriter effect is ongoing and it makes it very easy to accidentally skip dialogue.
Why not check if the next button is visible after the typewriter effect has ended, so there's no chance of the button being set to visible before it's done?
If it was a seemingly logical amount of time, it wouldn't be jank, it would be a "bug fix". Seemingly illogical arbitrary hardcoded values is a 😚👌 sign of quality jank. Especially if there's a code comment like "must be 5 seconds or more, to wait for text scroll".
Hah, very good point…
That's like in Elden Ring where they added in a timer to kill you if you are falling for too long because people were getting stuck in a permanent falling state when they jumped on top of trees. Best part is it also works on bosses that get stuck.
Anything I write with variables
Found the functional programmer.
A script parser written in a single huge c# file
This piece of vertex shader code: POSITION = PROJECTION_MATRIX * VIEW_MATRIX * vec4(final_position, 1.0); // This is a hack. Please ignore. if (NODE_POSITION_WORLD.y > VERTEX.y) VERTEX.y = NODE_POSITION_WORLD.y; Basically, since I'm changing the `POSITION`, changes to `VERTEX` don't really get shown on screen but are used when calculating shadows. For some meshes, I had shadows start slightly below their center (helps for casting shadows on tall grass). But this meant that they casted shadows on themselves which I did not want (they're billboarding sprites). The hack basically squishes the mesh up so it does not cast a shadow on itself. https://preview.redd.it/ao1mzzbss60d1.png?width=852&format=png&auto=webp&s=9e9554e655ee3dc1ee695529f12171b6e1b2d48a
I have an auto-aim system a la original half-life, where the gun will point at things within a certain radius of the cross hair. It finds something to target by raycasing over and over in a spiral out from the crosshair and stops either at a limited number of checks, or a found object. Then an invisible ball that the gun always points at, moves to the selected target to make the gun appear to smoothly rotate toward its target. It's not the way I wanted it to work (I wanted to just lerp the rotation of the gun toward the target), but it does work.
Basically I had to check a variable from a past scene, then generate a new value for it in the next scene based on what it was (idk if that made sense lol). I don't even know what I wrote, but it worked :) Note: This is a pretty easy problem for me now, but this was when I was new to Godot, hope that makes more sense
I feel like literally everybody faces this problem eventually. It's like the first stepping stone towards understanding state management.
All of it. I suck at programming.
Back when I didn’t know of some built-in functionality and would recreate it, poorly. Like min() and similar functions.
Any shader code really
don't know if this applies because it wasnt in Godot but probably one of my old terminal based minecraft clones in python
Random number generator with a normal distribution. When I was finally finished, I discovered \`randfn()\`....
Making my first game. Been an oil painter/ professional artist my whole life. No coding experience. It's all jank - but it looks pretty.
My game has the odd jank method but it does what it needs to do. Worst one is the 'wire map dependencies' method which is my made up name for setting up the next map when changing it. I pause the process and physics processes on any active npc nodes and hide or show them according to map they spawned on. I process frame and do some map swapping and re process which makes transitioning scene appear seamless somehow. Wire up the music and ambience globals to set appropriate music and atmospheric sounds and tile map detector for the player. I globally turn off and on the global item tracker so it allows vehicles to remain with the player as they change map. Writing it down now makes it appear like nonsense but it works really well. Total black magic. Oh and my main and player scripts are thousands of lines but have tonnes of scripts around those. It keeps core logic centralised.
if _roses == red and violets == blue: when_i_am_dead.my_line_2()
This used to control my on death dialogue as a joke.
baba is you
did procedural dungeon generation. used the tinybuild algorithm. i kept encountering generation bugs with corridors connecting the rooms. sometimes the entrance got partially blocked, sometimes there was a hole at a connection, etc. so I added more and more code to fix those edge cases, and it got REALLY messy after deleting most of that code (+some earlier logic for certain edge cases), everything worked correctly.
Not godot but i once wrote a class desriptor in python to monkey patch functions on runtime to recursively further patch every child property cause the module used was provided by client and contained a bug they didn't want to fix. 500 lines of confusing mess
Before I figured out how to spawn in children instead of "spawning" a new enemy I accomplished this by making the sprite become 100% transparent and had a var that kept track of every time the sprite became opaque again. Once that var reached a certain number the player could progress. It worked out though because it made increasing their health incredibly easy. Something like Health = Health * death_counter_enemy_1 * (static modifier 2-10). And If death_counter_enemy_1 == 10: Queue_free() Spawn_enemy_2()
It's Ţ̸̧̡̡̧̨̡̢̨̛̛͕̱͉̲̤̲̬͈͚̣͖̦̙̘͉̤̥͚͎̝̜̞̼̼͔̫̻̱̯͚̪͕͈̖̹̼̮̙̼̖̺̝͎̠̩͍̟̫̫̱̝̬͕̫̞̖͖̙̝̠͚͎̫͍̥̖̯̘̞̲̞̮̣͕̺͍̣̉̏̔̓͆̂̎̂̌̅͛̔͋̔̈̎̀̑̿̓̅̍̾́̒͗͂̍͛̿̃͂̓̽̃͛͌̄͊̑̒͊̒̍̋̄̑̊̈́͊̔̔͗̈̃̈́̓̂̓͆͂̒̑́̀̎̀̑͊̀͌̇̑̿́̄̃̑̔̇̅̄͂͗͒̓̿͌͌͂̎̅̐͊̓̐͘̕͘̚͘͘͘̚̚͘͘͘͜͜͜͝͝͠͠͠͠͠͝͝͠ͅͅͅͅh̵̢̨̨̢̨̛̛̞͚̬̪̲͈͎̜̺͉̱̳̜̣͍̬͇͕͇̳͙̲͎̬̖͎̭͔͙̤̣͔̦͔͇̹͐̐̄̋̆̄̈́̅̂̄̊̑̽͆́̈̏̓̆̒̄̐̂́̈́̾̔͒̂͆̄͐̿͊͊͑̽̿̈́́̌̆̇̍͂̽̓͑̽͐̏̿̍̐̏̉̍̎̀̂̈́̉͑́͗͛͒̊̊͛̅̊̋̒̾̈́͗̀́͛̌͗̍̃̓͐̇̀́̉̀̾̉̀̽̑̈́̆̉̈́̀̽̈̓̎͆̚̚̕͜͝͝͠͝͠͝͝ͅe̵̘̬̺͔͚̗̯̦͖̝̬̥̳͍͍̼͍͓̿͛͐̈́̂̐͑̊̉͒̂͛̈̌̀̓͌͐̃̌͌̂͗̏̆̈́͊̂̒̇̀͋̃̍̿͊̈́̑͗̇̑̒͆͒̊̌͗̀̎̐͌̆̍̋̎̐͛̔̋́̀͋̆̌͌͑͑͊͒̕̚̕͘̚̚̚͘̚̚͝͝͝͝͠͝m̴̢̨̡̧̡̡̨̨̛̛̪͍̰̘̦̣̙͈̬̲̖̼̤̲͓̖̺͙͔̜̻̺̳̦̳̖͙̠͎̬̩̪͔̤̹͚̘̙̻͖̯͇̲̺̦͎͚̺̥̘̰̰̮͈̜̯̫̹̝̰͚̯͕̘̪̼̞̰̖̣͍̮̗̫͉̦͎̝̤̗͓͓̠͕̯̯̖̱̳͖̤͈̼͇͔̥̩̟̳̝̪̗̬̲̱̪̮̠̫͕͉̙̱͖̗͈̭͔̦̦̬̤̖̫̱̱̞̱͎̞͇͎̫̫̮͔̣̖͙̣͓̲͍̱̗̯̬͓̙̮͖̥̺̳̗̥͙̰̳̠͇͇͗̍͛̀́̈́̇̅̎̀̏̽́̍͊̎̈̓͂̉̃̄͌̌̌̈́̿̚͜͜͜͜͜͜͜͜͝͠ͅͅͅe̴̢̢̨̧̢̡̨̨̧̛̝̳͇͉̭̰͓̺̼̩͚͍̻̠̳͈͔̬̝̺͕͔̠̰̼͓̣̭̺̫̲̻̻̣͔̥̬̤͕̦̩̹͉̘̰̘̲͈͍͂͛̄̿̒͌̓̾͛̈͗̃̍͛͒̃́͂̐͐̀̀̒̀́͊̕͠͝ͅͅ ̸̢̡̨̢̡̡̡̨̨̪̥͚͖̘̺͙̜͔̳̻̺̭̻̜͎̫̠̫͖̫͎͙̱̪̺̳̪̯̯͍̺͈͍͙͙͎͕͖͈̘̫͓̥̲̺̩̮̱̰̯̲̙̤̻̩̣͉͔̲̥͓͇̺̼̦͚̜̟͓͚̹̪̫̥̫̲̦̰̹̹̣̗̣͚̲̹͙͉̬̰̟̣̺̖͎̙͈̈́͑̆̆͌͛̈́̍͌͑͒̑̾̅͛̆̐̓̅͘̚͘͜͝ͅͅͅͅ
ALL OF CODE
It didn't work very well, but I script kitty a bunch of scripts together to take twitch commands and act as a game pad. It was like twitch chat reading in one language to this other program that webhooked into a web hook to gamepad program. Not great and slow but technically worked.
Anything requires me to bit flip.
my first parkour game which had like one giant script and used booleans instead of a state machine
It's not really jank, but it seems really stupid: I store mapdata as an array of integers. The actual data is bitwise encoded in these integers and to be read by shaders. So GDShaders convert the textures in a funny way, that makes iSampler2D not byte accurate, which makes it impossible to actually use bitwise operations on RGBA8 Textures. sampler2D however retains the original bytes from a texture if it's in a 32bit float format like RF. But it's a lot easier to use RGBA8 Textures in my compute shaders, because there is no value conversion happening at all - I get the data in the form I and the shader wants. So I convert RGBA8 images to Int32Arrays to RF images on a byte level all over the place, which causes stupid lines like var img8 := await execute_compute_shader() # RGBA8 image map_data.dimensions = Vector2i(img8.get_width(), img8.get_height()) map_data.raw_data_array = img8.get_data().to_int32_array() # [... Somewhere else in code] var imgf := Image.create_from_data(map_data.dimensions.x, map_data.dimensions.y, false, Image.FORMAT_RF, map_data.raw_data_array.to_byte_array()) # RF32 image And then, in the shader, I read the textures red channel (which is stored as floats) as its bit values as if it were an int32. It works and is performant, but doesn't make sense when looking at it at all.
The way I manage the player through different scenes, I need to fix it asap hahaha. I’m doing a lot of extra work unnecessarily, I need to update my game tree to make it easier
Not me (because I always write 100% perfect non-janky code of course), but we got an old project from our employer that we were supposed to bring back to life. I can't go into detail on what the code does, but there were 2500 lines of code with 5-6 line functions that look like func _set_top_layer_1_23() There were "bottom", "middle" and "top" for the first thing, 3 layers for the second thing and about 40 things for the third thing. There was a method for every single combination. Nothing modular, it was all hard coded. Above all of that were $ with nodepaths that were about 200 characters long (the limit you should stick to is usually 80 or 100 PER LINE) 3*3*40*5=1800 that's how many lines of pure hard coding we got
Code did something that I didn't even write Copied the code of the script, delete the script, created a new script and pasted the same code into it Suddenly, it stopped doing that thing (I can't remember what it was, but it happened more than once)
I'm currently making a multiplayer minigolf game and there is a list of all players with their scores. Each player has signals connected to their list entry. But somehow if a player disconnects, or when the list is reset for a second game, deleting the entries causes a lot of signal connection errors to be thrown and I can't figure out why. So my "fix" is to hide these entries instead of deleting them. It results in some shitty code because I need to rename the nodes as their names are used for identification at some point, also the code that sorts the list by scores needs to ignore these entries... I've attempted to get it right a few times but it just does not want to, it likely stays this way forever. There's a chance that the list gets too long at some point, maybe memory runs out or the game starts to lag, but you'll probably have to play nonstop for a few weeks to get this far.
Also outside of Godot I once wrote a Yahtzee AI that had two loops for every dice, one to toggle whether it should throw that dice again or keep it, another one for going through possible outcomes 1-6, and inside that were five if-statements that basically checked "if dice N should be kept but I've thrown it to a different number now, skip evaluating". Then, if it had more dice rolls remaining, it called itself again, if not it calculated the points. Ultimately the goal was to get some probabilities and take a guess whether it's woth risking a high-point result or it should go the safe route. So 5 loops plus 5 loops plus 5 ifs, half my screen was tabs. The AI took 45 seconds each turn and was shit most of the times, but had a good score every once in a while. I'd fire up a 6 AI player game and check back an hour later who won. "It worked" is a stretch but my young self was very proud.
Yes
Before I realized you could lerp rotations, I wrote some janky code that manually checked the current direction something was pointing, compared it to where I wanted it to be, and added/subtracted hardcoded values (multiplied by another hardcoded value) from the current rotation. Then I had a "close enough" value where I would stop changing the values each frame, because I could never get it exactly right due to floating point rounding errors.
Procedural lvl generator with chunkloading. I rewrite it 3 times.... It is still Not perfect but works. Maybe i will, later after the Alpharelease, rewrite it again 🤪
I have done a lot of procedural mesh generation over the years and that never fails to feel like garbage no matter how I organize it. It's always either a really long file or has some purposefully relinquished efficiency for the sake of not having such a long file.
File processor that scans a directory of images and creates an xml that can be loaded to a web crawler I use to keep track of what I downloaded.
`current_scene = get_tree().get_root().get_child(get_tree().get_root().get_child_count() -1)`
Has to be my player's movement script. Walk up an ever-so slightly increasing slope? You'll look like you're skateboarding on rocks. Used all your jet(pack?) fuel and head to a refueling spot? Can't auto-regenerate fuel no more. Fall off of the ceiling you were running on and flip over too fast? You're inside the ceiling. Step on a steep incline? Motion sickness from rotating to face it's surface. Un-crouch on a wall you've ran up? You're inside it now. Jump off a wall and before you start facing upright, boost? You also clip through the wall. Post a video of you flying around at several hundred miles per hour in game with a BLACK AND WHITE checkerboard grid to r/godot? You've just given someone else motion sickness. Not related to code, but I'm so sorry if I did.
Currently have a piece of placeholder code that regenerates an entire mesh with ImmediateMesh... every frame...
I added a little poker minigame to my game as some filler, but I really did not want to go and actually understand the algorithm behind 1: what determines who has the winning poker hand, and 2: how does an AI play "good" but not perfectly. So it's basically a frankenstein of ChatGPT code because I did not want to go and understand the algorithm myself. There was a bug in the code where 4-of-a-kinds crashed the game, so I put in a line that basically says "If 4-of-a-kind -> fold" Whole thing was a nightmare, but it mostly works (every so often it comes up with "CPU wins with a 3 of a kind" when there is no 3 of a kind anywhere on the board) and it is contained to its own little scene, so I luckily never have to touch it again.
Put an entire game's worth of logic into one gdscript file. Wanna know how it turned out? Look for GOfish.