Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Simple Movement With Processing+Box2d


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Pedrog   Members   -  Reputation: 104

Like
0Likes
Like

Posted 12 May 2013 - 07:53 PM

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 :(



 



Sponsor:

#2 McGrane   Members   -  Reputation: 1195

Like
0Likes
Like

Posted 13 May 2013 - 05:34 PM

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 ;)



#3 Pedrog   Members   -  Reputation: 104

Like
0Likes
Like

Posted 17 May 2013 - 04:43 PM

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, 17 May 2013 - 04:53 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS