Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (604) Games in Android Showcase (171) games submitted by our members Games in WIP (654) 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 440 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: 20

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

You cannot reply to this message, because it is very, very old.

 bilznatch (27 views) 2015-08-04 11:03:17 SHC (44 views) 2015-08-01 03:58:20 Jesse (25 views) 2015-07-29 04:35:27 Riven (48 views) 2015-07-27 16:38:00 Riven (26 views) 2015-07-27 15:35:20 Riven (28 views) 2015-07-27 12:26:13 Riven (19 views) 2015-07-27 12:23:39 BurntPizza (42 views) 2015-07-25 00:14:37 BurntPizza (56 views) 2015-07-24 22:06:39 BurntPizza (35 views) 2015-07-24 06:06:53
 theagentd 50x wessles 48x basil_ 32x KaiHH 26x Riven 21x mooman219 17x bornander 16x orangepascal 16x ags1 16x KudoDEV 13x klaus 11x princec 11x pquiring 11x CelestialCreator 11x israelg99 9x Spasi 8x
 List of Learning Resourcesby gouessej2015-07-09 11:29:36How Do I Expand My Game?by bashfrog2015-06-14 11:34:43List of Learning Resources2015-05-31 05:37:30Intersection Methodsby Roquen2015-05-29 08:19:33List of Learning Resources2015-05-05 10:20:32How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21
 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