So let's talk about one of the more common patterns used shall we?
![]() | ||
By which I mean the swirly doom pattern. |
So how does one go about making this pattern? Well this is slightly less easy than those other things I said would be easy. Time to examine some code!
This is all in the alarm zero event. Yep all this just for one simple pattern.
if shootstage = 0 {
if shoot > 0 { [1]
mb1 = instance_create(self.x,self.y,heavydakka) [2]
mb1.direction = angle1 [3]
mb1.speed = 5
angle1 = angle1 + 10 [4}
mb2 = instance_create(self.x,self.y,heavydakka) [5]
mb2.direction = angle2
mb2.speed = 5
angle2 = angle2 - 10
shoot = shoot - 10
alarm[0] = 2 }
else { shootstage = 1 [6]
shoot = 180}}
if shootstage = 1 {
if shoot > 0 {
mb1 = instance_create(self.x,self.y,heavydakka)
mb1.direction = angle1
mb1.speed = 5
angle1 = angle1 - 10
mb2 = instance_create(self.x,self.y,heavydakka)
mb2.direction = angle2
mb2.speed = 5
angle2 = angle2 + 10
shoot = shoot - 10
alarm[0] = 2 }
else {alarm[3] = 30}} [7]
I think that's enough for now.
1: The shoot variable is used to tell how far the sweep should go, the shootstage variable is used to reverse the sweep for another go.
2: This part of the script tell the game to create an instance of the bullet and assign it a variable, in this case the variable is mb1, short for My Bullet. The variable will then be reassigned to the next bullet fired and so on.
3. Adding the variable to the front of the command tells the game to perform it for the object with said variable, in this case telling the bullet to move in a direction equal to the variable angle1 at a speed of 5.
4: And of course you need to increment the angle variable in order to get that nice sweeping motion hence this part of the script.
5: I wanted it too fire two waves at once so I added another set of variables this time assigned to mb2, that moves in the opposite direction
6: This is where the firing arc reverses, it simply says if shoot is zero, and has thus traversed the full 180 degrees, then set shoot stage to 1. The following actions are all the reverse of the first ones making it sweep it's bullets back to the front.
7: After the shoot variable is zero again alarm 3 will get set instead of alarm 0 [7a].
7a: The alarm is basically a timer saying wait x then perform actions with x being the amount of steps you set it to.
No comments:
Post a Comment