-
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Odd physics glitch.
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
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Odd physics glitch.
Ah, I gotcha.
In that case it looks like you're not accounting for the origin of bodies being their center. If you change to
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)).
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)
Code: Select all
objects[howmany].body = love.physics.newBody(world, x + (width / 2), y + (height / 2), m, r)
(You'll also need to change your ground position to rectangle(world,0,0,600,0,650,50,0)).
Kurosuke needs beta testers
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Odd physics glitch.
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: to this:
I find it to be easier to read and maintain, personally.
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 = {}
Code: Select all
colours = {
r = {},
g = {},
b = {}
}
Kurosuke needs beta testers
Who is online
Users browsing this forum: Google [Bot] and 1 guest