Content

NewoFox Postmortem (programming)

Page is part of Articles in which you can submit an article

written by owen on 2018-Apr-26.

So I finally finished another of my hobby programming projects that I tinker with from time to time. This one is called "NewoFox" after a popular SNES game from 1993 which starred talking animals flying spaceships. My version does not have the talking animals part (nor barrel rolls), mostly just the flying and space.

When I started programming on wii hardware the first game I thought to build was a starfox clone. If only I had known it would have taken me 7 years to actually gain enough knowledge and skill to make it a reality. And even at this stage where I have finally published my most feature complete piece of video game homebrew that I have ever coded - IT IS STILL NOT DONE! The devil is in the details.

In an age where you have game consoles with 8 GB of GDDR5 RAM why would I still want to code on something with only 24 MB? There are have cellphones with more RAM than that. Maybe I just like torture myself or maybe I like having constrains in software my development. Constrains force me think creatively, efficiently and cautiously. I am not even sure what I would do if I had 8Gb of memory to play around with, I might have tried to write minecraft or code shaders all day. This might be another reason I do not take up Unity development because when you have a boundless field in which to play, you often end up doing nothing at all or worse yet end up writing plugins and widgets.

It may be the case that hobby projects are never done. You just keep working on them until you either give up or die trying. Considering where I started from with NewoShooter, then onto NewoAsteroids, NewoEscape and then finally NewoSky. I realise now that I was building up a knowledge base in order to achieve what I wanted to achieve so many years ago. If I had known all that I knew now, back in 2009 when the wii homebrew scene was buzzing at a healthy clip I would have probably been a famous game developer by this point in time.

But some knowledge comes with time or maybe luck. I am not sure. NewoShooter went through many versions and updates, even had an embedded Lua scripting language for writing custom levels. At some point in time I think I peaked and I learned as much as I could learn from the project and moved onto something else. Sometimes you have put somethings down so that you can clear you head.

While NewoShooter(NS) and NewoFox(NF) are similar on the surface. The later fox has come a long way in almost every aspect. NS was one monolithic main.c file while NF is a streamlined modular main.c with 3447 lines of C and 37 included files. The whole thing take 1.5 minutes to compile. Main.c takes 16 seconds by itself.

So I am not going to ramble on and on about logic or control structure or Object oriented programming like I did in the last post mortem. This time I am simply going to dump a file list with short descriptions.

File List

aabb.c (2.1K) - basically 2 [Axis Aligned Bounding Box] functions that I use for most of the collision checking

animate.c (7.0K) - a background process that applies an easing function to float pointers (max 100), mostly used by the menu.c and explosions for juiciness.

cloud.c (2.4K) - simple procgen clouds that are generated using a noise.c grid

collision.c (34K) - The [Spacial Grid Index] I use to manage the interactions between object types in the game. Object types such as bullets, asteroids, player and anything that needs high speed collision searching. Object types are stored as a set and only interact but querying cells. Made up of a struct containing a 3d int array, 3 1d int arrays for each axis. The 3d array stores 3d keys while the 1d arrays hold the values. Its complicated.

common.c (4.9K) - common functions that I use everywhere such as randnum(); and timer() which is not frame rate independant and also a control structure.

draw.c (28K) - draw lines and cubes
engine.c (9.5K) - 3d/2d switching, graphics init
explosion.c (12K) - spawning and managing explosions. 30 explosion max, 400 particles max

fading.c (2.0K) - controls the screen fading in/out to white. It is also used as a control mechanisim e.g. if(fading_is_done()) player_died=true; Tricky bit of code.

frustrum.c (2.8K) - A set of 6 increasingly large cubes that I use for AABB screen space culling when rendering.
ground.c (26K) - manages, caches and draws the procgen terrain and water.
http_interface.c (22K) - manages http thread and requests.
input.c (14K) - manages the pointer and all the controllers connected to the wii
language.c (4.3K) - translation array for switching between interface languages, memory mapped
leaderboard.c (11K) - updates and displays the leaderboard screen
loading.c (9.2K) - loading screen, threading and animation.

main.c (123K) - inits, draws and monitors game logic in a contantly running while loop. Lots of arrays, structs and for loops. player_asteroid_collision(); bullet_ground_collision(); bullet_asteroid_collision(); bomb_bullet_asteroid_collision(); game_next_level(); game_logic(); etc.

menu.c (22K) - draws and manages the menu, submenus and thier states. only supports array key input. one big recursive function that draws and interacts with itself. max=40, max items=200.

mp3file.c (6.5K) - loads and plays mp3 background music. max = 10
[b]
noise.c (10K) - contains the grid based sdnoise generation functions for spawning objects and picking from numeric ranges based on the incline of slopes. higher frequency = more chaos.

object3d.c (50K) - loading, drawing, loose collision detection for Wavefront OBJ files.
rock.c (2.2K) - spawning trees and rocks using noise.c, 4x4 noise grid

sdnoise.c (30K) - sdnoise1234, Simplex noise © 2003-2011, Stefan Gustavson, mostly 2d noise is used

setting.c (6.8K) - manages the loading of the settings file, memory bound pointers, default values and saving the file when the game exits. max=200

sndfile.c (5.0K) - sound effects little edian file loading and playback. max=30
spritesheet.c (7.8K) - loading of png graphics and animating spritesheets. max=30
stardust.c (2.3K) - the effect of stardust flying by the player. 256 lines max
starfield.c (3.9K) - the stars in the background, bound to the player position. 2048 dots.

statistic.c (4.8K) - custom achievements and stat checking, complicated. max=150, relationhips max=600

threading.c ( 10K) - thread management, only used for the loading screen and http functions. Everything else is running in the main thread.

vector.c (9.0K) - vector functions for finding normals and calculating simple physics
water.c (5.3K) - water animation and surfaces
wii.c (1.6K) - wii specific code

third party stuff

http_parser.c (69K) - by Joyent Inc is based on src/http/ngx_http_parse.c from NGINX copyright Igor Sysoev
easing.c (9.9K) - Robert Penner Easing Equations used by animate.c
grrlib - wii homebrew game dev API

Conclusion

There is not much else to say really. It is a simple game that took about 4 months to put together using 7 years of programming knowledge, trail, error, cheating, TDD and hacking. Not to mention the numerous youtube videos I watched in order to get ideas for efficiency. Too bad the wii does not output images in a higher resolution than 640x480. But alas I leave you with a selection of a few early development debug screenshots. If you have a wii with the homebrew channel installed you can download it and play it right now. Otherwise you are out of luck. Maybe one day I will pick up Unreal engine and do some PC game dev but until then; Have a great day.

Explosions

Explosions

Trees in space

Trees in space

User interface Menu

User interface Menu

AABB Collision Detection

AABB Collision Detection

related image
Boss Orb

Boss Orb

Water trail/Wake

Water trail/Wake

AABB Frustrum

AABB Frustrum

StarField Bug

StarField Bug

World space interaction

World space interaction

Object on Object AABB - failed

Object on Object AABB - failed

AABB on big models

AABB on big models

Model Space AABB

Model Space AABB

Spatial Grid Index

Spatial Grid Index

Simple shadows

Simple shadows

Flat planet

Flat planet

Placeholders

Placeholders

Rendering the water plane

Rendering the water plane

Ground grid

Ground grid

Ground LOD

Ground LOD

Early procgen

Early procgen


permanent link. Find similar posts in Articles.

comments

    Comment list is empty. You should totally be the first to Post your comments on this article.


comment