Efficient coding for Gaming - /g/ (#105923263) [Archived: 240 hours ago]

Anonymous
7/16/2025, 9:04:29 AM No.105923263
1752524870988319
1752524870988319
md5: daee28eecca6795ebf87a1d88666481a🔍
Hey /g/, I'm interested in making my own video game and have started the leg work on making assets for it but I'm curious on how to go about learning efficient coding so I don't end up coding like this guy where I'm writing array after array with notes attached to them constantly reminding me what each one does.

While I'm still finishing up my assets I have been researching and learning more commonly used mathematical formulas in video games as well to get a better understanding of better functionality.

I'm just trying to make it on Godot.
Replies: >>105923435 >>105923498 >>105923946 >>105923970 >>105924014 >>105924421 >>105925720
Anonymous
7/16/2025, 9:07:19 AM No.105923277
>I'm just trying to make it on Godot
According to Notch you should make your own game engine
Replies: >>105923297 >>105923347
Anonymous
7/16/2025, 9:10:53 AM No.105923297
>>105923277
Ugh ok... I guess I might as well make my own compiler and operating system too before that...
Replies: >>105924154
Anonymous
7/16/2025, 9:13:00 AM No.105923304
You need to be a special kind of stupid to be like this guy or Yandere dev. Just don't be retarded. Study the source code for existing games, specially if it's idtech (quake, source engine, doom 3). Also unironically consider making your own game engine.
Replies: >>105923347 >>105923447
Anonymous
7/16/2025, 9:21:54 AM No.105923347
>>105923304
>>105923277
I guess I'll look into making my own game engine after all so it can be catered to my specific needs. Look forward to messing around with that
Replies: >>105923465 >>105923693
Anonymous
7/16/2025, 9:23:01 AM No.105923355
What kind of game, how much experience do you have with coding?
Replies: >>105923402
Anonymous
7/16/2025, 9:32:35 AM No.105923402
>>105923355
It's going to be like metal slug but just a chauvanistic knight that goes around killing witches and saving towns. I'm counting on feminist seethe to boost attention to this game. It's going to be called Burn the Witches like that Marilyn Manson song. I have some experience with fucking around with C++, Python, and Java.
Replies: >>105923427 >>105923444 >>105923450 >>105923457 >>105923903
Anonymous
7/16/2025, 9:36:29 AM No.105923427
>>105923402
lol
Replies: >>105923453
Anonymous
7/16/2025, 9:37:17 AM No.105923435
>>105923263 (OP)
>Godot
Consider Redot instead
Anonymous
7/16/2025, 9:38:19 AM No.105923444
>>105923402
Definitely consider Redot then
Anonymous
7/16/2025, 9:38:44 AM No.105923447
>>105923304
>Study the source code for existing games
Is that really useful if a lot of them are made for other structures?
Replies: >>105923693
Anonymous
7/16/2025, 9:39:46 AM No.105923450
>>105923402
>I'm counting on feminist seethe to boost attention to this game.
That honestly doesn't matter anymore. Both the progressives and the conservatives got psyoped into only caring about billion dollar companies.
Replies: >>105923488
Anonymous
7/16/2025, 9:40:44 AM No.105923453
>>105923427
Is that laugh to the game idea or to my lack of coding skill? As far as the game idea goes, I keep any project I start with a simple idea and build on it with layers. I was inspired by the song to try and make it and I just happen to be pretty talented artist with experience making some assets so visually I know it will catch some people's eye.
Anonymous
7/16/2025, 9:41:07 AM No.105923457
>>105923402
That's stupid, you are stupid.
But I'd look for a 2d platform framework for unity/Godot and use that as your bases. If you don't have experience with big software projects it's easier to edit others work than create your own from scratch..
Replies: >>105923528
Anonymous
7/16/2025, 9:43:16 AM No.105923465
>>105923347
whan someone wxill give you an advice on this board always ask "why?"
and
>because notch sed so
is no argumant at all
i bet that advice came from a vermin retard who knows shit and only from hearing

the smart thing to do is more nuanced, as usual
the real quesrton is:
>does your game necessitate technology that pre-made engines cannot provide?
if youre writing a minecraft, then by all means, write your own engine
youre gonna have a gorilion blocks to account for and pre-made engines just arent designed for that
if you dont, it would be motherfucking retarded to write your engine from scratch

and even then you still have two tiers:
do you use graphical libs like sdl
or youre gonna go all the way down an learn opengl/vulkan/dirctx
and in either case you need experience
which you dont have
because experience would also prevent you from writing dumb shit like the other retard, pirategames or whatever
so if you had experience you wouldnt even be asking that question

use a pre made engine
use something simple
and instead of learning about the code, learn organization first
when you write a game, you start with a proto type to check the idea, the gameplay loop
you do that before assets, you do that in a pre-made engine
also keep in mind the first product you will create will be shit
first attempt is always shit for everyone, thats how learning works. dont pour your sould into your first project, youre gonna throw it away anyways
your objective for now is to find a fun game loop
leave optimization for later, for when building a game engine is actually justified
Replies: >>105923563 >>105924283
Anonymous
7/16/2025, 9:46:45 AM No.105923488
>>105923450
Seriously? I thought the trannies, feminists, and lgbtq+ along with whatever diversity hired over at triple A game studios were seething over indie developers kicking their asses and being chuds or something. I'm still making this game though. I'm m in too deep to give up with all the drawings/art work and assets I have made with them. Besides this is going to have a lot humor in it between all the horror and dark stuff and should still be fun.
Replies: >>105923505
Anonymous
7/16/2025, 9:48:12 AM No.105923498
>>105923263 (OP)
I abandoned godot. I spent more time reading docs and debugging than deving, very discouraging
Anonymous
7/16/2025, 9:48:42 AM No.105923505
>>105923488
>were seething over indie developers kicking their asses and being chuds or something.
Rarely specific games and even then it's only a twitter trend for a day at best. I'd rather pay for some streamers to play it.
>I'm still making this game though.
Don't let me stop you just reconsider your PR strategy.
Anonymous
7/16/2025, 9:51:26 AM No.105923528
>>105923457
Well duh, that's why I thought Godot would be good. Also there are lots of games like Metal Slug style there should be enough to copy and try to work my way around making it functional. I'm not trying to make an mmo, I figued this is simple.

I didn't say it was it was a smart premise for a game, it's supposed to be low bro with a Dante's inferno style humor thrown in.
Anonymous
7/16/2025, 9:58:01 AM No.105923563
>>105923465
I appreciate this advice.
>learn organization first
So I should be making a story tree/decision tree and get a loop going for players to get invested in the game.

>first attempt is always shit for everyone, thats how learning works
I'm looking forward to the headaches of learming from my mistakes but didn't Toby Fox get pretty successful with his first attempt? By no means am I trying to replicate that but I'm not trying to be pessimistic about it either.
Replies: >>105923638 >>105923649
Anonymous
7/16/2025, 10:11:10 AM No.105923638
>>105923563
>So I should be making a story tree/decision tree and get a loop going for players to get invested in the game.
not yet, this is story
a story without an engaging gameloop wont make a good game because players wont stick around for the story to develop
conversely, you can have a chad gameloop without a story, and thats how you get doom
by organization i meant organizing your project
what should be done, and which order
usually it starts with a pitch but youre not talking to a publisher, so start with the gameloop
what will be player activities, test em out

example: if your story is dependent on the gameloop like, idk, space pirates, but youre a janitor, and the game consistes of hours of cleaning the halls until you get blown up
its not a fun experience bc the gameloop of cleaning halls isnt fun
therefore you have to change the story. you can still be a janitor, but now the ship gets attacked and you rise to the occasion by defending it or something
the story is there to ground the gameloop
evendoe you seem to have your ideas down already
and its a metal slug
the story can be anything. you could be a chibi housemaid shooting fukken cleaning product at antropomorphic dirt
which also simplifies the stage of gameloop, since its a metal slug. were hardly breaking new grounds here

if i were you id try to get a good gameloop down
controls need to be tip top since metal slug is a fast playing game
probably experiment with various game mechanics, like, idk, cover? maybe use enemy bodies as such?
what about bosses? what makes em engaging in the og metal slug, what about other sidescrollers like castlevania etc
you dont even need proper assets for that. also artistic work is what takes the most time because you cannot accelerate inspiration
so organizationally i would interleave experimenting with assets and experimenting with gameplay, with a priority given to gameplay because you might discover that an engine is not suitable for xyz reason (1/2)
Replies: >>105923722
Anonymous
7/16/2025, 10:12:56 AM No.105923649
>>105923563
(2/2)
you might find out that your engine is not suitable for xyz gameplay reason and end up working with an engine with different capabilities, invalidating your artistic work
as in: "we counted on particle systems to augment the experience but now we dont have em anymore and so we have to rework all our assets"
you dont want that
youre a solo dev you need to make your work as efficient as possible
organisation helps with that
Replies: >>105923747
Anonymous
7/16/2025, 10:18:20 AM No.105923693
>>105923347
I'd start by making a rendering pipeline with SDL and OpenGL. Even if it's a 2D game OpenGL gives you hardware acceleration and you can do cool things with shaders easier than brute forcing it manually.
>>105923447
Yes because a lot of the same concepts apply. How do you intend to load your assets? How do you handle keybinds? What does your rendering pipeline look like? How do you manage in game objects?
For example, it's always a good idea to have a client-server architecture even if it's a single player game. You also should almost always move objects by manipulating a single velocity value instead of trying to apply all the transformations directly. Separating your game logic from your rendering pipeline will automatically make you better than most modern "gamedevs".
Replies: >>105923737 >>105923759
Anonymous
7/16/2025, 10:21:23 AM No.105923722
>>105923638
Okay I have a better understanding what you mean now and will get started with just seeing what I can get working mechanics wise and base the game around what I'm capable of making work. I'm glad you mentioned the side scroller Castlevania because I was going to draw inspiration from that as well. I'm not claiming to be genius here but I'm keeping it simple enough to where I know it's do-able. I think my max estimation timewise for this is that it will take me about 2 years of hard work to the point where I'm satisfied with it but I don't mind working on this outside of my job and I think it will look cool experience wise even if it flops.
Replies: >>105923802
Anonymous
7/16/2025, 10:22:50 AM No.105923737
>>105923693
Why opencl instead of vulkan?
Replies: >>105923806
Anonymous
7/16/2025, 10:23:58 AM No.105923747
>>105923649
>"we counted on particle systems to augment the experience but now we dont have em anymore and so we have to rework all our assets"
you dont want that
Yeah this is exactly what I want to avoid.
Replies: >>105923802
Anonymous
7/16/2025, 10:25:25 AM No.105923759
>>105923693
sdl- yes
opengl- forget about it, op is a beginner
wo serious study opengl is just too much at once
not only you have to understand how a gpu works, but opengl provides a framework which is based on the rendering pipeline, not the architecture of a gpu
and in result you have to learn how a gpu works and then map the rendering pipeline onto that
i managed but its because i come from a gpgpu background
and i still find it fucking annoying to call essentially the same thing 3 different names depending on where in the pipeline an object appears
Replies: >>105923806
Anonymous
7/16/2025, 10:32:03 AM No.105923802
>>105923722
>>105923747
godspeed + (you)
look what mechanics people like, why do they like em
theres also another sidescroller you might want to have a look at- cuphead
it was big at a certain point
thats gonna define the engine
once you get a satisfying loop, focus on the assets and the story
advertise, get beta testers
idk, discord, youtube devlog, many ways to achieve that

then polish
publish
and make monie$$$
Anonymous
7/16/2025, 10:33:01 AM No.105923806
>>105923737
OpenGL has less boilerplate and is more documented. Using Vulkan would be even more based, but beware of dragons and don't blame me if it's more than you bargain for.
>>105923759
OP is also making a 2D game (I think), he just needs to get to the "textured triangle" stage and he's set. Then the Z-index will help him avoid spaghetti code from trying to blit textures directly in SDL.
Replies: >>105923829 >>105923835
Anonymous
7/16/2025, 10:35:37 AM No.105923829
>>105923806
>OP is also making a 2D game (I think), he just needs to get to the "textured triangle" stage and he's set.
actually, youre not wrong
when i hear opengl i immediately think compute shaders and how 3/4 of the game actually runs on the gpu
but you dont need to use all the functionalities of opengl to make a good product
Anonymous
7/16/2025, 10:36:14 AM No.105923835
>>105923806
I'm thinking of sticking to pretty much 2D right now. That should be simpler, right? I have seen some cool side scrollers using 2d and 3d backgrounds though
Replies: >>105923902 >>105924048
Anonymous
7/16/2025, 10:40:31 AM No.105923871
public struct StoryState
{
public bool LearnedToWhistle;
public enum HaveMoneyKind { No, Dollar, Coins, Unused }
public HaveMoneyKind HaveMoney;
//etc
}
Replies: >>105923878
Anonymous
7/16/2025, 10:41:32 AM No.105923878
>>105923871
since its a struct you can just dump it into save state as bytes.
Anonymous
7/16/2025, 10:44:58 AM No.105923902
>>105923835
the jump from 2d to 3d is quite big involvment-wise
especially with opengl
BUT
you could use 2d assets to render a 3d scene using parallax
because the big difference is in how you render the assets

if its a 3d asset you have to compute a whole scene, and a point of view, and you have to pass the whole geometry to the gpu
geometry which needs to be associated with the corresponding textures
everything is matrix maths
3d assets would make the whole project quite more involved mechanics-wise
with 2d assets all you do is draw flat surfaces
and you could emulate 3d using parallax

if you will be using 3d assets,
you will basically be drawing a 3d scene just with a fixed point of view
Replies: >>105923928 >>105924048
Anonymous
7/16/2025, 10:45:03 AM No.105923903
>>105923402
Fuck I forgot to add the Marilyn Manson song that was inspiration for the game idea and art was Dogma.
Anonymous
7/16/2025, 10:47:23 AM No.105923915
I've got 20+ years of game programming experience ranging from sole projects to working at 1000+ employee AAA studios. If it's your first time I'd really recommend just getting to making the gameplay as fast as you can. Prototype using something off the shelve like Redot, Unity, UE etc. Once you (hopefully) have something fun to play that alone will give you a much clearer idea of what to do on the technical side. The prototyping phase is probably the most important phase of the whole dev cycle imo.

A lot of people say write your own engine, I wouldn't really bother with that at first, just write what you need for your game if you decide to go fully self coded and eventually you'll just end up with a small collection of functionality you can export as an engine for your next project. This is how just about every engine out there started as anyways.
Replies: >>105924201
Anonymous
7/16/2025, 10:48:17 AM No.105923928
>>105923902
>everything is matrix maths
I have unironically been practicing matrix math before making this thread to get a better grip on it for programming. It's crazy how useful it is.
Replies: >>105923969 >>105924019 >>105924048
Anonymous
7/16/2025, 10:51:29 AM No.105923946
>>105923263 (OP)
Just learn to program the way normal people do using a course or textbook of your choice. His code is basically the code that someone on their first week of learning to program would write it, when they haven't been taught about loops and such yet and are just writing some trivial "input two numbers, get the sum output back to you" training thing to teach them the absolute basics. If you're not totally retarded you'll be writing better code very quickly.
Anonymous
7/16/2025, 10:52:53 AM No.105923960
Reminder this guy fucked one of his ferrets
Anonymous
7/16/2025, 10:54:30 AM No.105923969
>>105923928
>It's crazy how useful it is.
in graphics? absolutely. everything runs of matrix maths
theyre just very appropriate for the context
elsewhere? mmmh... not so much
in os dev for instance id expect tons of stats related stuff, but not matrices
everything heuristics is gonna contain stats in one way or another, probably very abstracted from the traditional maths too
Replies: >>105924000 >>105924019
Anonymous
7/16/2025, 10:54:41 AM No.105923970
>>105923263 (OP)
I think ending up like that guy is alright as long as it works. You'll find a better way eventually unless you're just as dense
Anonymous
7/16/2025, 10:59:10 AM No.105924000
>>105923969
>in graphics? absolutely. everything runs of matrix maths theyre just very appropriate for the context
Now that you mention it, I guess I'm coming at this game developing thing from the graphics side first all together instead of the game mechanics side which should be first. My approach to this was going to be all wrong. This is how you know I mostly work on visual/artistic crap and not coding...
Replies: >>105924019 >>105924030
Anonymous
7/16/2025, 11:02:31 AM No.105924014
>>105923263 (OP)
You can make good games with renpy and rpgmaker. Especially if you want to focus on making your own assets and art.
Anonymous
7/16/2025, 11:03:00 AM No.105924019
>>105923928
>>105923969
Matrix maths is the most important maths for gamedev, you use it everywhere. There's plenty of decent libraries out there already so you don't have to reinvent the wheel with coding up all the common operations at least now.

>>105924000
Yeah the actual graphics and look of the game can be decided much later. First make sure you have something that's actually fun to play.
Replies: >>105924094
Anonymous
7/16/2025, 11:04:13 AM No.105924030
>>105924000
>This is how you know I mostly work on visual/artistic crap and not coding...
i immediately saw that
artistic types tend to lack rigor in their planning
also one starts with stuff that one's comfortable with
and you jumped right into the creative part

people will berate you over it
but the artistic part is actually harder than the programming
you can learn to program properly
but you cannot learn talent
actually, you could do ok in both with schooling i guess
because talent is a thing in programming too
but you can lower your standards and just sprint through a project code-wise
you cant really do that with the assets. they all have to be coherent in style and quality
Anonymous
7/16/2025, 11:07:23 AM No.105924048
>>105923835
>>105923902
For a side scroller you don't even really need matrix math. Just Z multiplied by a fraction that feels right.
>>105923928
>I have unironically been practicing matrix math before making this thread
Based. You'll have no problem with OpenGL then.
Replies: >>105924050
Anonymous
7/16/2025, 11:08:35 AM No.105924050
>>105924048
Sorry I mean X and Y multiplied by Z multiplied by a fraction that feels right.
Replies: >>105924146 >>105924207
Anonymous
7/16/2025, 11:14:58 AM No.105924094
>>105924019
>Matrix maths is the most important maths for gamedev, you use it everywhere.
~
mmath is a system of representation
you oculd use mmath in stats
but in most cases its a very inefficient approach

ill give you an example thats fresh in my mind
i make a buffer for parsing
and i want it to decay throughout time
im gonna use stats bc thats the tool to use for this case
i decided to base myself on the assumption that your datapoints follow a normal distribution (empirical rule)
but i dont compute any of that
i have a ratio, two counters, and the biggest mem use for this set
i use that to identify when the distribution of my dataset changed,
which indicates im in a different dataset
which indicates i have to resize my buffer
its very simple maths because you let the dataset and its properties do the maths for you
Anonymous
7/16/2025, 11:23:35 AM No.105924146
>>105924050
yeah ofc but thats unless you use 3d assets (with 2d you also need to set the w vlue iirc, to set depth)
you still could get away with doom-like 3d rendering wo mmath but it just makes sense in the context of 3d assets
mmath operations just map very well to various transformations of 3d objects
i suck at mmath, so i couldnt explain to you in details, esp its gonna be a while i havent done anything with opengl, but its stuff like to rotate a whole scene you multiply the whole matrix by the sine/cosine of the angle. done
but theres more to it, the fact that your pov is the origin of your coord system also plays a major role in the system its efficiency, and the reason why mmaths are preferred
Anonymous
7/16/2025, 11:26:14 AM No.105924154
>>105923297
It's not that difficult to make your own engine with SDL3 is a base. It's like a steep learning curve followed by smooth sailing. If you use godot it's an easier start and then nightmare mode, you'll end up writing your own engine in the end one way or another, literally everybody who started with a off the shelf engine ended up writing their own afterward.
Replies: >>105924184
Anonymous
7/16/2025, 11:30:57 AM No.105924184
>>105924154
But why would you do it especially as a beginner who doesn't know how to make portable code?
Replies: >>105924199
Anonymous
7/16/2025, 11:34:21 AM No.105924199
>>105924184
Godot was coded by amateur retards, so you can do it too.
Anonymous
7/16/2025, 11:34:52 AM No.105924201
>>105923915
>Redot
Fart
Anonymous
7/16/2025, 11:36:13 AM No.105924207
>>105924050
>yeah ofc but thats unless you use 3d assets
which are a series of triangles in a 3d coordinate set, with textures projected onto each one of them
which creates a cloud of 3d coords so to speak
which then changes the maths completely
thence the difference
3d asset = set of triangles in 3d = 2d maths no longer suffices
theres tricks doe
like pre-rendering your assets and streaming them as 2d sprite
Anonymous
7/16/2025, 11:53:18 AM No.105924283
>>105923465
>when you write a game, you start with a proto type to check the idea, the gameplay loop
this is the hardest part. ngl.
It's mind shattering and exhausting.
Replies: >>105924334
Anonymous
7/16/2025, 11:56:11 AM No.105924296
appo-marketing-n
appo-marketing-n
md5: 9fc1d3843f4ea9f46620bdf85e3c7e77🔍
>streaming
which means something completely different inside opengl and outside of it
in opengl that means changing a texture
outside opengl that means showing a texture thats changing
in practice you have a big ass texture thats your individual frames and you cycle between their coordinates

i just love fukken rendering pipeline s <3 (not, i want to kys w/a brick)
Anonymous
7/16/2025, 12:04:14 PM No.105924334
ai-suicide
ai-suicide
md5: 6ab8e0f54544d12945b5bf615f1510e7🔍
>>105924283
rly?
in my very limited attempts that was the more entertaining part for me
maybe youre doing things wrong
the problem might be your code:
as in- its not modular enough so every change is a chore

or it might be your approach:
try running the game in your head
try to visualize what experiences would evoke which emotions
then make it into a coherent mass. thats a good point to also start your storytelling
your gamaloop will define the laws of your universe
and storytelling will ground them in-universe
as in: you have dragons, magic, then your story should support that
but also: you have an insurgent game? then your story should explain why youre the underdog in this situation

then put it into prototype so that youre confronted with the technical side of the problem too, in practice
and, ofc, you experiment with the interface then
an adequate interface is paramount, and is often neglected, even in established studios
cf. dungeon keeper 1 vs dungeon keeper 2
minute changes in the way you interface with your creatures completely changed the gameplay
and while dk1 was a hit, dk2 was not bc the gameplay got flattened, simplified.
bc of the interface.
Anonymous
7/16/2025, 12:19:40 PM No.105924421
1734876006837212
1734876006837212
md5: b2fb7bbba4135d0c29cd87386bf4fdca🔍
>>105923263 (OP)
learn about data structures and their advantages/disadvantages. that's it. just being aware of their existence and being capable to recognize a situation that one fits will make you never write trash code like this and yanderedev.
Replies: >>105924443 >>105924479
Anonymous
7/16/2025, 12:23:17 PM No.105924443
>>105924421
>muh datastructures
>autism
when you learn the mechanics of memory you dont need that
its a more fundamental knowledge
it like learning a multiplication table vs learning to multiply
Anonymous
7/16/2025, 12:26:00 PM No.105924464
conceptually mem mechanichs isnt even hard
just limit your memory accesses as much as possible and mind where youre storing your stuff because not all storage has the same characteristics
beyond that its just learning said storage characteristics and experience until you integrate the above
Anonymous
7/16/2025, 12:27:49 PM No.105924479
>>105924421
also the pirategames retard did collision detection without an early exit clause
no memory layout would help with that
Anonymous
7/16/2025, 12:29:32 PM No.105924495
>did collision detection
did *per pixel collision detection
Anonymous
7/16/2025, 3:09:06 PM No.105925720
>>105923263 (OP)
github id software