Homebrew working on a quick little wii racing game

newo

Well-Known Member
OP
Member
Joined
Apr 7, 2011
Messages
736
Trophies
1
Website
wiibrew.org
XP
2,581
Country
Jamaica
I think the cars spawn at exactly the same spot on every track. I havent checked but they should at the same spot everytime.

Porting this to anything else would be hard as i made it specifically for the wii hardware. Though its written in C there are tonnes of wii specific bits of code + grrlib. I would have to use something like SDL2 which would only slow down the game dev.
 

diggeloid

Alex
Member
Joined
Apr 29, 2019
Messages
359
Trophies
0
Age
32
Location
gbatemp.net
XP
1,478
Country
United States
Porting this to anything else would be hard as i made it specifically for the wii hardware. Though its written in C there are tonnes of wii specific bits of code + grrlib. I would have to use something like SDL2 which would only slow down the game dev.
Not necessarily, it depends on what the rendering code looks like since that's the hardest thing to port. If you're already using an abstraction over the nintendo APIs (which I assume grrlib is), then it's just a matter of re-implementing what you used on top of another portable API like GLES2. This would make it easy to port to desktops, android/ios, webgl, and even other homebrew consoles. Since you're a C programmer, you may find the Sokol project as a helpful tool here, so you don't have to write OpenGL directly.

I would suggest that you create a header and fill it with your own functions that are identical to all the grrlib/wii ones you're using (with different names). Then you create e.g. a source file called "myapi_grrlib.c" which implements those functions with calls to the actual grrlib ones. Then to port it, you just create "myapi_sokol.c" that implements those functions using sokol's API. You probably won't be able to do a 1:1 mapping, so you'll have to do some extra work to implement everything. Not a big deal as long as you remember basic performance stuff (like no runtime allocations)

The next issue would be input, but the game's control scheme is simple, and it should cleanly map to anything with 3 buttons. It also seems like you've already implemented support for different control schemes, so it might not be that much trouble to add some more.

And finally, getting it to build for another platform is the final major thing to worry about. I assume you're using Devkitpro. I haven't played with that in years, but IIRC it uses a build system based on Makefiles. That's probably going to be a pain to modify for your needs, so I would suggest in that case to just write a second set of build scripts for your other platforms. CMake is a good choice, but you should pick whatever you're most comfortable with. If you decide to go with Sokol, they have some good documentation on that subject.

Overall it's not a trivial amount of work, and you'll probably have to dedicate at least a few weeks to do it. But it may be worth it since it's not exactly easy to get people to play a homebrew game. Port this to PC, toss it up on itch.io, and you'll likely get way more players. We all make games for different reasons though, so it may not be worth it depending on your personal goals with this project.
 
  • Like
Reactions: newo

newo

Well-Known Member
OP
Member
Joined
Apr 7, 2011
Messages
736
Trophies
1
Website
wiibrew.org
XP
2,581
Country
Jamaica
@diggeloid Lets take for example the track in the game is rendered using primitives. The entire track rendered in one draw call, then the signs and then decals. The track primitives are altered in near real time as you drive down the track. If look closely as you play the game you can see the current section of the track gets brighter as the player moves along the track.

Things like this are annoying to "wrapper" because they are used all over the place with slightly different parameters (position, normal, colour). They need to be called in a certain order and in a specific context. The game doesnt do any runtime allocations. its just throwing lines, triangles and quads at the GPU as you drive along the track.

The advantage of coding to the metal is that I can build the game quickly (once I know what to do) without constantly having to refer to documentation. And I can do everything in engine.

The disadvantage is that porting it ends up being a nightmare. Some games are built to be ported but this game was not. Would be faster to just build a new game on PC but the PC game dev scene is chaotic.

If I used something like SDL2 from the start building the game from scratch then figuring out how to get it on the screen would probably take 2 years. Not really worth the time. Making a portable game takes away a tonne of your dev time. Its one of the reasons many people migrated to unity for the convenience. Or worse yet they start their games and never finish because iteration is so slow, they go down the shader rabbit hole or get distracted trying to support everything.
 

thenextgui

Member
Newcomer
Joined
Jan 6, 2022
Messages
10
Trophies
0
Age
21
XP
31
Country
United States
I was wondering why there isn't a timer or option to see how long you took at the end of the level. That seems to be an important element of racing games.
 
  • Like
Reactions: newo

newo

Well-Known Member
OP
Member
Joined
Apr 7, 2011
Messages
736
Trophies
1
Website
wiibrew.org
XP
2,581
Country
Jamaica
I was wondering why there isn't a timer or option to see how long you took at the end of the level. That seems to be an important element of racing games.

Its something i could add. I wanted to keep the game as casual as possible but this is a good suggestion for a future update.

Should i add a total time when you complete level 12? Or should i list the times for each track you complete? (might not hold on the screen).
 
  • Like
Reactions: thenextgui

thenextgui

Member
Newcomer
Joined
Jan 6, 2022
Messages
10
Trophies
0
Age
21
XP
31
Country
United States
Its something i could add. I wanted to keep the game as casual as possible but this is a good suggestion for a future update.

Should i add a total time when you complete level 12? Or should i list the times for each track you complete? (might not hold on the screen).
I know the Wii has low resolution so all the stuff might not be legible clearly. However I think it could be a scroll menu.
 
  • Like
Reactions: newo

diggeloid

Alex
Member
Joined
Apr 29, 2019
Messages
359
Trophies
0
Age
32
Location
gbatemp.net
XP
1,478
Country
United States
Without seeing your code, I'll mostly be talking out of my ass here :P, but I don't see why this couldn't be ported (relatively) easily. Even if you have API calls littered all over the codebase, then all you have to do is go one level lower for your abstraction/wrapper. If done properly, you wouldn't have to change a single line of code in the existing game (as long as your wrapper uses the same function names as grrlib)

I haven't done any Wii development, but I assume from your comment about shaders that (at least grrlib) is using a fixed function pipeline (also known as "old OpenGL"), so you specify vertices with something like:

Code:
  glBegin(GL_POLYGON);
    glColor3f(1, 0, 0);
    glVertex3f(-0.6, -0.75, 0.5);
    glColor3f(0, 1, 0);
    glVertex3f(0.6, -0.75, 0);
    glColor3f(0, 0, 1);
    glVertex3f(0, 0.75, 0);
  glEnd();

Those APIs are dead in modern opengl, but they're trivially easy to re-implement from scratch either in modern opengl, vulkan, or a wrapper like sokol. Basically just pre-allocate a vertex buffer and treat it like a stack. Maybe have a ring buffer to build multiple at once and minimize draw calls per frame.

If I used something like SDL2 from the start building the game from scratch then figuring out how to get it on the screen would probably take 2 years.
wat
I'm sure you're being facetious, but I'm fairly certain that SDL2+OpenGL is about the same effort as using grrlib (if not easier).

Again, I'm not saying you should port it, and I'm not trying to pressure you into doing it. It's just that if the only reason you're not doing it is because you believe it's too difficult, I feel obligated to discuss that since it's something I have experience with.
 
  • Like
Reactions: newo

newo

Well-Known Member
OP
Member
Joined
Apr 7, 2011
Messages
736
Trophies
1
Website
wiibrew.org
XP
2,581
Country
Jamaica
The difficulty is not in the starting of the port but more so finishing it. Its not really worth the time and effort to do a port when i could easily create a new game without the baggage of the old code. I know its possible, its just a rabbit hole.

If you look a NZ its really simple. A new programmer could probably build a similar game in unity in a couple of hours. But guess what they will fall into a rabbit hole of things to add and plugins and shader bugs. Meh, i dont want that life
 
  • Like
Reactions: diggeloid

newo

Well-Known Member
OP
Member
Joined
Apr 7, 2011
Messages
736
Trophies
1
Website
wiibrew.org
XP
2,581
Country
Jamaica
This is how the code basically looks. grrlib handles the initialization of the video, matrix math and png files while most of graphics as sent directly to the gx engine. Sometimes there are normals, displaylists, sometimes QUADs, TRIANGLES, LINES. Sometimes its loops within loops but the graphics is basically a stack as you said.

Code:
void draw_sign( guVector p, guVector r, guVector s, u32 c, u32 c2 ){
    engine_3d();
    GRRLIB_ObjectView( p.x, p.y,p.z , r.x,r.y,r.z, s.x,s.y,s.z);
    GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 5);  //GX_LINES////GX_TRIANGLESTRIP
    GX_Position3f32(-1.0f,1.0f,0.0f);        GX_Color1u32(c);
    GX_Position3f32(1.0f,1.0f,0.0f);        GX_Color1u32(c);
    GX_Position3f32(1.0f,-1.0f,0.0f);       GX_Color1u32(c);
    GX_Position3f32(-1.0f,-1.0f,0.0f);       GX_Color1u32(c);
    GX_Position3f32(-1.0f,1.0f,0.0f);       GX_Color1u32(c);
    GX_End(); 
 
    sign_width=s.x/sign_step_limit;
    GRRLIB_ObjectView( p.x,p.y,p.z , r.x,r.y,r.z, sign_width*sign_step,s.y*0.5f,s.z);
    GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 5);  //GX_LINES////GX_TRIANGLESTRIP
    GX_Position3f32(-1.0f,1.0f,0.0f);        GX_Color1u32(c2);
    GX_Position3f32(1.0f,1.0f,0.0f);        GX_Color1u32(c2);
    GX_Position3f32(1.0f,-1.0f,0.0f);       GX_Color1u32(c2);
    GX_Position3f32(-1.0f,-1.0f,0.0f);       GX_Color1u32(c2);
    GX_Position3f32(-1.0f,1.0f,0.0f);       GX_Color1u32(c2);
    GX_End(); 
}
 
Last edited by newo,
  • Like
Reactions: diggeloid

newo

Well-Known Member
OP
Member
Joined
Apr 7, 2011
Messages
736
Trophies
1
Website
wiibrew.org
XP
2,581
Country
Jamaica
@newo - happy new year! Just curious, do you think you'll continue working on this or move onto something else. Any plans at this point?
Happy new year to you too! No real plans at this point. I kinda just jump into homebrew, work on something for a couple weeks then move on to one of my other hobbies like photography or something else.

When i get inspired to write some homebrew again i will probably write something new. Newodefence needs to be updated and simplified - thats another thing i could possibly work on. Newomodelviewer needs to be updated as well. It all depends. I want to eventually make something in the fps genre like a doom clone. It all depends on how i feel at the time.

Just today i played NZ level 6 on arcade championship - its a challenging level with sneaky turns. I think NZ is a pretty complete game, there is not much i think i can add at this point. 60 tracks is alot for anyone who likes the game. Adding more levels would just make it tiresome to play. I like neat packages.

One person did ask about a 2 player mode. and a lap timer. Besides that i dont know. What do you think NZ needs?
 
  • Like
Reactions: banjo2

wiiAdventurer

Active Member
Newcomer
Joined
Mar 7, 2021
Messages
36
Trophies
0
XP
239
Country
United States
One person did ask about a 2 player mode. and a lap timer. Besides that i dont know. What do you think NZ needs?
Honestly, the game is great the way it is and I totally understand wanting to move on to something different.

I do think multiplayer would be neat.

As for other ideas:

  • If you ever played Sonic Racing Transformed, they have some non-racing levels. These levels have things like "Don't be hit" (with lots of parked vehicles) or "Race through all the rings in a set time". I don't know if everyone liked those modes but I think something like that would be interesting and give the player something to do outside of racing.
  • This is more work than it's worth most likely but I think a separate "championship" selection screen with a small preview of the races might go a long way to adding to that professional feel.
  • This would be a lot more important if you do multiplayer but different racers would be nice. This could be as complicated or as simple as you like. Something like: 1 vehicle that is super fast but has less durability, 1 vehicle of medium speed and durability, and 1 of slower speed but high durability (useful for novices). You could add more variations by introducing handling or more or less boost meter.
 
  • Like
Reactions: newo

newo

Well-Known Member
OP
Member
Joined
Apr 7, 2011
Messages
736
Trophies
1
Website
wiibrew.org
XP
2,581
Country
Jamaica
1 - sounds like achievements. It could be possible without distractting from the core game. Could put coins or something on the track to make for a alternate challenge.

2. Mariokart has these track trailors but its isnt really necessary since all the tracks look the same at the start.

3. Yeah split screen multiplayer is something I could look into. never did a split screen game before.
 
  • Like
Reactions: wiiAdventurer

Dcep1501

Well-Known Member
Member
Joined
Mar 29, 2018
Messages
187
Trophies
0
Age
43
XP
698
Country
United States
Hey guys, I created 2D cover art to be used in USB Loader GX if you have the wad forwarder and the game itself showing up in USBLGX. Enjoy!
 

Attachments

  • NEWO.png
    NEWO.png
    24.8 KB · Views: 6
  • Like
Reactions: newo

newo

Well-Known Member
OP
Member
Joined
Apr 7, 2011
Messages
736
Trophies
1
Website
wiibrew.org
XP
2,581
Country
Jamaica
Apparently the controls are seriously broken when using the nunchuck and wiimote setup. Never realised it until I was playing around with a nunchuck.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
    Psionic Roshambo @ Psionic Roshambo: Lol