GalGen library

Community Forums/Showcase/GalGen library

schilcote(Posted 2009) [#1]
I made a little thingy that generates a galaxy and draws it in real time. I call it GalGen. You just have to call GenerateGalaxy(1000) and it'll conjure up a galaxy of a thousand stars, and then you just have to put DrawGalaxy() at the end of your GFX loop (it works better at the end because it flips buffers when it's done, flipping buffers twice in a GFX loop tends to make things blinky) and you have a galaxy! The library is all graphics at this point, you have to supply all the game mechanics yourself.

Screenshots:
http://img5.imageshack.us/i/galgen1.jpg/
http://img5.imageshack.us/i/galgen2.jpg/
http://img5.imageshack.us/i/galgen3.jpg/
http://img5.imageshack.us/i/galgen4.jpg/
http://img5.imageshack.us/i/galgen5.jpg/

Download:
(Coming soon...)

Constructive criticism and/or suggestions welcome.


Who was John Galt?(Posted 2009) [#2]
Screenshot not visible here.


schilcote(Posted 2009) [#3]
Fixed.


plash(Posted 2009) [#4]
Only the first two images work.


GfK(Posted 2009) [#5]
Its just a black screen with coloured dots in it?


ImaginaryHuman(Posted 2009) [#6]
Right now I could only say that DrawOval(Rand(0,640),Rand(0,480),3,3) would do the same job. ?


schilcote(Posted 2009) [#7]
Well, that would be good if you wanted to draw a pretty picture, but it's kind of useless for making games because you have no idea where the dots are. Perhaps I didn't explain it thouroghly, GalGen is a library for generating and managing galaxies which are populated with stars. You give it a global containing the size (size*size square) of your galaxy, and then pass the number of stars you want to GenerateGalaxy(). You then call DrawGalaxy() in you GFX loop, draw a little spaceship and make it move, put some basic interactions with the stars in, and you've got a basic space exploration game.


Jeppe Nielsen(Posted 2009) [#8]
But does the library just place the stars randomly?, or is there some clever positioning going on?


schilcote(Posted 2009) [#9]
Aside from making sure that no star ends up in the same place as any other star, no, it's just random. However, you can add stars on your own, the function for making stars is seperate from the function for generating a random galaxy.


Jeppe Nielsen(Posted 2009) [#10]
Ah ok, I see, maybe make it so you can create different shaped galaxies, spirals and so on, like we did, when I worked on Lost Impire: immortals; there we had a galaxy generator, where you could specify number of stars, number of arms, curviness, and so on:

http://gamevideos.1up.com/video/id/17217


schilcote(Posted 2009) [#11]
Well, the library is more for managing the galaxy, you don't neccicaraly have to use GenerateGalaxy, you could write your own.


Sokurah(Posted 2009) [#12]
A couple of years ago a couple of my friends were making a space exploration game ala VGA Planets, called Pollux: Lost Empire.

When I saw an early version of the game I noticed that they placed the stars completely randomly in their galaxy and I asked "why not make it look like a galaxy?"
"We don't have the time" they said.
...so I said "bullsh!t!" :-D

I wrote this little piece of code for him that same evening (well, in VB6 because that's what they were using) although I'm not sure if they even used it.

It'll give you a galaxy like the one below. Just write a bit of code to store the coords and perhaps tweak it so two stars won't end up on the same coords and you're ready to go. A shake'n'bake galaxy. :-D

It's not rocket science but perhaps someone can find a use for it. ;-)






schilcote(Posted 2009) [#13]
Hmm... I might implement that at some point. Thanks for the code.


Jeppe Nielsen(Posted 2009) [#14]
Funny, it's the same game I am referring to :-), I actually programmed some of it.


Sokurah(Posted 2009) [#15]
@Jeppe
Funny, it's the same game I am referring to :-), I actually programmed some of it.


D'oh!..didn't even see your post. :o)


Jeg kender Flemming og Michael btw. :-)


schilcote(Posted 2009) [#16]
I'm dragging this one out of the dustbin.

I tried to implement Sokurah's spiral galaxy, but it dosn't seem to scale well, I get an enormous hole in the center of the galaxy, which isn't very realistic. How can I solve this problem?


Sokurah(Posted 2009) [#17]
Well, that should be an easy fix.

What scale do you want to use?


schilcote(Posted 2009) [#18]
Any scale has to work. Well, not ANY any, but within the limits of GalGen 3 years from now. So, maybe from 5,000 stars over 10,000 pixel square, to 50,000 over a 1,000,000 pixel square.