Hi again, i'm having a bit of troubles with bullets.
I followed a tutorial on love's wiki, but they don't want to work.
Here is my code:
bullet.lua (i think the problem is here): http://pastebin.com/MafSWDak
Or if you want, a .love file with the entire code: https://www.dropbox.com/s/m5fc58iqm8dww ... .love?dl=0
Thanks to everyone that will have the patience to read the code and maybe help me out
Bullets that don't shoot.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Bullets that don't shoot.
The pastebin code looks fine.
I didn't read the rest but
Should be:
I didn't read the rest but
Code: Select all
function UPDATE_BULLET(dt)
bullet.update()
love.mousepressed()
end
Code: Select all
function UPDATE_BULLET(dt)
bullet.update(dt)
love.mousepressed(x, y, button) -- not sure what args you would pass there
end
Re: Bullets that don't shoot.
Thanks for the help, but it still doesn't work :civan wrote:The pastebin code looks fine.
I didn't read the rest butShould be:Code: Select all
function UPDATE_BULLET(dt) bullet.update() love.mousepressed() end
Code: Select all
function UPDATE_BULLET(dt) bullet.update(dt) love.mousepressed(x, y, button) -- not sure what args you would pass there end
-
- Prole
- Posts: 13
- Joined: Thu Oct 23, 2014 5:05 pm
Re: Bullets that don't shoot.
.
Last edited by OrbitalBlueprint on Fri Apr 19, 2019 5:19 pm, edited 1 time in total.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Bullets that don't shoot.
I also see in the pastebin snippet that you define bullet.speed, but nowhere are any numeric keys defined inside bullet, much less a dx or dy member for them.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Bullets that don't shoot.
zorg wrote:I also see in the pastebin snippet that you define bullet.speed, but nowhere are any numeric keys defined inside bullet, much less a dx or dy member for them.
Code: Select all
local bulletDx = bullet.speed * math.cos(angle)
local bulletDy = bullet.speed * math.sin(angle)
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Bullets that don't shoot.
This part:W3LF wrote:I don't get what you mean, sorry :c
Code: Select all
function bullet.update(dt)
for i,v in ipairs(bullet) do
v.x = v.x + (v.dx * dt)
v.y = v.y + (v.dy * dt)
end
end
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Bullets that don't shoot.
zorg wrote: This part:v would be bullet, but bullet does not have any members with number keys (only speed, x, y, etc...), and even if it would, they would still lack the dx and dy keys.Code: Select all
function bullet.update(dt) for i,v in ipairs(bullet) do v.x = v.x + (v.dx * dt) v.y = v.y + (v.dy * dt) end end
The fact is, I literally copypasted it from Love's wiki, but it still doesnt work.
I'm new to programming so I have no idea of what's wrong, could you please tell me how I should do it then?
Re: Bullets that don't shoot.
Take a look at this basic shooting example:
It should make clear what is going wrong with your code.Re: Bullets that don't shoot.
Thanks a lotMadByte wrote:Take a look at this basic shooting example:It should make clear what is going wrong with your code.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 5 guests