Hi. i am currently making my first game with love. its a breakout clone.
But the collision doesent work...
i have done exactly the same as in my test games...
but i don't see the problem with the code...
Collision Help?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Collision Help?
- Attachments
-
- Breakout.love
- (48.1 KiB) Downloaded 195 times
Re: Collision Help?
hmm... i uploaded the wrong version... heres the right one...
- Attachments
-
- Breakout.love
- (48.1 KiB) Downloaded 203 times
-
- Party member
- Posts: 215
- Joined: Sun Jan 18, 2009 8:03 pm
Re: Collision Help?
Hi, when something goes amiss, it's always useful to simplify the program, remove assumptions, or as many recent changes as possible so to get a program that works again. Once you have a case that works, you can work out precisely where your case breaks down and modify the original version of the program. You could for instance take the collision detection demo and change yours back to that as to make it as close as possible (or gradually go from that version to your version). If you give up, I can tell you what the problem is, but you'll lose a salmon.Pawnda wrote:Hi. i am currently making my first game with love. its a breakout clone.
But the collision doesent work...
i have done exactly the same as in my test games...
but i don't see the problem with the code...
Also, I believe it is advisable to create each block as its own table, with body, shape, and other properties, all stored in a blocks table rather than a matrix that specifies particular positions. This would also result in making it easier with e.g. dropping tiles. I would recommend that you store the tiles as keys however, not as values. That is, blocks[myblock] = true to add and blocks[myblock] = nil to remove.
There is a limitation in how fast objects can move. Increasing the velocity won't fix this. If you want things to move faster, you need to update the world update 'delta' by some value.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
Re: Collision Help?
Code: Select all
-- Probably wrong (offset [150,270]):
ballShape = love.physics.newCircleShape(ball,150,270,5)
-- Probably better (offset [0,0]):
ballShape = love.physics.newCircleShape(ball,5)
-- Also, you don't want zero mass on the ball. That will make it "terrain":
ball = love.physics.newBody(world, 0, 0, 0)
-- Better:
ball = love.physics.newBody(world, 0, 0)
-
- Party member
- Posts: 215
- Joined: Sun Jan 18, 2009 8:03 pm
Re: Collision Help?
The constructor is overloaded - 150, 270, 5 creates a circular shape of radius 5 with an offset of (150,270) from the body. In other words, if the body is at (0,0), then the shape is at (150,270). This was also pawnda's problem, the collision detection was made at (150,270) but the drawing at (0,0). The same applied for the rectangular pad.rude wrote:Code: Select all
-- Probably wrong (radius=150): ballShape = love.physics.newCircleShape(ball,150,270,5) -- Probably better (radius=5): ballShape = love.physics.newCircleShape(ball,5)
Oh, I see, the default mass is 1 in the latter case. He was calling setMassFromShapes() afterwards though and static is equivalent to 0 mass, so that still worked out.rude wrote:Code: Select all
-- Also, you don't want zero mass on the ball. That will make it "terrain": ball = love.physics.newBody(world, 0, 0, 0) -- Better: ball = love.physics.newBody(world, 0, 0)
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
Re: Collision Help?
My bad @ radius. Edifixed.
Not sure if setMassFromShapes does anything if the initial mass is 0. I think there's a separate list for terrain geometry (or was that Chipmunk?).
Not sure if setMassFromShapes does anything if the initial mass is 0. I think there's a separate list for terrain geometry (or was that Chipmunk?).
-
- Party member
- Posts: 215
- Joined: Sun Jan 18, 2009 8:03 pm
Re: Collision Help?
I tried initializing with 0 mass and calling setMassFromShape - no longer isStatic.rude wrote:My bad @ radius. Edifixed.
Not sure if setMassFromShapes does anything if the initial mass is 0. I think there's a separate list for terrain geometry (or was that Chipmunk?).
I tried initializing with a non-zero mass and setting to 0 - became isStatic.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
Re: Collision Help?
Cool. I guess it was Chipmunk, then.
Who is online
Users browsing this forum: No registered users and 4 guests