-

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
ruarai
Prole
Posts: 11
Joined: Sun Jun 26, 2011 3:04 am

-

Post by ruarai »

-
Last edited by ruarai on Sun Feb 19, 2023 6:06 am, edited 1 time in total.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Odd physics glitch.

Post 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?
Kurosuke needs beta testers
ruarai
Prole
Posts: 11
Joined: Sun Jun 26, 2011 3:04 am

-

Post by ruarai »

-
Last edited by ruarai on Sun Feb 19, 2023 6:05 am, edited 1 time in total.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Odd physics glitch.

Post 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)).
Kurosuke needs beta testers
ruarai
Prole
Posts: 11
Joined: Sun Jun 26, 2011 3:04 am

-

Post by ruarai »

-
Last edited by ruarai on Sun Feb 19, 2023 6:05 am, edited 1 time in total.
ruarai
Prole
Posts: 11
Joined: Sun Jun 26, 2011 3:04 am

-

Post by ruarai »

-
Last edited by ruarai on Sun Feb 19, 2023 6:05 am, edited 1 time in total.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Odd physics glitch.

Post by tentus »

I'm not getting that bug. Screenshot?
Kurosuke needs beta testers
ruarai
Prole
Posts: 11
Joined: Sun Jun 26, 2011 3:04 am

-

Post by ruarai »

-
Last edited by ruarai on Sun Feb 19, 2023 6:05 am, edited 1 time in total.
ruarai
Prole
Posts: 11
Joined: Sun Jun 26, 2011 3:04 am

-

Post by ruarai »

-
Last edited by ruarai on Sun Feb 19, 2023 6:04 am, edited 1 time in total.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Odd physics glitch.

Post 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.
Kurosuke needs beta testers
Post Reply

Who is online

Users browsing this forum: togFox, zingo and 4 guests