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.

Code Snippets / Your very own black hole

Author
Message
Philip
20
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 12th Mar 2006 19:43 Edited at: 12th Mar 2006 19:43
The scariest thing in nature ... (other than IanM that is)

This is really just mucking about more than anything else.

Its an incredibly simple black hole simulator. I say incredibly simple because I haven't bothered to set a decent event horizon constant and so a lot of the particles escape.

Arrow keys, return and shift to control the camera. Escape to reset it. A and S to increase or deceased gravity. Minus gravity of course repels particles from the "black hole".

You'll need Cloggy's D3dfunc plugin to run this.



Cheer if you like bears! Cheer if you like jam sandwiches!
Quote of the week: "... I started learning DBP while I was a Satellite Network Controller for the US Army Space Command ... "
Darkbasic MADPSP
18
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 12th Mar 2006 22:13
Looks neat on PSP atm will try Later

where i went on holiday to
www.portaventura.es and also http://themepark.nl/ubbthreads/showflat.php?Cat=0&Board=UBB7&Number=661483&page=0&fpart=all
Scilynt
21
Years of Service
User Offline
Joined: 13th Nov 2002
Location: .-#-.
Posted: 26th Mar 2006 14:48
Was just looking for your original circle code to try out the batching stuff in the new D3DFunc, and found this. Was a great example to use.

Apart from being a nice demo as is, the original runs at 74 FPS. Adding in the new batch commands sees that jump to 690 FPS!!

Not too much difference in the code either, during setup you need to initialize the batch arrays using

Quote: "D3D_Batch_Set_Dot3D total_particles
D3D_Batch_Set_Line3D total_particles"


Since you can only use a single point size for 3D dots in a batch, you set that up here aswell.

Quote: "D3D_Batch_Set_Dot3D_Size 3"


Then rather than drawing straight to the screen, you replace the current drawing commands with the batch, so...

Quote: "
d3d_dot3d particles(i).pos.x, particles(i).pos.y, particles(i).pos.z, 3, rgb(255,215,000), 1
d3d_line3d particles(i).pos.x, particles(i).pos.y, particles(i).pos.z, particles(i).pos.x - particles(i).velocity.x, particles(i).pos.y - particles(i).velocity.y, particles(i).pos.z - particles(i).velocity.z, rgb(255, 0, 0), 1"


...changes to...

Quote: "D3D_Batch_Add_Dot3D particles(i).pos.x, particles(i).pos.y, particles(i).pos.z
D3D_Batch_Add_Line3D particles(i).pos.x, particles(i).pos.y, particles(i).pos.z, particles(i).pos.x - particles(i).velocity.x, particles(i).pos.y - particles(i).velocity.y, particles(i).pos.z - particles(i).velocity.z, 0xFFFF0000"


And finally, you have to draw everything using

Quote: "
D3D_Batch_Draw_Dot3D 0, 1, 0
D3D_Batch_Draw_Line3D 0, 1, 0
"


Let's see how quoting code turns out, didn't want to have a click to view a couple of lines.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 26th Mar 2006 23:08
Just tried this but it crashed out reporting an error on line 4 d3d_init. The obvious answer is to say that I need Cloggy's plugin, but I thought I had it.

In my Compiler > Plugins-User folder, I have a DLL named d3dfunc.dll 1.0.0.1

Is there a later version? or has 6.3b broken it?

Thanks


Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 27th Mar 2006 10:32
Scraggle,

The latest version is V3.2 and can be found here http://forum.thegamecreators.com/?m=forum_view&t=69221&b=5

It will work with philips code, but the batch commands are in version 3.5 which will be out very soon.

Cheers,

Cloggy
Philip
20
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 27th Mar 2006 20:30
I am personally worried that Scraggle should think it appropriate to go around creating very simplistic Newtonian black holes in his computer. Does he not realise that he may just destroy spacetime in his immediate vicinity?

Cheer if you like bears! Cheer if you like jam sandwiches!
Quote of the week: "I highly recommend Philip's Vector Tutorials" (RiiDii)
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 27th Mar 2006 20:31
What is d3d_init


At least farting ferrets are better than stinky stoats.
Okashira
18
Years of Service
User Offline
Joined: 8th Feb 2006
Location: Right here.
Posted: 27th Mar 2006 23:03
I can make a black hole in Dark Basic. Here is the code:



In reality, a black hole is:

A neutron star so dense that is gravitational field would not permit any energy to be emitted, causing it to be invisible.

Did you fail 5th grade science?

Just joking. The thing looks pretty cool, good job.

-Okashira

Let the games begin!
Philip
20
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 28th Mar 2006 13:44
That definitions is partly right. Many kinds of black holes emit what is known colloquially as "Hawking radiation" as Professor Sir Stephen Hawking of Cambridge University was the first to mathematically postulate it.

On the internet there are some lovely artistic renditions of what Hawking radiation might look like (if you happened to have a camera that took pictures of radiation).

Cheer if you like bears! Cheer if you like jam sandwiches!
Quote of the week: "I highly recommend Philip's Vector Tutorials" (RiiDii)
Okashira
18
Years of Service
User Offline
Joined: 8th Feb 2006
Location: Right here.
Posted: 28th Mar 2006 18:40
Alright. Ya got me.

Anyways, very nice!

Let the games begin!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Mar 2006 12:49 Edited at: 29th Mar 2006 12:53
Quote: "A neutron star so dense that is gravitational field would not permit any energy to be emitted, causing it to be invisible."


well technically, its not visible because it keeps light from escaping, if you really wanted to get specific. But an article published last year claims this is no longer true of a blackhole definition. I forget exactly what it said and what the new evidence was, but it was interesting to read. I'll have to find it.

quantum tunnelling gets through a black hole, theorectically of course.


I installed the latest dll, but i get a d3dx9_25.dll missing error.


Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 29th Mar 2006 13:15
Phaelax,

I have compiled the latest dll to work with 5.9. It is attached to a post in the d3dfunc thread in program announcements. It should stop that problem happening.

Cheers,

Cloggy
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Mar 2006 23:03
That's the version I used, 3.5.

I think I'm using DBP 5.8 though.


Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 30th Mar 2006 00:15
can we get a screenie?

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Mar 2006 09:52 Edited at: 30th Mar 2006 09:54
Now I have a headache.

I got a bizarre error when I pressed teh spacebar, I don't know if it's U6RC3, or D3D...

Early Exit Error: You have hit a FUNCTION declaration mid-program!

[EDIT]: Looks like in the latest upgrade, you have to END your program.

Login to post a reply

Server time is: 2024-04-26 13:31:30
Your offset time is: 2024-04-26 13:31:30