Jump to content
  • Advertisement
Sign in to follow this  
pedrogabriellancelloti@hotmail.com

Simple Movement With Processing+Box2d

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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 smile.png 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 smile.png

Edited by Pedrog

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!