• 14
• 12
• 9
• 10
• 9

# Simple Movement With Processing+Box2d

This topic is 1770 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys :)
I'm new at Processing and I had some experiences with Box2d(but using c++).

Today I was trying to make simple movement by applying forces to a "personagem" (character).

The program compile well but the box don't move (stays static at the initial position). I think that the coordinates given by box2d aren't being transmited to the pixel coordinates. Can somebody help me?

Here's the code:
http://pastebin.com/vGmr8DCZ (personagem class).

http://pastebin.com/5DCSYhsS (Main Code).

Sorry but i've commented the code in portugues and sorry about my english :(

##### Share on other sites

Hi Pedrog,

I found it difficult to understand some of your code, just because of the language, and i only had a minute to look over it but i think the problem may be here ?

void draw() {
background(255); //colocamos um plano de fundo na cor branca
box2d.step(); // a cada vez que draw fizer 1 loop,
//sera feito um loop nas acoes da box2d
Personagem personagem = new Personagem(20,20);
personagem.display();
}


If this method is being called every frame, then personagem is being created at every frame, and is being passed x: 20 and y: 20 position. Thats if i read it right ;)

##### Share on other sites

Hi Pedrog,

I found it difficult to understand some of your code, just because of the language, and i only had a minute to look over it but i think the problem may be here ?

void draw() {
background(255); //colocamos um plano de fundo na cor branca
box2d.step(); // a cada vez que draw fizer 1 loop,
//sera feito um loop nas acoes da box2d
Personagem personagem = new Personagem(20,20);
personagem.display();
}


If this method is being called every frame, then personagem is being created at every frame, and is being passed x: 20 and y: 20 position. Thats if i read it right ;)

Thank you I've got it right yesterday today. The line "Personagem personagem = new Personagem(20,20);" musted be only called in setup, as all the other "class constructors", I'm having other problems that I need help, but to avoid the mess I'll create other topic.

Thanks again

Edited by Pedrog