You can get the GML script here. This post will explain the code.
When I was developing enemies in Yxi, I was trying to get turrets to aim at you, but I didn’t want them to possess “instant aim”. I wanted them to rotate towards you given a maximum rotation speed. If you move too fast, it should turn towards you gradually, not instantly.
It seems that it wasn’t as simple as I thought it was. I had the basic algorithm down, but because of the way Game Maker handled angles, the turrets would behave strangely when you would hover around the 0°/360° point with respect to the turret.
I figured a tutorial would be necessary for something that isn’t so obvious to implement. This only pertains to Game Maker and thus uses the GML language.
There are three steps involved when gradually rotating an object (let’s call it a turret for now) towards a target object:
Calculate the target’s direction with respect to the turret’s position.
Calculate the angle difference between the direction derived from step 1 (let’s call “target direction”) and the turret’s facing direction.
Apply angular rotation towards the target so that the target direction is the facing direction.
Here’s my progress on Yxi so far. I lot of work has gone into getting physics right and also making bosses with random parts.
As of yet there aren’t that many boss parts, but the system will randomly choose parts to build the boss. When the player blasts one of the arms, only that arm gets destroyed; the rest of the boss is still alive.
Other things this video demonstrates are how the player gets pushed back upon contact with the boss, how coins follow the player, what player death currently looks like, how shooting the main body will kill the whole boss, and how turrets slowly turn towards your direction.
Yes the graphics are very ugly, and the boss is currently boring. It’s a work in progress, so this will hopefully turn into something fun. 🙂
The choice for GameSalad to make a game might sound strange, since I’m a programmer student and GameSalad has no coding. The story behind that is a little long, but I’ll explain anyway:
On October 19, 2012, two people from Microsoft came to DePaul’s College of Computing to talk about app development for Windows 8. They setup a workshop for people to make a Window 8 compatible game using GameSalad. I think the choice for GameSalad has something to do with how it currently supports export for Windows 8.
Considering how simple (perhaps too simple) GameSalad is, I wanted to make a game that was also simple. Unfortunately, GameSalad wasn’t delivering what I wanted. It doesn’t support sophisticated logic, nor does it support a changeable sprite anchor point.
Long story short, I started a new project with Game Maker Studio and reproduced every feature that was in my Yxi prototype from GameSalad. I even added a nice debug display you can toggle (see the screenshot).