Page 1 of 1

Best way to attach paddles to each other?

Posted: Fri Dec 02, 2022 4:00 pm
by kristinamay
I'm working on a pong variant that makes the paddles add a layer when the player scores. The paddle detection is working perfectly for the first "layer", but on subsequent layers, the new shapes/fixtures don't seem to be working to detect collision like the first ones. My theory is that this has to do with how the new shape and fixture interact with the base body, but I can't for the life of me troubleshoot my way out of this one.

I initially looked into weldJoints for this, but it seemed overkill when what I really need is to just effectively increase the width of the paddle and slap on a second fixture (I think?).

https://github.com/kristinalustig/pongburger Here's my code (the relevant stuff is in physics.lua, namely in beginContact() and startNewRound() (as well as in createPaddleObject()). I also included the latest build in dist/0.0.2 if you want to see the issue I've described for yourself. W/S are up + down for left paddle, Up + Down for right.

Thank you so much for your help - I've made several games in love2d thus far but this is my first one even partially using the physics engine so I'm a bit out of my depth. This lovely community has made my dream of making indie games a reality <3

Re: Best way to attach paddles to each other?

Posted: Fri Dec 02, 2022 5:03 pm
by kristinamay
Update - I actually think it sort of works, just only on paddles past paddle # 1 for some reason. :-O

Re: Best way to attach paddles to each other?

Posted: Sun Dec 04, 2022 9:22 pm
by togFox
Assuming you're using physics engine you could destroy the paddle and instantly create one with a different size or you can check my last game. It has a physics space ship that grows over time.

https://github.com/togfoxy/Asteroids/tree/master/Source

I'll try to find the bit for you.

Edit: I'm on mobile so can't do much but point you to my functions.lua which destroys and recreates a larger ship in its place.