NewoGame Profile picture
Oct 28 23 tweets 5 min read
The main reason i dont open source my homebrew is because the code is super messy and experimental. Its wasnt written to ported like doom or quake. Lets look at newozero; #thread
In nz the track, the player and the camera are basically co dependant structures. Joined at the hip. Though drawing the track is separate strangely enough.
The track is using a spatial grid, frustum, distance list and a big array to figure out what to draw and collide with the player. It also tells the camera where to look.
Basically everything is stored in structs ala C. Whenever i can store a value instead of calculating it i will pin it to the struct without mercy
Every module has a init(), animate(), draw(), gethits() and a exit() function. There are roughly 40 c files including wind, road, building, sign, grid and stars.
Everything runs on a timer. All the time. Definately not framerate independent so it has to be 60fps or not at all. Timers are everywhere waiting to fire all the time.
The only reason most if it even works is by knowing exactly which systems interact with each other and ensuring that none of them end up stepping on the others.
There is no threading. Alot if it is time splicing and ensuring that the per frame cost of everything is low. If a tree falls in the forest and there is no one there to see it does it make a sound? There are no falling trees.
There can be no intesections on the track because of how its drawn. I could refactor it in the future but it will not be pretty. Too many things to change. Too many optimizations to undo.
All the signs know which building they are posted on. So since there are 4x more signs than buildings they all check if the building they on is visible instead of using the frustum. Saves so sqrts.
The menu is a recursive function that draws itself similar to how you print out a directry structure. Over all my years of coding its the only time i have found such a simple solution to UI. All the menu options are pointers to in game global variables. #gamedev
I rebase my code often once i find a cheaper way to complete a task. Because i am the only one working on it i can add/remove optimizations based on what i want to achieve instead of whats more compatible.
Git doesnt add anything to my workflow. I dont miss any of the code i delete. It either works or it doesnt. Sometimes i am tinkering with multiple modules to get one thing to work. If it doesnt work then rebase.
Here is an example of a system in the game where the track is drawn based on the position of the player and the frustum but there is a bug in this video. who can guess what the bug is?
Even the math functions i use are crude. I took a look at the standard frustum culling code and was like; nope i am just gonna do everything with AABB. Octree? Nope, spatial grid. Linked list? Nope fixed arrays.
If you have any questions about how any of it works i am always willing to help. It may seem complicated when its all put together but its really just a collection of simple parts.
Oh the spatial grid had a bit of magic so avoid that just do an octree.
I do put comments into a few sections but its mostly for things NOT to do as opposed to the thing being done. If there is a section which look like it can be easily optimized but shouldnt i will put a comment there to stop myself from doing the obvious. #gamedev
Some times i imagine i would have an easier time writing homebrew games on the ps4/5/switch/ #unity /3ds/#UnrealEngine5 but i fear i might fall into a shader rabbit hole and never come back out. #gamedev
I use multiple paradigms. depending on the situation. Sometimes they converge+overlap. Modern code tends to try to stuff everything into OOP. I like to wild out ex; procedural, functional, passing by val, by ref, time splicing, partitioning, whatever gets the job done
Predicting which paradigms I use for which problem depends on several things; the time it will take, speed, complexity, code size, maintability, error rate, magic etc. So you cannot blanket the code with ECS or something like that it will just break in mystical ways.
Some systems (the track) have multiple variables scattered over the code that can be tweeked for a desired result. This means that there are multiple places where you could uset the system or cause a domino effect. Its like climate change the video game.
look at this; why am I doing this?
static bool seek_back=false;
seek_back = !seek_back;
if(!seek_back) for(int i=0; i<TRACK_MAX; i++) game_track_seek(i);
if(seek_back) for(int i=TRACK_MAX-1; i>0; i--) game_track_seek(i);

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with NewoGame

NewoGame Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @NewoGame

Nov 3
I need to find the time to do a postmortem on all the changes i made in NewoZero v3. Even though they should be easy to spot.
Download NZv3 from the link if you have a real wii or @Dolphin_Emu (u will have to figureout that yourself but it works) wiibrew.org/wiki/Newo_Zero
I changed a few of the track decals creating alternates. Added strobes in the tunnel sections to brighten them up abit.
Read 7 tweets
Jan 4, 2020
Today was a long tedious day of digging into my old #procgen #landscape engine. Trying every trick in the book to get it running at 60fps on the #wii but thankfully I made some progress! #thread #gamedev #lowpoly #screenshotsaturday
Fixed some strange bugs in my simple view frustrum and increased its size
Moved the clouds, water and mountains to the correct position in the render list in order to reduce alpha-transparency bugs
Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(