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.
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 ints.
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.
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.
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?
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.
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.