Gamedev from Scratch 1: Scaffolding
eev.ee
eev.ee
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.
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?
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 ..
it's all about the feeling
Celeste's player class: https://github.com/NoelFB/Celeste/blob/master/Source/Player/...
Just deliver.
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.
I’m personally not strict about TDD. Maybe pragmatic testing development (PTD)? And this is indeed because people have surfaced legit critiques about testing on game software (disposability of the game software, radical sweeping changes of the codebase, etc).
The critiques people have surfaced in response to my OP are valid too in general… but for me I’m trying to embrace a zen of automated testing where I want to do it by default but won’t let it block me from delivery. There just seems to be unconsidered value in writing certain genres of automated tests.
E.g. I’m fine writing a test that asserts behavior on “prefabs” (like classes, whereas instances of the class are game objects in a scene (for those not in the know)) instead of on individual components. This is from experience; the prefab’s behavior typically doesn’t change even if the underlying composition of components might radically change.
Remmeber, don't write production code without a failing test first.
But just to attempt… to TDD a graphics shader one would have to consider the side effects of the shader to be able to craft a test for it.
And then to reverse once again, given a graphics shader is typically up to the vis artist and that artist would need to muck around to find what looks good, it almost doesn’t make sense to write a test at the beginning.
For me, I don’t typically write non-disposable write tests on my shaders. I just make the simple shaders. If it’s a tricky shader, or I want to capture a funky edge case, I’ll write a disposable test so I can try to iterate faster on the shader. Running a test that takes 1-2 seconds to see results for each iteration of code is faster (for me) than waiting 20-30 seconds for Unity to load my test scene. I still have to visually check it at the end of the process but I find for my workflow it helps me go faster.
I wouldn’t dare say “it’s good for me, therefore everyone needs to do it.” I’m just sharing my experience.
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.
I tried to be clear about that. Sloppiness at work could kill someone or bankrupt the company. You're being paid to be a professional, so be a professional and write tests.
You only have so much free time to achieve your dreams. Cut every corner you can to make it happen.
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…
For basic CRUD and simple business logic I see TDD work. But for example most projects I work on I have no clue what or no clue how to do it. I just write code, play around get new ideas and build upon that. It changes so frequent and is so exploratory that I can not be bothered writing any tests.
Once I "get it" I write some tests. Mostly I understand also what will need tests and what not. Personally I think this if fine.
Online everyone is writing the ideal situation. I know what to deliver, I know how to do it and this is the perfect way to do it. Mostly it is I have taken loads of assumption and figuring it out as I go. Fuck it needs to be done don't have time to "optimize" it to look perfect.
Maybe I'm just not a good developer. But I shipped enough value in my lifetime to know I'm good enough ;)
IMO I suspect we as an industry haven’t spent enough time considering the role of automated tests in video game software. I worry that it’s been written off for so long that it’s a self fulfilling prophecy. Since there isn’t tons of time spent thinking about testing whenever anyone attempts it they run into issues. When seeking help they are told tests are a waste of time. They do waste time because the “what is effective” patterns are still being discovered for as complex of software as games.
Maybe I am actually just not a good developer… But I really think there is something worth exploring.
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.
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'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.
There’s only a handful of long duration games under active development anyway.
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.
No code before a red unit test.
Pretty sure the first post will talk about my experience building out a simple prototype in React + PixiJS, the landscape for JS development, and rationale for rebuilding in Rust/WASM/Bevy and then the second will be on my experiences learning those tools and opining on the pros and cons.
Would that be interesting to people? Are there specific aspects of development that people want to read more about than others? I don't feel like I have much to say on graphics and sound assets or anything like that (yet?)
The pros and cons of the tools you mentioned. As a hobby Unity dev I appreciate reading about the ups and downs of tool chains excluding the big-3 (Unreal, Unity, Godot).
Harrumph!
A) is the thing maybe gonna intersect with the thing?
B) how much does the thing intersect with the thing?
C) move the things so they aren't intersecting.
I don't know, the author might go into more detail.I agree with you, PICO-8 is fun and I can knock an original game in a weekend without worrying about any marketing or slogging through content.
PICO-8 and the TIC-80 are both great little platforms that will push your creative juices without getting you bogged down in realistic graphics, hi-q music and assets. It's also a pleasure to do as it's very easy to navigate and comes with all batteries included.
I trust they’ll disconnect the two at some point.