Hi guys
I see many tutorials about bullets BUT they are with the mouse direction!!
bullets follow the mouse pointers..
now can someone tell me how to use bullets but with one key to trigger?
for example a player moves up with (w) down with (s) right with (a) and finally left with (d)
and (k) would be the fire button...
now how do i do it? for one key to fire different directions?
if my player is facing up use K to fire or if the player its facing down still use K to fire
i used variables likes
left ="left"
but still didn't work
can someone tell me?? thank you !!!!!!!!!!!!!!!
bullet directions
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: bullet directions
you're going to want to store the facing direction of the player, that is: store the last direction that you moved the player then multiply the bullet's velocity vector by the direction vector. this is untested and is just here to show you the intent.
Code: Select all
local dir = { x = 0, y = 0 } --dont make a table every loop though
if love.keyboard.isDown('up') then
dir.y = -1
elseif love.keyboard.isDown('down') then
dir.y = 1
end
if love.keyboard.isDown('left') then
dir.x = -1
elseif love.keyboard.isDown('right') then
dir.x = 1
end
makeNewBullet(100 * dir.x, 100 * dir.y) --it's fast!
Re: bullet directions
Here is a wiki page about bullets: https://love2d.org/wiki/Tutorial:Fire_Toward_Mouse
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
personal page and a raycaster
Re: bullet directions
Nice work!
and sure ill check it out and thanks for the examples...
and sure ill check it out and thanks for the examples...
Re: bullet directions+stand
I have a small problem hope someone could help me
i can create bullets now and shoot them , can shoot right,left,up,down
after a few seconds i want stand to overwrite all the states so i can use state=stand for other things but it seem
like stand disappears while bullets are pressed or not i still want to use state= stand but how?????
I am sure its something small to fix but maybe i haven't seen it
here its the .love
i can create bullets now and shoot them , can shoot right,left,up,down
after a few seconds i want stand to overwrite all the states so i can use state=stand for other things but it seem
like stand disappears while bullets are pressed or not i still want to use state= stand but how?????
I am sure its something small to fix but maybe i haven't seen it
here its the .love
- Attachments
-
- bullets.love
- (3.31 KiB) Downloaded 72 times
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests