Trivia Game (WIP)

Had the idea to make a trivia type game today and spent most of the day putting this together. I’ve got most of the guts fleshed out already, but I’m having trouble getting everything to operate the way I intended. Been scratching my head for a minute at this one, though maybe that’s the from the sleep deprivation that often comes with being a maker :wink:

Any help or insights as to why things don’t seem to be working or ways to improve this code in general would be greatly appreciated! I’ve got a few other projects I’ve been struggling with that I’ll likely post about soon, but this one seems the most manageable for now.

There’s a detailed description of how the game should work at the beginning of the .ino file, and I’ve went ahead and included a png of a visual aid for how the game should flow. Thanks again if you can help!

Arduboy Trivia on Github.


I think no one has answered as your question is really open ended. What exactly are you looking for help with?

You might like to look at enum classes for the game state variable and use these explicitly rather than gamestate++;. Adding one to the game state might work but its hard to read. Also look at your naming conventions - what is GS2() and formatting.

1 Like

Thanks, I’ll go ahead and change things a bit to be more readable! I wanted to make a simple function for most of the gamestates, so “GS2()” is the function for Game State 2, though I can probably think of a better naming convention, so I’ll change that too. The main issue I’m having with the code itself is that one the first question comes up, the player can’t press anything to interrupt the timer, and once the time runs out, it tries to print what seems like every string & bitmap used at once, and I can’t seem to figure out why.

Should be much easier to read now! Also helped point out a couple human errors (player one /and/ two functions ended up going to player one’s outcome) so I cleaned that up as well. Still don’t know why it’s dumping strange data to the screen after questioning both players, though. Experimenting now with ways to solve this/figure out why it’s so strange.

I think the rendering issue is caused by the data in the arrows images.

When using Sprites::drawOverwrite() the dta should start with two bytes that describe the width and height, followed by the data itself. They look wrong as the H / W are very large compared to the data itself. This has the effect of the arduboy rendering a lot of junk after the image.

How did you create this data? What tool did you use?

You should be using this one > Arduboy Image Converter

1 Like

You will also want to look at the F macro and how to store arrays of strings … PROGMEM - Arduino Reference

1 Like

This was very useful! A closer look at the arrays and I realized they were all the same data and I hadn’t even realized I overlooked the H/W bytes! I used the tool you created for the Game Jam 4, Coder’s Toolbox as I find it and ASE to be easiest in overall use, but it seems that Coder’s Toolbox was only outputting the data of the first image to serial for each image I had drawn, and I just copy & pasted, renaming the arrays but not really looking too close at them to realize they were all the same. I usually use ASE as it outputs the H/W bytes and has the option to load from serial as well, but Coder’s Toolbox will have a neater result, which I much preferred in this case.

I didn’t know about the F macro and wasn’t super familiar with storing a 2d array for strings, so that was super helpful! The code is much better now, just need to iron out a few more issues (namely timing & button handling) and add more content. I’ll post back here again with updates soon!

If you use Coder’s Toolbox, compile a new copy from the GitHub repo at GitHub - Press-Play-On-Tape/CodersToolbox. I ran into the same problem and submitted a fix, but I don’t think a new binary has been posted.

1 Like

Ah … so it’s my fault! :grinning:

I will recompile a hex and post it up in the thread and I’m GitHub tonight.

Actually, I have recompiled the HEX now in the repo and on the thread.


Right on! I was using the default hex that was on the arduboy FX mod chip, so I guess its compiled version is outdated. I switched it out for the new one and it’s working fine now!

I also just updated the code for this trivia game on github. I’ve finished all the text that the game uses and updated the functions, now (almost) everything is working smoothly. There’s just two things left for me to do:

  1. clean up coordinates of sprites and strings for each question, so nothing is overlapping, this is just an aesthetic issue, as I used the same coordinates as a template of sorts for different Q/A screens.
  2. For some reason, if the timer runs out when it’s either player’s turn, it gets stuck at 0 before switching to the screen informing the player they’re out of time. this is an issue because the timeout screen uses the same timer. before switching gamestates the timer is set to an appropriate interval for the gamestate in question’s purposes. With the problematic function, it was set to 100 before switching the gamestate, but it doesn’t seem to do so when the code is run. I must be missing something because I have very similar functions in other places that do not have this issue. Any insight would be appreciated, I’m still somewhat new to C++ and while I understand a lot of concepts, I always sometimes have trouble implementing them.

Oh, I’ve also given the game a proper title:
FrankenMacCharDeeDen: The Trivia Game

Just finished actually! v1.0 out now :slight_smile: