# Mystic Balloon - 9th TEAM a.r.g. game (39 levels)

Great game!
When i complete damn 29th I take a breath.
WRONG!
I finished 30th level 2 hour ago. It take 2 full recharge to gain the “touch of climb”.

Now I can study the code to understand what I see during game. For now, I don’t understand vec2 struct, but with a little step I’m pretty sure to get something.

``Marco``
1 Like

Thanks @Nono_Nano, @Gaveno is on a trip to Europe, but when he’s back I’m pretty sure he’s willing to explain the vec2.

It looks like it implements a vector and code to handle operations over that vector, for example `vector1+=vector2;`

1 Like

I can help there. If I had a pound for every time I’ve had to write a vector I’d be able to afford a few more steam games.

A vector in mathematical terms is a multi-component object that represents a direction in cartesian coordinates (x, y, z etc). (It can also be used to represent a space).

In the case of this `vec2`, it’s a two-dimensional direction using `int`s.

It has a default constructor that initialises `x` and `y` to `0`:
`vec2() : x(0), y(0) {}`

It has a regular constructor accepting an `x` and `y` value with which to initialise `x` and `y` with.
`vec2(int vx, int vy) : x(vx), y(vy) {}`
This can be used like so: `vec2 v = vec2(34, -10);`

It has a `+= operator` which allows you to add vectors together.
`vec2 a = vec2(4, 5); a += vec2(6, 5); // a is now vec2(10, 10)`
It also has a `-= operator` for subtraction, a free-function `+ operator` and a free function `- operator`.

The assignment-operators modify the left hand side, whilst the free-function operators take two values and return a third completely new value. (Or at least that should be the case, but from the looks of things it’s going to result in the `lhs` argument being modified because it’s a reference instead of a value).

There’s also a copy-assignment operator (though I’m not sure why it’s there, I’m pretty certain the compiler should generate that automagically).

And lastly for some reason the `<< operator` and `>> operator` were provided to give it left and right shift functionality. First time I’ve ever seen that on a vetor. Presumably it’s supposed to be a means of doing cheap division and multiplication by powers of two.

Any questions?

2 Likes

The copy assignment operator was just because my C++ teacher always made a stink about including it. Lol.
Bit shift operators are because I used a lot of fixed point arithmetic for game objects.

I just created this vector struct to handle coordinates of game objects. Good suggestion on the + and - operators. You’re right, those should return a third copy as opposed to modifying the lhs.

2 Likes

How can I compile the GitHub source code into one of those .ino files? I’m running Ubuntu. The .arduboy uploader only works on Windows so I can’t use an .arduboy file at all. However, I did get the Arduino IDE up and running. Could someone help me get this game on my Arduboy?

TL;DR: I can’t use the new .arduboy file format on my computer. How do I make it an .ino file?

Thank’s @eried @Pharap @Gaveno, now I understood. I was locked on “default contructor”.

@SuperRed38 After dowload zip from Github, inside ther’s a folder called “MYBL_AB” whith compilable code for Arduino IDE.

Marco

1 Like

Thank you! I’ll try that out right now!

Until level 28, is hard but fresh water compared to 29 and 30.

Your C++ teacher was probably trying to teach you something good but not understanding it properly. You only need to write a custom copy-assignment operator if either the compiler can’t generate one for some reason or if you’re writing a class that handles dynamic memory allocated with `new` or `malloc` so you can correctly copy the resource.

If you really want to include it though, usually using the `= default` syntax is the easiest way thanks to C++11.

That makes sense. I tend to use a separate class for fixed points.

That’s one of the reasons I avoid the old 'implement `operator +` using `operator +=`’ idiom. It’s shorter and it works, but it’s easier to accidentally get it wrong than making `operator +` standalone.

They’re worth knowing about. I like using en.cppreference for reading into C++'s quirks.

1 Like

Marco

Hello, Guys.

I have a Mac and I cant find the source code for Mystic Balloon. On the Github, there is no .ino file on the source zip.

Thanks and best Regards,
Nathan

Thank you very much!

AND @Gaveno gaves us an other update with 9 extra levels and graphic improvements

1. 9 extra levels (total of 39 levels)
2. updated the “save” function
3. parallax background
4. extra tiles for narrower walls

# watch it, this update changes the place of the saved game, so you’ll lose progress when updating to this version !

5 Likes

Will try this, thanks for the good work.

1 Like

Can’t import the .arduboy file. In Team A.r.g. uploader the MYBL_AB_v17 appears as Version 1.6 after importing and the uploader crashes. Craigs uploader generates a warning and can’t import the file either.

Oh man I have been playing this on my spare arduboy for a week now. I do not want to loose my progress.

1 Like

I think there’s a program somewhere that you can use to backup your EEPROM.

1 Like