/r/howdidtheycodeit

Photograph via snooOG

"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

  • Be descriptive! It's hard to guess how something was made without knowing what exactly the feature/algorithm is. Try including screenshots and/or links to gameplay if possible.
  • Collaboration is encouraged! It's okay if you don't have any idea, but writing down your thoughts in the question will help give other redditors a jumping-off point.
  • One size does not fit all! When writing your questions and answers, be up front about the tradeoffs you're considering. Memory or Processing time? Visual fidelity or Texture Budget? Small Indie Game or AAA Studio?

(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

38,354 Subscribers

0

Exploring new(not so self confident)

Noob to this zone ! hey subreddit(seniors) could someone help me with this coding, honestly have no idea where to begin(all I know is movies, gAmes 😅) TIA

3 Comments
2024/12/12
11:53 UTC

0

Krunker Multiplayer

Who is hosting?

0 Comments
2024/12/10
07:44 UTC

10

Monday Night Football game being "played/displayed/replayed" on a YouTube channel using Madden

How is this being done? I'm guessing they're reading data in (is there an API?) from a site like this

https://www.nfl.com/games/bengals-at-cowboys-2024-reg-14?active-tab=watch

So they take a live broadcast game on TV and show the game in Madden using play-by-play data and feed it into Madden?

0 Comments
2024/12/10
04:04 UTC

0

Until you Fall VR parry mechanic

For a few years I've had this idea of trying to make a VR Sekiro like game, then Until you Fall released, and it had the perfect recipe in my opinion.

Does anyone have any idea, tips, tricks or videos on how i can achieve similar results? Until you fall does not have physics based combat.

0 Comments
2024/12/10
00:09 UTC

12

Does anyone know what the name of the fur shading method that they used here on Jeff the Land Shark from Marvel Rivals? Trying to learn more about fur!

6 Comments
2024/12/07
18:15 UTC

2

How do I confirm if three separate "scenes" are actually running on one script?

I actually have the code for this. I'm having trouble understanding it.

I'm looking to find a specific area of gameplay in a 1990s PC point and click adventure game. Most of the areas (called "scenes" in the code) get their own script file. The script for this area only has procedures for entering and leaving the scene. The area has unique audio, unique use of conditions, and calls a movie file. I can't find direct evidence of where the area's files are used. Searching gives me 0 results.

But I have found small hints suggesting this area's might be cached in a script for a hub area. At first, I thought this was because the hub changes after this area is visited. Some graphics for the hub area and the area I am looking for are the same. Now, I think the programmers might have created a base scene that's reused for several similar areas. Using indirect asset names means they would not appear in the code when I search for them.

How might I confirm if this is what's happening, or confirm it's not happening?

The code is written in a variant of lisp that used a "yale interpreter." (Googling those terms gives no helpful results for finding the exact language.) Assets (graphics, audio and such) are referenced by ID number. Usually, this number is hard-coded.

I appreciate any help, suggestions, or theories. Thanks in advance!

11 Comments
2024/12/05
01:46 UTC

0

How does an chrome extension read texts from a google doc? Something like obsidian web clipper?

Basically the title, as google docs are not web pages but web based apps, how do they fetch the data from the google doc canvas?

3 Comments
2024/12/04
21:13 UTC

12

How were enemy attacks managed in Castle Crashers?

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!

7 Comments
2024/11/28
02:35 UTC

3

Advice on Building a Game with Player-Generated Dungeons and Persistent Storage for Live Services

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:

  1. What’s the best way to store and manage player-created dungeons or castles in a scalable and secure way?
  2. How can I handle instances for players who raid other players' dungeons? Should each raid be an individual server instance, or is there a more efficient way to manage this?
  3. What's the best way to secure the combat in these instances, in order to prevent cheating?
  4. What tools or services are recommended for handling the storage and instance management for a game like this?
  5. What are some common challenges you’ve faced with games that require persistent data storage and live services?

Any advice, suggestions, or lessons learned from your experience would be greatly appreciated! Thanks in advance!

9 Comments
2024/11/20
20:39 UTC

15

How did GTA 3 make their pedestrian navigation system?

https://youtu.be/CIrAuLTwaaQ?t=36

Splines? Or lots or points around the map?

3 Comments
2024/11/18
06:34 UTC

29

The Gravity Gun interactions on Half-Life 2's 20th Anniversary webpage

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.

3 Comments
2024/11/17
05:09 UTC

0

Redirecting to Branding Page when Use tries to rick click and save their Logo

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

1 Comment
2024/11/13
22:47 UTC

21

How did they render all kinds of vegetation in MSFS (Microsoft Flight Simulator) with extremely high rendering distances cheaply? Any secret technique?

7 Comments
2024/11/13
09:38 UTC

6

How they did this vfx?

https://x.com/_1mposter/status/1854283366440313258

They took a 3D model and made look like it was ASCII art but how?

5 Comments
2024/11/07
15:03 UTC

15

How did they implement the "whoosh" SFX in Need For Speed games

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:

  • I have a trigger around my camera.
  • The trigger tests for my target objects which should emit the "whoosh" SFX.
  • Once an object enters the trigger, I find the intersection point and position the sound effect at that point.
  • I then tweak the volume and pitch based on the estimate size of the object and player velocity.
  • Finally, I add some reverb to the audio effect and also enable doppler (I'm doing this in FMOD).

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:

Example

Technical details

  • I fire 4 raycasts from the camera.
  • Once a raycast hits an object, I place an audio source at that point.
  • If the raycast continues to hit an object, the audio source follows the updated hit point.
  • If the raycast fails, I leave the audio source at the last known hit position and stop the loop, in FMOD I made it so that the audio effect smoothly decays in about 2s to avoid rough cuts.
  • The audio source has a doppler effect applied to it, which means that once the raycast fails and the source stays at a fixed position - this allows doppler to take action.
  • This kinda works for tunnels/caves, however it doesn't sound the same as in the NFS example - I think as u/TheSkiGeek mentioned, this needs an additional, manually placed trigger or some other faked system.
  • Finally, I use pooling for the audio sources - I only play audio sources if they are fully stopped, I found that this prevents audio artifacts.
8 Comments
2024/11/07
14:47 UTC

0

Movement

how do you code the movements in 2d games like champion island or stardew valley. specifically in godot

6 Comments
2024/11/04
05:47 UTC

0

How are there so many AI-based apps nowadays? Do they pay API calls for known LLMs or do they run their own AI servers?

12 Comments
2024/11/01
22:21 UTC

2

How duckduckgo's email forwarder works

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. :)

5 Comments
2024/10/31
12:10 UTC

5

Valheim's Rotating Build Pieces

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.

5 Comments
2024/10/28
12:03 UTC

6

How do large scale apps handle eventual consistency?

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

1 Comment
2024/10/27
17:55 UTC

13

I need advice for not so simple cubes

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:

https://preview.redd.it/oph51bg5d9xd1.png?width=454&format=png&auto=webp&s=565b9618b4708a7af50c8240969ac168869949dd

But the player has complete freedom to build anything you can imagine:

https://preview.redd.it/mvybhraed9xd1.png?width=460&format=png&auto=webp&s=4c24bece6284a49e986b89c5a4c2bbf9b56e408b

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:

https://preview.redd.it/v1fsbu24e9xd1.png?width=535&format=png&auto=webp&s=7a338a836aebbf663d29f2715cb658533f1587e8

This is prettier but, given the triangles needed for this, generating this procedurally is way more complex:

https://preview.redd.it/h5jr712ie9xd1.png?width=527&format=png&auto=webp&s=acb313c886bd2cb1ce8dac45ccaf995c7c3c856c

https://preview.redd.it/8xyefukwe9xd1.png?width=517&format=png&auto=webp&s=8ac07f0ae5a87c299225eba817ad5a458250de81

I've tried diffenrent approaches:

  • Make the objects with separated cubes, but this feels cheap, I feels way better if the cubes blend together.
  • Render each cube in the object with a pregenerated mesh. To do this, I need a mesh for every possible combination of neighbour cubes. If every cube has 26 neighbours that can be on or off this leads to more that 60M different meshes. So I tried to reduce using rotations and simetries, and after a few calculations, I have still more that 60k unique meshes. So this is for now discarded too
  • So my last idea is to separate rounded edges, and faces, and calculate which one is needed for each position, and instantiate them separately, something like this image:

https://preview.redd.it/jppof5y6h9xd1.png?width=412&format=png&auto=webp&s=388705c3a10b4020da56f38dfa45f7ca3312659d

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!

9 Comments
2024/10/27
08:43 UTC

8

Shelter algorithms

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.

11 Comments
2024/10/22
01:21 UTC

0

The fact that this is even possible baffles me

7 Comments
2024/10/22
00:02 UTC

4

How videolite continue video playing in background?

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.

0 Comments
2024/10/21
13:06 UTC

35

How do you decompile video games just in general?

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?

9 Comments
2024/10/20
16:27 UTC

0

Instant Transmission in SPARKING ZERO... this game's such a coding masterpiece it tangle my mind

6 Comments
2024/10/20
06:22 UTC

0

How do people code price comparison sites then find a way to actually format the data

14 Comments
2024/10/15
18:18 UTC

7

World Map in Final Fantasy

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.

11 Comments
2024/10/12
20:55 UTC

Back To Top