Page 2 of 2
Re: Physics, revolute joints, anchors. How does it works?
Posted: Sat Sep 03, 2011 1:25 pm
by Rad3k
knarf wrote:Also, I still don't understand why I have to set a width of 2*window_width (see code) to actually get a width of window_width for the ground.
When you create a rectangle in Box2d, "x" and "y" are the center of the rectangle, not its top left corner. Create the ground rectangle at the bottom-center of the screen.
Also, when you create the world, you can do just
Code: Select all
world = love.physics.newWorld(0, 0, width, height)
instead of
Code: Select all
world = love.physics.newWorld(-width, -height, width, height)
You took this code from the wiki, right? I think it needs to be corrected...
For the correct positioning of joints, try using less
magic numbers and more meaningfully named constants in your code. It will be easier to understand it and spot the bug then.
Re: Physics, revolute joints, anchors. How does it works?
Posted: Sat Sep 03, 2011 1:39 pm
by knarf
Rad3k wrote:knarf wrote:Also, I still don't understand why I have to set a width of 2*window_width (see code) to actually get a width of window_width for the ground.
When you create a rectangle in Box2d, "x" and "y" are the center of the rectangle, not its top left corner. Create the ground rectangle at the bottom-center of the screen.
Yep, I realised this few minutes after posting.
Rad3k wrote:Also, when you create the world, you can do just
Code: Select all
world = love.physics.newWorld(0, 0, width, height)
instead of
Code: Select all
world = love.physics.newWorld(-width, -height, width, height)
You took this code from the wiki, right? I think it needs to be corrected...
Actually I should have payed more attention to the wiki, the center-coordinates thing is explained there.
Rad3k wrote:For the correct positioning of joints, try using less
magic numbers and more meaningfully named constants in your code. It will be easier to understand it and spot the bug then.
I know, but too much named constants can also be harder to read.
Re: Physics, revolute joints, anchors. How does it works?
Posted: Sat Sep 03, 2011 3:41 pm
by knarf
Okay I've reach a point where I'm not far from what I want. The included love has a body with 2-parts legs, rotation is blocked almost similar to a human and I've even added some gameplay: you have to jump the highest you can. My personal record is 349 at the moment
.
The controls are terrible though. I want my thing to behave like the flash game
QWOP. QWOP controls are also, ahem, special but you get used to it. (I can finish it)
I know the body creation code is messy and full of hardcoded coordinates, I'm trying things out.
Re: Physics, revolute joints, anchors. How does it works?
Posted: Sat Sep 03, 2011 4:58 pm
by Rad3k
Looks fun
But yeah, controls need some love. Right now, I can't even figure what precisely does each key, and none of them does what I want
Considering that we have 2 legs, 2 joints per each leg (hips and knees), and 2 basic actions for each joint (contract and extend) wouldn't we need at least 8 keys to effectively control all the joints?
By the way, resetting doesn't work for me. Something happens when I press R, but it's quite far from full reset.
Re: Physics, revolute joints, anchors. How does it works?
Posted: Sat Sep 03, 2011 9:08 pm
by knarf
Rad3k wrote:Considering that we have 2 legs, 2 joints per each leg (hips and knees), and 2 basic actions for each joint (contract and extend) wouldn't we need at least 8 keys to effectively control all the joints?
Have you played
QWOP? Basically, Q and W control the thights and O and P control the calves.
- Q moves the front thigh to the right and the back one to the left
- W is the opposite of Q, front and back are switched.
- O extends the front calf and contract the back one
- P is the opposite of O, front and back are switched.
Rad3k wrote:By the way, resetting doesn't work for me. Something happens when I press R, but it's quite far from full reset.
yeah it's a quick & dirty reset.
Currently I'm using applyTorque() to move a part but maybe I should set a motor to the joint...
edit: ok I've fiddled some constants, controls are getting better (also added some walls and a surprise).
Re: Physics, revolute joints, anchors. How does it works?
Posted: Sun Oct 02, 2011 2:22 pm
by knarF.se
Stupid forum software!
I claims I've been cited in this thread...
Hi other knarf!