Page 1 of 1

-

Posted: Fri Jul 01, 2011 11:32 pm
by ruarai
-

Re: Odd physics glitch.

Posted: Sat Jul 02, 2011 12:19 am
by tentus
I think what you're talking about is gravity. (I think.) If you change "world:setGravity(0, 700)" to "world:setGravity(0, 0)" does it do what you want it to?

-

Posted: Sat Jul 02, 2011 12:46 am
by ruarai
-

Re: Odd physics glitch.

Posted: Sat Jul 02, 2011 12:53 am
by tentus
Ah, I gotcha.

In that case it looks like you're not accounting for the origin of bodies being their center. If you change

Code: Select all

objects[howmany].body = love.physics.newBody(world, x, y, m, r)
to

Code: Select all

objects[howmany].body = love.physics.newBody(world, x + (width / 2), y + (height / 2), m, r)
you'll see that by offsetting them by 1/2, you make their mouse origin line up with their body center.

(You'll also need to change your ground position to rectangle(world,0,0,600,0,650,50,0)).

-

Posted: Sat Jul 02, 2011 12:57 am
by ruarai
-

-

Posted: Sat Jul 02, 2011 1:00 am
by ruarai
-

Re: Odd physics glitch.

Posted: Sat Jul 02, 2011 1:06 am
by tentus
I'm not getting that bug. Screenshot?

-

Posted: Sat Jul 02, 2011 1:20 am
by ruarai
-

-

Posted: Sat Jul 02, 2011 1:22 am
by ruarai
-

Re: Odd physics glitch.

Posted: Sat Jul 02, 2011 4:37 pm
by tentus
In other words, if the width OR the height of the rectangle is negative, the shape does not get created properly.

My advice to you would be to rethink your code. You have a LOT of unused variables in there, and you do a lot in the draw function that should probably be done in the update function. Consider rewriting the project from scratch, and the bug will probably not recur.

A few tips:
love.mouse.isDown("r") == true can be stated as just love.mouse.isDown("r"). By the same token, love.mouse.isDown("r") == false can be said as just not love.mouse.isDown("r").
love.draw() should concern itself only with drawing. The "thinking" part of your game should be done in love.update()
This can be rewritten:

Code: Select all

	colours = {} -- boring table stuff
	colours.r = {}
	colours.g = {}
	colours.b = {}
to this:

Code: Select all

	colours = {
		r = {},
		g = {},
		b = {}
	}
I find it to be easier to read and maintain, personally.