by sovietmudkipz · 3y ago · 0 comments
However; I shutter in horror at the thought of embarking on this journey for myself. This is a statement about me rather than a general statement. I know I fixate on problems and “perfect” solutions at the detriment of my project’s velocity e.g. TDD for my game projects —- especially since most tutorial code isn’t written with testing in mind. I highly suspect I would be doomed to misery if I tried.
Maybe if/when I get more skilled. I feel like projects like these are an expression of programmers who are very comfortable and experienced with writing complex systems.
it's all about the feeling
Celeste's player class: https://github.com/NoelFB/Celeste/blob/master/Source/Player/...
Just deliver.
It's a game. Treat it like one.
TDD is great for your day job, where you ship bulletproof software for work. Nobody does work for fun. Look at how many games are written in Java.
For a personal project, only write unit tests to ensure specific bugs get fixed. No more. This ensures you do the least possible amount of Work.
In the end, you'll say holy shit, I have a ton of bugs to fix-- that guy was full of shit. But you'll have a functional game to fix the bugs on within a year, rather than a pile of exquisite code that does nothing after a decade.
Test as appropriate for your needs and goals. Adjust over time. There is no need to artificiality skew the balance in either setting.
You don't TDD a game mechanic as soon as you make it - you can wait until you're reasonably sure, and then use TDD to flesh out the corner cases.
You can also TDD at the lower level - such as your LOD algorithm, or culling algo, etc; these don't really change much once you know you need them.
Remmeber, don't write production code without a failing test first.
TDD means you write a failing test case first before you write the actual function. You don't need TDD to "run a unit test to test a function in a fraction of a second".
TDD is only good when the spec is unambiguously defined (either in your mind, or written by a product designer). For example if you need a function that tests whether two AABBs are overlapped, TDD is perfect. But in game development, sometimes the spec is just "write a water shader that looks good enough", and "good enough" is not unambiguously defined. Therefore TDD is bad in this case.
https://hitchdev.com/hitchstory/approach/snapshot-test-drive...
Write a scenario that uses a new water shader - eyeball it - if it's good then "fix" the snapshot and pass it around.
Repeat with a few other scenarios to see it performing under all relevant circumstances.
It can be a bit tricky if the result of the shader is not deterministic - but there are sensible ways of dealing with that.
TDD may be helpful later, but as long as you don't yet have a fun gameplay loop everything else is a distraction.
Finding the fun, though…
Do you really want to have to update a test every time you want the jump button to have more or less force, when tuning your platforming mechanics?
I have the same, which is why my current game is still not released.
Perfectionism made me reject all existing engines and write my own (I do use a physics libary, box2d, but actually am thinking about writing my own soon). I am happy with the result now, but I really had to learn to cut corners and abolish perfectionism again.
And now that WebGPU has come out(I programm on the web), I have to restrain myself to not overhaul everything again, because the GPU would unlock so much more power, making awesome new things possible in the simulation beneath..
So I am just doing one simple wgsl module to speed up one important part of the simulation, giving hopefully great performance improvements. And then do it all differently and right with the next game..
"Maybe if/when I get more skilled."
And the alternative would be tonstart now, making a very simple game, or using an existing engine.
It depends what you want to do. If you are really into complex systems, then yes - making everything from scratch, UI, Game logic, Rendering - then it all really gets complicated soon and if you didn't start right, you will never finish.
But a simple game, like a flappy birds clone or something alike, is not too complicated and will tell you, if you are really into it.
Just give it a try in a language you are comfortable with.
And of course there is no shame in using the right frameworks, libaries and engines, if you mainly want to get stuff done and play the result (which is very rewarding). Or rather, if you really want to ship a game, that runs stable and bugfree also on other peoples computers, then you will have to use existing work, or you won't get far, or will be buisy with it for a looong time, if you want to do anything not trivial.
But OP especially wanted the hard way of doing it from scratch..
I’m now waiting for interested engineers like you to update Unity to enable use of web GPU. I embrace that it’s not a topic I want to care about as a creator, but instead as a consumer.
Because the GPU are in fact lots of small cpus, meaning if you want performant code, it has to run parallel.
And then the fun starts with sharing ressources, coordinating etc.
So the code and data has to be structured very carefully, if you want actual improvements.
And this is not new to me, but I have never done it for something serious, so far. So for my intended use case is should work, as I need to do lots of raycasting and this is where GPUs shine. (But I still need to figure out the compute pipeline)
But in fact, I do intend to work something out, enabling other people to make use of it without having to do the deep dive.
At least in some cases ..
There’s only a handful of long duration games under active development anyway.
ChatGPT even wrote a game for me and I thought the same then. I think this might be related to why I write so many dashboards as a hobby.
Spectating is pretty cool by itself perhaps?
Don't write any kind of code, none of it, without a failing test first is the motto.
Not only does it test your game under sort of realistic conditions; it also gives you constant feedback on whether the game is fun, interesting, engaging — something that's infeasible to test by code.
Development of a game engine is a different matter, and affords itself to classical TDD, to my mind. You can write formal tests ahead of time, because you can feasibly understand what you want to be implement before you implement that.
I've probably implemented platformers physics about 15 times now, and have a pretty good idea of how I personally like structuring game code.
I’ve done them using TDD as an inexperienced game dev, test free, TDD now that I have more experience, and it’s helped me clarify some of my own thoughts on how automated testing can fit into my workflow.