Bullets that don't shoot.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
W3LF
Prole
Posts: 8
Joined: Fri Feb 12, 2016 7:40 am

Bullets that don't shoot.

Post by W3LF »

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 :D
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Bullets that don't shoot.

Post by ivan »

The pastebin code looks fine.
I didn't read the rest but

Code: Select all

function UPDATE_BULLET(dt)
    bullet.update()
    love.mousepressed()
end
Should be:

Code: Select all

function UPDATE_BULLET(dt)
    bullet.update(dt)
    love.mousepressed(x, y, button) -- not sure what args you would pass there
end
W3LF
Prole
Posts: 8
Joined: Fri Feb 12, 2016 7:40 am

Re: Bullets that don't shoot.

Post by W3LF »

ivan wrote:The pastebin code looks fine.
I didn't read the rest but

Code: Select all

function UPDATE_BULLET(dt)
    bullet.update()
    love.mousepressed()
end
Should be:

Code: Select all

function UPDATE_BULLET(dt)
    bullet.update(dt)
    love.mousepressed(x, y, button) -- not sure what args you would pass there
end
Thanks for the help, but it still doesn't work :c
OrbitalBlueprint
Prole
Posts: 13
Joined: Thu Oct 23, 2014 5:05 pm

Re: Bullets that don't shoot.

Post by OrbitalBlueprint »

.
Last edited by OrbitalBlueprint on Fri Apr 19, 2019 5:19 pm, edited 1 time in total.
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Bullets that don't shoot.

Post by zorg »

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 :3True 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.
W3LF
Prole
Posts: 8
Joined: Fri Feb 12, 2016 7:40 am

Re: Bullets that don't shoot.

Post by W3LF »

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)
I don't get what you mean, sorry :c
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Bullets that don't shoot.

Post by zorg »

W3LF wrote:I don't get what you mean, sorry :c
This part:

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
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.
Me and my stuff :3True 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.
W3LF
Prole
Posts: 8
Joined: Fri Feb 12, 2016 7:40 am

Re: Bullets that don't shoot.

Post by W3LF »

zorg wrote: This part:

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
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.


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?
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Bullets that don't shoot.

Post by MadByte »

Take a look at this basic shooting example:
bulletExample.love
It should make clear what is going wrong with your code.
W3LF
Prole
Posts: 8
Joined: Fri Feb 12, 2016 7:40 am

Re: Bullets that don't shoot.

Post by W3LF »

MadByte wrote:Take a look at this basic shooting example:
bulletExample.love
It should make clear what is going wrong with your code.
Thanks a lot :D
Post Reply

Who is online

Users browsing this forum: No registered users and 172 guests