Mitty the Kitty

I’m new around here, not sure of the conventions around posting games, but here’s my first effort! It’s a pint-size platform game (without platforms!) that’s about a minute long:

My kids (5 and 4) and I made a little video game for the Arduboy open source 8 bit platform with 1 bit graphics. The children did the sprite work (graph paper!) and game design, I just implemented what they described!

It’s playable in-browser so you don’t need to peer into a 1 inch wide OLED to play! Although, sound doesn’t work in-browser for whatever reason.

8 Likes

Nice little game! I can’t seem to “duff” the birds, though.

@Pharap certainly won’t like these though :stuck_out_tongue_winking_eye:

Great getting the kids involved!

Good thing it isn’t his game!

@gavd.co.uk you can post a hex file in your original post and it will put an ‘in-browser’ version at5 the top of the thread. Sort of like this:

1 Like

I was just joking because he sure does love his constexprs.

I know … #defines are evil and all that :slight_smile:

1 Like

I guess they are though because they’re just text substitution.

Nice to see someone actually used AB Sprite Editor to make/convert their sprites.

I’d be interested to know how you got on with it, and whether you only ran it on Windows or also tried the Mac version.

A highly underrated tool.


I notice in the repo you mention:

Although if there’s a nigh-zero effort better way to publish a binary that I can easily update, lemme know!

Are you aware of GitHub releases?

That’s the typical way most people handle distributing binaries via GitHub.

Another approach would be to distribute them in a separate repo I suppose.

You probably know this, but the main reasons people say not to distribute binaries as part of the source code’s repository are:

  • The binaries become desynchronised with the source, unless you rebuild the code every commit.
  • They can end up being superfluous, either because the source makes them redundant or because for some people the binary is for a different system.
    • That still applies to Arduboy, because homemade packages with different hardware setups can’t run a .hex built for the official system
  • It can lead to the source taking longer to download
    • This applies more for desktop and repos that maintain multiple binaries for different sytems, it’s less of an issue for Arduboy because .hex files are small and reasonably easy to compress due to being plaintext, though they’re still often larger than the source itself.

Also in regard to

you can’t render sprites at a subpixel location

I’ve no clue if this is technically true since I’m not really a hardware expert, but there certainly are techniques other than scaling integers.

Obviously there’s float, which I presume you’ve avoided due to the memory footprint. (Or perhaps you didn’t realise that AVR can still use float?)

Another option is to use fixed point arithmetic, which is like floating point arithmetic but the radix point doesn’t move around, it stays in the same place. There’s a library for that (which, full disclosure, I am the author of). Though if you don’t want to use the library, you can just learn how fixed points work and write your own code. They’re cheaper than floating points for certain types of code and may be cheaper than using multiplication and division, but your mileage may vary.

Lastly, just to point it out, Arduboy uses C++, not C, so you don’t have to use ‘bare globals’ - namespaces and classes are available (as are enumerations, scoped and unscoped).


Putting words into my mouth before I even get a chance to read the code?

Anyway, it’s not a matter of what I like and don’t like, there’s many good reasons for prefering constexpr variables (or even const variables) over macros. Remember, this is stuff I’ve learnt from people who are probably far more knowledgable than I am.

They do still have their uses, but the legitimate uses are ever dwindling as C++ improves.

As of C++20, even __FILE__ and __LINE__ have a better alternative. Configuration macros (i.e. for testing compiler version, target processor et cetera) and conditionally including files are pretty much the only things left that can’t be done better by a different feature.

1 Like

I really like the idea of running back to the beginning of each stage whenever you get hurt. :blush:

thanks for the feedback folks! I very much appreciate it! :+1:

@Pharap I figured macros was a good way to save memory but my C++ is based on having read K&R 20 years ago. The only C++ I’ve done before is an Arduino synth and drum machine so I’m learning as I go :slight_smile: I’ll look into constexpr

Re: AB Sprite Editor - I ran it on Windows. I usually use a Mac but I couldn’t get it to work right away on Mac and couldn’t be faffed setting up parallels or a VM or whatever so I grabbed my Windows laptop to copy the sprites the kids drew into AB. It’s a great tool, only thing I’d like that it doesn’t have is an undo feature (unless I missed it!).

I can’t remember why it didn’t work on Mac; I’ll give it another shot when I have some free time.

@gavd.co.uk you can post a hex file in your original post and it will put an ‘in-browser’ version at5 the top of the thread. Sort of like this:

Thanks filmote - I saw that but I tried dropping the hex in the original post but the BBS said “Sorry, new users can not upload attachments.” I guess I jumped the line :rofl:

Are you aware of GitHub releases?

I am :slight_smile: I should really set up Github releases - my day job is a devops consultant so I really should do things “properly” :smile: Added to my TODO list!

Obviously there’s float , which I presume you’ve avoided due to the memory footprint. (Or perhaps you didn’t realise that AVR can still use float ?)

Yes, that was my thinking. To be honest this game kind of evolved over time, I started out with pixel-based movement then realised I needed greater resolution so bodged up a bit of scaling. I’ll look into the library you mentioned, thank you!

Lastly, just to point it out, Arduboy uses C++, not C, so you don’t have to use ‘bare globals’ - namespace s and class es are available (as are enum erations, scoped and unscoped).

Nice, would be good to get a bit of encapsulation going :slight_smile: I’m a hobbyist whose games background was in QBasic in the 90s and then Flash in the 2000s, then recently I released a JavaScript RPG, and it’s fun to pick up C++.

I really like the idea of running back to the beginning of each stage whenever you get hurt. :blush:

Thanks crait ! (Sorry, new users can only @ mention 2 users in a post)

Thanks everyone for the warm welcome, I shall look to incorporate the feedback :slight_smile: The biggest win for me is doing a project with the kids, when I was 4 my dad wrote a BBC Micro game under my direction so it’s great to pay it forward!

2 Likes

Compilers and the language itself have improved a lot since then.

On Arduboy, and probably most Arduino platforms, const variables and constexpr variables typically won’t end up using memory because a round of ‘link time optimisation’ is performed before the executable is generated and this eliminates any variables that:

  • Aren’t modified
    • Which applies to all const and constexpr variables
  • Can have their values calculated at compile time
    • Which applies to all constexpr variables, but not necessarily to const variables

So it’s safe to use const and constexpr as one would normally in a desktop program. (As for why they’re better than macros, see the answers to this SO question.)

https://www.learncpp.com/cpp-tutorial/compile-time-constants-constant-expressions-and-constexpr/

Did you see the note for Mac users?
If that doesn’t fix the problem then I’m not sure what will, I’m not really a Mac person and don’t have access to a Mac to test on.

I’ve more recently added a .dmg version in addition to the .app, which I’m told may work better, but I can’t vouch for it myself.

It doesn’t. I know of a few ways I could add one, but the best ways would involve a fair bit of work, so understandably I don’t want to spend the effort unless I’m sure the software is actually finding sufficient use.

There isn’t really much to set up.
Create a ‘dummy’ repo and give it a try, you might be surprised at how easy it is.
(Especially compared to command line Git.)

I’ve never quite understood what ‘devops’ actually is.

Let me know if you need any help with it.

I really ought to get around to documenting it properly, but it’s not too hard to deal with provided you understand how fixed points work. (If you’re not, there’s a basic introduction provided in the extras folder.)

I briefly dabbled with its modern successor QB64 during my college years.

Recommended resources:

(Though bear in mind those are aimed at ‘desktop’ C++ rather than ‘embedded’ C++, so there will be a few differences, particularly with availability of libraries.)

Trust levels go up based on engagement - things like how many topics and comments you’ve read, for how long, how many things you’ve liked, how often you visit the site, et cetera.

So basically just read through a few topic threads and the limits will be removed before you know it. (You can always go back and edit a comment afterwards.)

Some good topics to start with would be:

By the way, if you highlight the bit of text you want to reply to and click the ‘quote’ button that appears, it’ll insert an attributed quote into your reply. Those also notify users of the fact they’ve been quoted in a way that an unattributed quote won’t. (You can tell the difference because an attributed quote includes the original commentor’s name and user icon above.)

1 Like

I was just joking :flushed:

It should work perfectly because .dmgs are meant for containing apps and their data.