Hi !
Featured games (87)
games approved by the League of Dukes
Games in Showcase (649)
Games in Android Showcase (181)
games submitted by our members
Games in WIP (700)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Please check my *very* simple 3D physics code - its not working!  (Read 1262 times)
0 Members and 1 Guest are viewing this topic.
Offline saucecode

Senior Newbie

Medals: 1

« Posted 2012-07-04 06:14:21 »

So I'm not exactly a whiz with physics. I did once write a 2D physics engine which, while being very messy, worked to my needs.
And when I say physics engine, I mean getting a player to jump, fall down with gravity, and land on a surface that was below it's feet.
It would've been extremely easier if I had that 2D 'physics' engine to refer to, but due to severe, irreversable stupidity, that small set of code is sitting at a computer desk about 600 kilometers away.

So here is what I have so far. I can move about on an x and z axis, detecting collisions with a cuboid. I can jump on a spot, loose upwards momentum with gravity, fall, and land. I can jump ontop of the cuboid. Observations say that my Y position stops as soon as I am above the cuboid, however, my yBottom variable does change to the correct height when atop the cuboid. I cannot jump from the cuboid, because the Y position is not the same as the yBottom. yBottom is the highest point of geometry at my x/z coordinates.

The code

If you can point out my obvious errors amongst my poorly(?) structured code and help fix my little problem, that would be great!

Offline saucecode

Senior Newbie

Medals: 1

« Reply #1 - Posted 2012-07-17 04:24:07 »

still waitin'...   Emo
Offline SwampChicken
« Reply #2 - Posted 2012-07-17 06:31:46 »

This place is world-wide so I'd wait at least 24 hours....
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Sickan
« Reply #3 - Posted 2012-07-17 08:10:11 »

This place is world-wide so I'd wait at least 24 hours....
He did wait 13 days, I think that should be enough.
Offline SwampChicken
« Reply #4 - Posted 2012-07-17 10:10:16 »


Apologies sauce, for some reason I read both posts as being from today.
Offline _Al3x

Senior Devvie

Medals: 7

Indie Games FTW!

« Reply #5 - Posted 2012-07-17 10:45:03 »

I'd say the problem is related to
if(world.keys[Keyboard.KEY_SPACE] && onGround){

onGround = (vector.y == yBottom);

Do you allow double jump? If not, why don't you say something like?
if(world.keys[Keyboard.KEY_SPACE] && !jumping){

I hope someone can help you soon, I just couldn't read the code thoroughly because I'm at work Sad

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

KaiHH (124 views)
2016-01-31 23:15:29

sci4me (149 views)
2016-01-23 21:47:05

sci4me (135 views)
2016-01-23 21:46:58

KaiHH (168 views)
2016-01-19 13:26:42

theagentd (254 views)
2016-01-05 17:10:00

ClaasJG (269 views)
2016-01-03 16:58:36

chrisdalke (259 views)
2015-12-28 06:31:21

Guerra2442 (264 views)
2015-12-25 03:42:55

Guerra2442 (266 views)
2015-12-25 03:27:21

theagentd (294 views)
2015-12-21 14:43:24
List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50

Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48 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‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!