The Bounce - A ball physics platformer

Thanks for taking the time for your detailed description.

That change was made in the Arduboy library long before I forked it to create Arduboy2, so it’s slated to go into the next Arduboy library release. If I can find the time, I’ll look into it.

If anyone else wishes to look at the changes and identify the problem (if there is one) you’re welcome to have a go.

EDIT: I have a feeling the problem is with this block in drawFastHLine():

  // if our width is now negative, punt
  if (w <= 0) {

It’s checking if w is negative but w is defined as a uint8_t, which is unsigned, so can never go negative! I think w has to be copied, or maybe just cast, to a signed int for manipulation and/or comparison. I may have a chance to sort this out later today.

I just copied the changes made in that commit and applied them to my current Arduboy library and I got the bug, so I can confirm that’s the cause.

Makes sense I guess, instead of making it negative and then not rendering it, it just loops it to maximum-ish uint8 size and draws a massive line across the screen… No idea why it makes it crash though

EDIT: Changing it to int16_t w fixed the issue, not sure if there’s a better way but your right that’s definitely the cause.

The easy proper fix is to copy w to a local int16_t variable and then use that in place of w for the remainder. I’d like to see if it can be kept as an 8 bit variable, though.

If a line is drawn near the end of the screen and ends up writing pixels in RAM past the end of the screen buffer, it would clobber other variables in RAM which could result in a crash.

I first tried a signed 8 bit but it still happened, I guess it’s over/underflowing, so then I tried 16 bit.

Ahh, explains why I got somewhat different crashes each time I messed with the level I was loading/the w variable.

I’m hoping it can be cast or copied as a signed 16 bit where necessary but then left as an 8 bit in the drawing loop.

I’ve made a Pull Request with what I think is the changes you meant, if I understand what you mean by the drawing loop. I tested it and it worked fine.

Options Menu along with Save files are in, accessed by the CONF option in the main menu. Levels that have been beaten can be chosen in the level select menu and the PLAY button will reload your previous progress while your playing through the game (If you’ve beaten the game it will just load level 1 like normal). Game is version 0.9 now.

Yes, I’ve looked at it. Thanks.

I’ve written my own fix using a different method and need to determine if yours is better than mine to decide which to use.

Note that you’re using tab indenting and will need to change the tabs to spaces in order for the pull request to be accepted, if we decide to apply it.

1 Like

Tabs versus Spaces?

I’ve done a fair amount of testing, including looking at the code size produced with various sketches, and timings using an oscilloscope. I’ve found that my way of fixing the problem results in smaller code size and runs faster than yours. It’s actually smaller and faster than the code with the bug.

I’ve applied the fix to my Arduboy2 library and the develop branch of the Arduboy library.

Although it wasn’t used, the time you spent working on a fix and pull request is appreciated, as well as your help in determining the cause of the problem. :smile:

Awesome, I’m glad the issue is fixed over anything else so it’s fine. Thanks a lot :smiley:

Just as an update (sorry for the double post, I can’t find the edit button on my original post?) I’ve added an ending to the game now, which is level 14. I was planning on getting at least 15 levels but I feel this is the correct length now. I had to do a lot of squeezing to get this much done anyway :smiley:
The game now runs on the Arduboy2 Library, so I’ve removed the custom library included with the Sketch, I’ve also updated the Hex file to the finished version.
I might add one or two extra levels, but I’ll probably move on to my next project now that I have free time again.

Thanks, and hope you guys enjoy :smiley:

1 Like

I added an update in the Versions section of your original post.

I don’t see any use of Arduboy2 in the code in the GitHub repository.

It sure would help if I updated the GitHub repository with the current code then!

Also thanks for editing my post, I realise now that the post is just too old for me to edit.


The code for this sketch on GitHub, as of Dec 25 2016, will not compile when using Arduboy2 library V4.0.0 or higher, due SPI changes in the library.

I’ve opened and issue on GitHub with details on how to fix this.

I’ve found that this game can suffer from the problem that prevents new sketches from being uploaded after this one is installed, and it doesn’t include flashlight or safe mode for recovery. Using the reset button may be required to upload a new sketch.

I’ve opened an issue about it.

Fixed both issues, thanks @MLXXXp

1 Like

I feel like this game could be like, next level amazing if some cool particle effects and more graphics were added? Like when it bounces off stuff it throws off some sparks and stuff. It would get pretty complicated pretty quick but I think this gameplay could benefit from some pizzazz.

1 Like

Can someone please help me with the last level. I believe I pushed all buttons but the finish line Is still closed, what should I do?