Thursday, July 12, 2012
The Boring Mechanics of Another Shooter, Part 4
Told you there would be another one of these.
Today I think I shall cover, the basic turret.
I've covered the power of harnessing variables and objects so you should know where I'm going with this
mygun = instance_create(self.x,self.y,t1)
So the first step is to have whatever you want your gun attached to create the gun and give it a variable.
This is of course to prevent your turrets getting confused about what they should be attached to.
Getting the gun too stay is also fairly simple.
in the end step event
mygun.x = x
mygun.y = y
This tells the gun to move to the center of the object, you can use + or - to make an off center gun, like this-
mygun.x = x + 5
mygun.y = y
That will move it 5 pixels to the right.
Now for the most important part, as what is the point of a turret if not to point at stuff you want dead?
if instance_exists(player) [1]
then image_angle = point_direction(self.x,self.y,player.x,player.y) [2]
As for firing, well you should already know this.
And that's all the typing I feel like doing at the moment, see you next time
1:This is to prevent errors if you die.
2:The first set of coordinates is the origin, self uses the objects origin, the second set is what you want to point at, in this case the player.[2a]
2a:For a player aiming with the mouse substitute mouse_x, mouse_y for the second values.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment