/r/howdidtheycodeit
"Wow, how did they do THAT?" - Ask here, get enlightened!
This subreddit is for beginner/intermediate programmers to ask about how a specific feature in a game (or other program) was coded, if they can't imagine themselves how they would go about doing it. Answers do not actually have to be what the game was actually coded with, but can explain another method of accomplishing it.
We have user and post flair! If you want to see some other categories, let us know!
Question
: Add this tag to your questions!
Answered
: Question = > Answer
Showcase
: Use this to tag your write-ups of your own features that make people say "wow, how'd they code that?"
Article
: Use this tag for shared videos and articles that describe how a feature is done
Submission Guidelines
(These are just suggestions, you can post without all of these, but the conversation will be more lively with a little bit of forethought!)
I created this subreddit because I am a novice coder who has often asked the question to myself when playing even small, indie games how a certain thing was coded. The thing that actually prompted me to actually create the subreddit though was a random, cool game, a Ludum Dare winner, Tangent: I was confused about how the circular transitions between different rooms of the game was accomplished. Example post about Tangent
/r/howdidtheycodeit
https://i.redd.it/extvqq080k3e1.gif
Anyone who has played Castle Crashers knows how fun and organic the battles against enemies are. The combat never feels linear or repetitive, and each enemy seems to adapt to the environment and situation. Moreover, even when multiple players are involved, enemies manage to strategically split their focus, targeting different players and taking turns attacking.
I've been trying to implement something similar in my game, but I haven’t been able to achieve a system as robust and natural as the one in Castle Crashers. If anyone knows how they developed this system or can share any tips or similar approaches, I’d be really grateful!
Hi everyone,
My team is developing a game where players can create their own dungeons, which need to be stored and accessed by other players who can raid them, even if the target player is offline. I’m looking for advice on the following:
Any advice, suggestions, or lessons learned from your experience would be greatly appreciated! Thanks in advance!
https://youtu.be/CIrAuLTwaaQ?t=36
Splines? Or lots or points around the map?
https://www.half-life.com/en/halflife2/20th
When you scroll all the way to the bottom and click on the Gravity Gun, you can use it on most of the text, images, and embedded elements on the webpage. They all have their own collision bounding boxes and physics. How was this done?
Another question I have, is: after the Gravity Gun has changed an element on the page, how would I make that element interactable before it was changed? For example, making the YouTube video embed on the page still interactable and play the video. Or text still selectable.
Dagster Labs somehow coded a redirect from an attempted right click save. Here's some more context:
https://www.linkedin.com/posts/dinoscheidt_userexperience-perfection-activity-7262370412271988736-3gGD?utm_source=share&utm_medium=member_desktop
https://x.com/_1mposter/status/1854283366440313258
They took a 3D model and made look like it was ASCII art but how?
I'm curious how did they implement the "whoosh"/"doppler" sound effect in "Need for Speed" games when you quickly drive past an object. For example in Need for Speed, notice the wind sound when the car drives past lamp posts, columns and such (sorry for long videos - see timestamps). I'm especially curious how they handled tunnels as it sounds really good and is exactly for what I'm after:
I'm thinking that they did a sphere physics query centered on the camera to check for an entered object, then they noted the object size and car velocity. Given these parameters they then adjusted the pitch/volume and relayed the audio effect at the query intersection point.
Having said this, I made a quick prototype to test this in Unity:
This approach works decently for small-ish objects, however if I'm roaming around a large object with lots of extrusions, my approach fails as I'm colliding with same object and my trigger doesn't fire multiple times. Additionally, it doesn't sound right in enclosed areas such as tunnels/caves or generally when surrounded by large objects. There must be some more complex system taking place here 🤔
Edit - found a possible way, here's my prototype which simulates this:
how do you code the movements in 2d games like champion island or stardew valley. specifically in godot
I've been seeing <username>@duck.com emails
What I wanna do is build similar for my custom domain which forwards email to my gmail address
What tools and tech is required.
About me: I'm a webdev (intermediate level) I understand frontend and backend.
Please guide me, Thanks. :)
I want to make an app like MyMind and, on top of that, also create graphical nodes (similar to Obsidian). How would one go about coding something like that? Since I know JS/TS, I'm looking into using ElectronJS for this.
Hi folks. I've always love the build system in Valheim and have just started about implementing something similar myself.
To my question: Do they have separate versions of each build piece at each possible rotation? (or at least many, not including reflections).
I ask this because the length of a 1 meter beam's length needs to change as it's rotated to make sure it ends at the correct spot on the underlying grid layout. Damn you Pythagoras and your Hypotenuse!
If they don't do that, do they scale the piece along its length depending on it's angle. Are they then mapping a new texture onto it or stretching the texture too because I can't say I've ever noticed the texture stretching as I rotate a piece.
Thanks in advance.
How do large scale apps like discord, Instagram, etc handle eventual consistency? I'm sure the database they use in the backend is sharded and replicated throughout several regions and each one needs to be in sync with the other. One of the best apps I see that does it flawlessly is Discord. On the other hand, reddit is one of the worst. Sometimes when I send a chat in reddit, it doesn't show up when I open the chat again for a while.
I know these apps also give the illusion of sending the messages by using optimistic updates but I am still wondering what exactly the frameworks, tools, languages are used to handles this. Especially with the extremely large volume of data
I'm making a game in Unity in where the player can build objects in a voxel style made of cubes. Objects like this L shaped you can see in this image:
But the player has complete freedom to build anything you can imagine:
So, my code is procedurally generating the meshes for these objects, one triangle at a time. Doing this is fairly simple if the game is limited to plain cubes.
The problem is that this is visually too much plain and not very attractive, so I'm planing change the cubes for a model a little more complex, that renders a little more detailed:
This is prettier but, given the triangles needed for this, generating this procedurally is way more complex:
I've tried diffenrent approaches:
So, my question is, before starting to code a complex algorithm to implement this mode, do you have another idea on how to do this? or at least a good idea on how to implement the last concept?
Thanks!
Can anybody on here speak to fast algorithms for checking "shelter" in survival games?
Most survival games I have played do a pretty good job of it instantaneously and I'm just wondering what kind of approach is used because it seems like a tricky problem. Like it's not just a roof over your head, you have to be somewhat totally surrounded by walls, roofs, etc. I couldn't find any generic algorithms.
Looking for actual experience - not just guesses.
The VideoLite app seems using a WkWebView or some other UIView to load the YouTube website. When the app is pushed to background, the video is still playing. There is a movie_player element on the page to play/pause the video. But explicitly calling playVideo() on the element after app is put to background is not working.
A lot of N64 games have gotten decompilations recently, and I have no idea how you even do that. Like if I wanted to try decompiling a game myself, how would I do it? Would I need an emulator for any part of it? Is it all just guesswork?
Not including tools that decompile games for you, like for example Game Maker or RPG Maker decompilers. Curious how people do it without access to anything of the sort.
Also related question: is decompiling even legal in the US? I know reverse engineering is, but does decompiling fall under those laws?
How did they achieve the “endless scrolling” world map that gives that globe type experience? e.g. when you reach the bottom of the map it wraps around back to the top.
Hello! I don't know if this is the right place for this, but I always loved the effect of a developing photo the loading screens in red dead 2 have, and was wondering how I could replicate something similar? Is it a shader or an animation of some kind?
I feel I’ve asked this some where on here but I’m having trouble finding it. So i had asked one of the developers of GTA 3 how cars knew to stop at stop lights. He explained that because traffic uses waypoints some of those points were marked if they were near the traffic lights. There were only two states All North and South lights were green or East and West points were green. Which made sense to me.
However my brain was trying to make sense of another element after this how are the actual traffic lights in sync with the node states. Because if you remove the actual traffic lights the traffic will still behave as if there is still management. Which makes it seem like the object and nodes are completely separate but are still in synch somehow. I was wondering how that was possible? Not a-lot of examples of this online from what I’ve seen and i didn’t want to bug him again so I decided to post here.
Apologies if this doesn't fit here, but I've seen really good feedback here before and hoping to get perspective on the "best practice" for this type of thing.
I've been working on small web game and have been running into this thing in multiple places where I'm unsure about typing with one larger and vague type or multiple smaller, but more specific types.
As an example:
In the game I have abilities for different skills. Initially I had one type for ability, but had to use optional keys for differences between different types of abilities (for example crafting ability would have keys ingredients and product for input and output, where as combat ability would have effects key for combat effects).
After a while I tried breaking abilities to multiple types, but then that had it's own issues. For example if I have variable like selectedAbility or activeAbility those could be of multiple different types leading to some issues.
Right now I'm wondering between following options.
Option 1, Original version, one type with optional keys. Would look something like this:
export type Ability = {
id: AbilityId;
name: string;
skillId: SkillId;
levelReq: number;
xp: number;
effects?: Effect[];
itemPropertyReq?: ItemProperty[];
product?: GameItem;
ingredients?: ItemId[];
cost?: number; };
Option 2, Separate abilities. Two examples:
export type AbilityCrafting = {
id: CraftingAbilityId;
name: string;
skillId: SkillId;
levelReq: number;
xp: number;
product: GameItem;
ingredients?: ItemId[]; };
export type AbilityCombat = {
id: CombatAbilityId;
name: string;
skillId: SkillId;
levelReq: number;
xp: number;
effects: Effect[];
itemPropertyReq?: number[];
cost: number; };
Option 3, Some other option?
Any advice on how to move forward would be appreciated. This feels like a thing where some learning from others experience would be beneficial rather than finding out 3 months from now that I chose wrong and have to majorly refactor things.
For example:
$ mysql -u root -p < script.sql
Enter password:
how can it still access STDIN? wont stdin be replaced by script.sql?
I'm curious if there is any non obvious way to code something that is essentially the same map but switching between universes/dimensions? Starfield had an awesome mission where you are navigating a ship stuck between two realities.
Is it always going to be just having two versions of the map player essentially teleports between? Or is there a way to reduce size of a level/scene by doing it in a layered fashion(say with clever viewport manipulation?). I dabble in programming and game engines so not very experienced, more curious than anything.