Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / Using DarkPhysics in a 2D World

Author
Message
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 23rd Feb 2008 10:45 Edited at: 23rd Feb 2008 10:47
Hello,

I am trying to use DarkPhysics to control a spaceship in a Thrust style game. The obvious problem is that Thrust is 2D and DarkPhysics controls all three axis's, which means that after a collision your ship could end up flying into or out of the screen ... not ideal!

I an attempt to overcome this, each loop I determine the Z angle of the ship and then use:
phy set rigid body rotation object, 0, 0, object angle z( Object ).

I also force the object back onto the Z plain with:
phy set rigid body position object, object position x( object ), object position y( object ), 0.

This seems to work but obviously I would have to do this each loop for every dynamic object.

So, my question is this: Is this really the best method? Is there an alternate method? Or am I going about this in the best way there is?

Thanks



BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Feb 2008 10:53
Have you seen Box 2D in the program announcements section? It's a 2D Physics Dll
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 23rd Feb 2008 11:40
Yes, I have seen it, thanks.
However, it lacks a lot of the features of DarkPhysics which is why I wanted to go down this route.



Oolite
18
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Middle of the West
Posted: 23rd Feb 2008 14:02
I had a little example somewhere that i converted from when i tried it with ODE, i'm on the laptop at the moment, when i get back i'll see if i can dig it out from somewhere.

I think you are going the best way about it, i did the same but then transfered the X and Y coordinates of the 3d object to a sprite.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Feb 2008 15:42
How about 2 invisible rigid body planes in front of and behind the playing area? That would prevent any 3D action at all though. So if you were planing on 3D particle explosions for example, this is not a good idea
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 23rd Feb 2008 17:16
Not practicle.
It would prevent movement in the Z plain but there would be either constant collision or bouncing from the front plain to the rear and vice-versa. Also, it would still allow rotation around the X and Y axis which I need to prevent.



monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 23rd Feb 2008 20:33
You could use the phy make point in plane joint function, there is a demo program in the tutorials directory under dark physics.

Projects Started: 20
Projects Completed: 0
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 24th Feb 2008 02:07
How About Always Dampening a Certain Access? You Can Control The Velocities and you can read them - so I think you caould Read x,y,z Velocities, then set them back - except the one axis you would always set to Zero.

also you can kinda Override the positions yourself... Like Bump Something, Grab the Velocities and Rotations, Then Firce Object back to "Depth" you need, then restore the forces.. (Again maybe zeroing out undesired Travel : i.e. Out your screen! LOL)

Might work.

BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 24th Feb 2008 05:14 Edited at: 24th Feb 2008 05:18
Quote: "How About Always Dampening a Certain Access? You Can Control The Velocities and you can read them - so I think you caould Read x,y,z Velocities, then set them back - except the one axis you would always set to Zero.

also you can kinda Override the positions yourself... Like Bump Something, Grab the Velocities and Rotations, Then Firce Object back to "Depth" you need, then restore the forces.. (Again maybe zeroing out undesired Travel : i.e. Out your screen! LOL)

Might work."


That is what Scraggle is suggesting, but he wants to know if there is a better alternative.

I would also be interested if there is a simpler way to achieve this, other than set the limits of each object.

Maybe Mike might be able to implement a restriction command, so the physics is "turned off" globally on a certain axis.

eg
phy compute position data 1,1,0
phy compute angular data 0,0,1
0 denoting off and 1 denoting on

Such a command will give rise to some excellent 2D stuff.

Although I don't know how hard that would be to add in.

monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 24th Feb 2008 11:35
Quote: "You could use the phy make point in plane joint function, there is a demo program in the tutorials directory under dark physics."


This function locks movement along a certain plain. The demo program which I mentioned demonstrates an object that has it's movement restricted to the X & Y axis.

I have the attached the project so you take a look if you don't have this project.

Projects Started: 20
Projects Completed: 0

Attachments

Login to view attachments
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 24th Feb 2008 17:21
There is a saying about the right tool for the right job.

Thrust appears to be an ideal candidate for sprites. What advantages do you think you will get our of using DP for this task?

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 24th Feb 2008 17:49 Edited at: 24th Feb 2008 17:50
There are 3 reasons that spring to mind as to why I would use 3D over sprites:

1) Why re-invent the wheel? DarkPhysics is there, so use it.
2) I have gun turrets that track the ships movement. It would need an awfull lot of sprites do get the same result.
3) My plan was never to make this into a full game (although I might) it was and still is, a tool to teach myself to code in C++. I have many years of coding experience in BASIC but have never got round to learning C++. Now I need to. So, I have chosen Thrust as a project to learn by.

My method is to write a small section of code in DBP and then convert it into C++ (using GDK). Yesterday I wrote the code that allows my ship to thrust around a level and have the turrets track its movement and today I have been trying to reproduce the same results in C++ ( with only marginal success so far)





Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-20 00:26:19
Your offset time is: 2024-05-20 00:26:19