Posted July 24, 2025 by corkboardstudio
#asteroids #gamemaker #rotation
Day three was a shorter session, but it was a huge step forward in firepower and a funny reminder of why I'm a teacher and not a mathematician.
The main accomplishment today was implementing a full weapon system. The player ship now has three functional and distinct weapon types, including single, double, and triple shot modes, each with different speeds and ranges. As you can see in the GIF, it's starting to feel like a real arcade shooter.
The biggest breakthrough, however, was getting the weapon's rotational offset working correctly, thanks to a fantastic explanation from the instructor, Justin Zendt.
By default, GameMaker spawns objects at their origin point, which means the lasers were firing from the center of the ship, especially when turning. The solution requires using a rotation matrix, a mathematical concept found in linear algebra that, I have to admit, I would not have figured out on my own. It was now my turn to be like my students who ask, "When will I ever use this outside of class?" Well...I finally had a use for linear algebra! I might have been able to figure it out if I hadn't have dropped out of my linear algebra class after discovering it was more about matrices than y=mx+b. The course title certainly was a wolf in sheep's clothing. Let that be a lesson: always read the course description before you sign up! That advice goes for just about everything else in life too. Make sure you always read the fine print before signing!
Thankfully, with the tutorial's guidance, everything is shaping up nicely. The next step is to add a UI to show the selected weapon and an energy system to limit the ammo, which will add a fun layer of resource management.
Another pin has been firmly placed on the board.