Hi, im new to game programming but im having a go with a top down shooter. A found an open source sprite online and ive got it to rotate based on where the mouse is but now ive hit a bit of a wall in getting the bullets to rotate their starting position too, im not too sure how to go about it. Thanks for any help!
Having issue with how bullets are generating when my player rotates
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Having issue with how bullets are generating when my player rotates
I guess you could get the gradient of the line between the center of your player and the position of the cursor. Once you know that gradient, you can just move your bullet along that line until it reaches it's target. Using the same rotation amount for the bullet should keep it pointing in the same direction as your player (I hope)
Re: Having issue with how bullets are generating when my player rotates
I think i phrased my issue wrongly, basically i can get bullets to fire towards the cursor but I dont know how to make it look like its coming out of the gun in the sprite basically
Re: Having issue with how bullets are generating when my player rotates
Here's the mathTeshi wrote:im not too sure how to go about it.
Code: Select all
xoffset = 50
yoffset = 10
bulletx = player.x + math.cos(player.angle)*xoffset + math.cos(player.angle+math.pi/2)*yoffset
bullety = player.y + math.sin(player.angle)*xoffset + math.sin(player.angle+math.pi/2)*yoffset
Otherwise you'll get stuck again and again
butts
Who is online
Users browsing this forum: Bing [Bot] and 7 guests