Okay so i'm new to both love and programming with lua so i'm having some difficulty getting started.
The basic game i'm working with now is a top down shooter. I'm trying to code everything on my own but i'm having a problem with the bullets all sharing trajectories. If i shoot 1 bullet its no problem but when there are more then 1 bullets fired from 2 different positions their trajectories are shared and i don't know how to make it so they're individually stored.
Anyway,
Left click shoots, mouse aims, and arrow keys move(plan to switch that to wasd at some point).
Thanks for any help, also i respect other solutions to the problem but i mostly want to solve it while gaining an understanding of table/entity dynamics.
Thanks for any help.
Need help with a table/entity bullet problem.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Need help with a table/entity bullet problem.
- Attachments
-
- ChargeCircle.love
- (982 Bytes) Downloaded 117 times
Re: Need help with a table/entity bullet problem.
I can't open your love file at work. But a pointer:-
https://love2d.org/wiki/Tutorial:Fire_Toward_Mouse
You can modify the above code if you wanted to fire in directions or towards the mouse cursor. I use similar code in this example for the bullets and ducks that spawn:-
https://vimeo.com/57578774
Let us know if you need further assistance.
https://love2d.org/wiki/Tutorial:Fire_Toward_Mouse
You can modify the above code if you wanted to fire in directions or towards the mouse cursor. I use similar code in this example for the bullets and ducks that spawn:-
https://vimeo.com/57578774
Let us know if you need further assistance.
Sagan Interactive - Looking forward to a creative 2013.
Re: Need help with a table/entity bullet problem.
I was actually working on something similar a few days ago, After a rather brief glance at your code, It would appear that I've chosen a slightly different method.
Here's what i'm dealing with:
Updating:
"self" represents basically what v2 does in your love.update. I'd say this is the most important part of the code, But i'll attach my .love below so you can have a look at how i handled things and see the code in context. That snippet is inside mob.lua.
Keep in mind that the code is really dirty and might be hard to understand as this game is in very early development., If you have any questions regarding it, Just ask and I'll do my best to clarify.
Here's what i'm dealing with:
Updating:
Code: Select all
elseif self.class == "bullet" then
self.x = self.x + math.cos(self.a) * self.s * dt
self.y = self.y + math.sin(self.a) * self.s * dt
end
Keep in mind that the code is really dirty and might be hard to understand as this game is in very early development., If you have any questions regarding it, Just ask and I'll do my best to clarify.
Re: Need help with a table/entity bullet problem.
I had no idea there were more tutorials on the wiki, very helpful. I solved my issue, and it mostly involved me getting used to creating entity tables. I see where i went wrong.
Anyway i made a little game out of it. Thank you for your help, now to decide what to make next...
Anyway i made a little game out of it. Thank you for your help, now to decide what to make next...
- Attachments
-
- ChargeCircle.love
- (76.55 KiB) Downloaded 116 times
Who is online
Users browsing this forum: Hydrogen Maniac and 2 guests