Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (757) Games in Android Showcase (229) games submitted by our members Games in WIP (844) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Phys2d Velocity Problem... Body Movement from Point A to B with Velocity.  (Read 871 times) 0 Members and 1 Guest are viewing this topic.
Digital.Optiplex

Senior Newbie

 « Posted 2013-08-01 10:47:09 »

I am trying to write a code in Phys2d in which an object(BOX) is supposed to be moved from location A to location B with the Velocity of 2 m/s in certain direction let suppose North.

I'm new to this game programming specially physics & I don't know how should i have to set the velocity...I just read in few demos (they wern't even clear )

following is the code but box is not moving, do I need to apply force as well??

... new Box("Truck",10.0f, 10.0f, 100.0f);
Truck.setPosition(262, 184);
Truck.setPaint(Color.blue);

any help will be highly appreciated...
ClickerMonkey

JGO Coder

Medals: 26
Exp: 10 years

Game Engineer

 « Reply #1 - Posted 2013-08-01 12:20:15 »

You're going to have to post a LOT more code than that for us to help you quickly.

Digital.Optiplex

Senior Newbie

 « Reply #2 - Posted 2013-08-01 12:30:14 »

I made a mistake by defining object as static after declaring it as dynamic Code is working fine... the box is moving with certain velocity in upward direction because of (negative) velocity and falls down due to gravity... Still i m wondering how should I move Box from Location (x,y) to Location2(x,y).... Is there any way to have a look of sky view because here things fall from top to bottom?  any help??
sirkarpfen

Junior Devvie

Medals: 2
Exp: 2 years

 « Reply #3 - Posted 2013-08-01 14:30:17 »

I made a mistake by defining object as static after declaring it as dynamic Code is working fine... the box is moving with certain velocity in upward direction because of (negative) velocity and falls down due to gravity... Still i m wondering how should I move Box from Location (x,y) to Location2(x,y).... Is there any way to have a look of sky view because here things fall from top to bottom?  any help??

As ClickerMonkey allready said, it would be very helpfull to post some more code here and maybe next time use the code tags: [.code][./code] (without the dots ). Its just much more readable.

I didn't work with Phys2d nor Slick but maybe you have to adjust the gravity or set it directly to 0, try:

 1 `world.setGravity(0,0)`

This way your box should move without beeing affected by gravity .
Pages: [1]
 ignore  |  Print

 EgonOlsen (77 views) 2018-06-10 19:43:48 EgonOlsen (57 views) 2018-06-10 19:43:44 EgonOlsen (77 views) 2018-06-10 19:43:20 DesertCoockie (259 views) 2018-05-13 18:23:11 nelsongames (157 views) 2018-04-24 18:15:36 nelsongames (156 views) 2018-04-24 18:14:32 ivj94 (897 views) 2018-03-24 14:47:39 ivj94 (161 views) 2018-03-24 14:46:31 ivj94 (810 views) 2018-03-24 14:43:53 Solater (174 views) 2018-03-17 05:04:08
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org