Tutorial on bullets?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Tutorial on bullets?
Can someone give me a tutorial on a basic bullet? I've seen many other tutorials about this, but they all seem too rushed.
- severedskullz
- Prole
- Posts: 36
- Joined: Thu May 30, 2013 1:55 am
Re: Tutorial on bullets?
Need more info on what you need. Are you launching bullets from turrets, guns, players, etc. Is Rotation a factor in your implementation? Are there dynamic offsets of the bullets location? Is the bullet "homing" in on its target?
Re: Tutorial on bullets?
The game is a top down view. You can click the mouse somewhere, and the player will fire the bullet in that direction.
- severedskullz
- Prole
- Posts: 36
- Joined: Thu May 30, 2013 1:55 am
Re: Tutorial on bullets?
I don't really have time to write a tutorial for you, but I hope these very helpful methods that I wrote in my own game will work for you.
Rotation will give you the rotation angle of 2 positions. X1 and Y1 are the starting positions and X2 and Y2 are the desired location. You can then pass in the rotation into dirVector which will return 2 variables: an X and Y position. You can use these in your update statements for your bullet entites. If it is too slow, and it most likely will be as these values range from 1, -1 then you may simply multiply the values returned by a constant to get faster speed.
Code: Select all
function dirVector(rot)
--Returns the vector of the rotation in X and Y terms.
-- Usually you use these as the update increments. Multiply them for faster traveling
return math.cos(rot), math.sin(rot)
end
function rotation(x1,y1, x2,y2)
--Math.atan2 returns a radian between -Pi and Pi.
return math.atan2(y2-y1, x2-x1) -- Return the rotation
end
Re: Tutorial on bullets?
I don't have a tutorial either, but I see two challenges in implementing bullets:
- Creating a bullet that moves exactly in that direction that you want.
- Creating and managing multiple bullets
Check out my blog on gamedev
Re: Tutorial on bullets?
Watch this vid : http://www.youtube.com/watch?v=S2oO2wbsXQs.If you got any questions ask me!
I found Love very enjoyable and nice!
Re: Tutorial on bullets?
tuts?
you need to read some lua and experiment some more and then you will find it out
hint:
use tables!
you need to read some lua and experiment some more and then you will find it out
hint:
use tables!
Who is online
Users browsing this forum: Google [Bot], Semrush [Bot] and 4 guests