Physics, revolute joints, anchors. How does it works?

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.
Rad3k
Citizen
Posts: 69
Joined: Mon Aug 08, 2011 12:28 pm

Re: Physics, revolute joints, anchors. How does it works?

Post 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.
knarf
Prole
Posts: 9
Joined: Fri Sep 02, 2011 10:39 am

Re: Physics, revolute joints, anchors. How does it works?

Post 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.
knarf
Prole
Posts: 9
Joined: Fri Sep 02, 2011 10:39 am

Re: Physics, revolute joints, anchors. How does it works?

Post 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 :awesome: .

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.
Attachments
qwop.love
(2.35 KiB) Downloaded 109 times
Rad3k
Citizen
Posts: 69
Joined: Mon Aug 08, 2011 12:28 pm

Re: Physics, revolute joints, anchors. How does it works?

Post 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.
knarf
Prole
Posts: 9
Joined: Fri Sep 02, 2011 10:39 am

Re: Physics, revolute joints, anchors. How does it works?

Post 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).
Attachments
qwop.love
(2.56 KiB) Downloaded 139 times
knarF.se
Prole
Posts: 5
Joined: Wed Sep 28, 2011 10:47 pm

Re: Physics, revolute joints, anchors. How does it works?

Post by knarF.se »

Stupid forum software!

I claims I've been cited in this thread...

Hi other knarf! :awesome:
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests