Breakout 2: Rage edition

An extremely hard version of breakout. Not recommended to play at work. An easter egg will occur when you beat level 7.

2 Likes

Nice work and thanks for the warning about playing it at work.

A couple of little things:

  • You used arduboy.audio.on(); and off() to control sound. There is a noTone() command to stop a playing sound.

  • Use the F macro, for example arduboy.print(“Breakout 2”); becomes arduboy.print(F(“Breakout 2”)); It will save you a lot of memory in the long run.

2 Likes

int troll = 0;…
Consider not having everything in int format as they can take up some space (not really, but something to know, so that you won’t run into memory troubles when doing something big.)


Pick the one with the size more relevant to the actual values of the variable you are using. (storing score as a int or short will be a good idea, but pedal and ball x & y only need to be short or even bytes. read the link. )
My friend could have scored higher in the AP test by following these…, because his program took up too many memory and was a bit slow…s…he got a 4 / 5.

Thank you the great advise.

Xavier,

Thank you for the great advise

1 Like

I hadn’t noticed before but you seem to have some odd character in your code, '\O' instead of '\0'.

(Though really neither make much sense, those should all just be 0.)

‘\0’ means “delete the data placed at that place”
I don’t know. Probably the font they use inside and outside the ’ ’ and " ". Didn’t seem to notice that at all.
Well it is not letter “O” or whatsoever, so…
Hmmm…interesting.

No it doesn’t.
\0 is the ‘null character’, which is often used for null-terminating strings (i.e. '\0' marks the end point of the string).

At first I thought it was a different encoding of 0 since unicode has some strange characters (for example + is a different symbol to +, despite both looking similar), but after checking rverything I can find seems to be reporting it as an O, so I’m guessing it genuinely is an O and the red syntax highlighting is supposed to represent “this is an invalid escape code”.

I really have no idea. But typing ‘\0’ yourself won’t be hard work.
In fact, if you are talking about other unicode symbols, you would be looking into the charmap.exe instead of the standard keyboard (so he either might be not knowing what is he doing or just copied something by nobody online). I still think it is the font…
IDK. (and since none of us know what exactly it is let’s just draw the line here.)

I know it’s not the font.

A font is just a way of rendering a character encoding.
When you copy text the actual bytes are copied (in whatever encoding they may be in).
That text can then be rendered in any font but generally the bytes will remain the same.
At most they will be converted to another encoding (e.g. converted from UTF-8 (the web’s favourite encoding) to UTF-16 (Windows’ favourite encoding)),
but unless they’re moved to an encoding that can’t handle them then the code point that they represent will remain the same.

That’s generally how encodings work.

The ‘\O’ does make a value a null. I had to use it because the list had to reset after completing each level. Assigning the value to a 0 did not work because zero is an actual coordinate on the game. Making it a value of zero caused the game to glitch every time the ball went to the top-left of the screen, which is coordinate (0, 0).

1 Like

That’s not what’s going on here.

Normally \ is used for escape sequences like \n and \0,
but in this case '\O' isn’t a recognised escape sequence so the compiler gives a warning
(warning: unknown escape sequence: '\O'),
then ignores the \and converts the 'O' to its numerical value (as per ascii), which is 79,
so effectively it’s converted to:

rectCordsx[i] = 79;
rectCordsy[i] = 79;

79 is an invalid coordinate for y, but not an invalid coordinate for x since the screen is 128 x 64 pixels.