• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Randomly Generated Galexies

R

Ramaraunt

Guest
Its pretty easy. Here is a milky-way-esque galaxy I made in GM:Studio. This one has 10,000 stars.



I want to make a giant room now, 10,000 times 10,000, for you to zoom in, drag your mouse to move around, etc. This will be the main map for a game I'm working on. Any help would be appreciated.
 
D

Dengar

Guest
probably chunking and tiles. but definatly use tiles and when you zoom out at certain points have tiles check to see if others are next to it and if so remove them, that way ur not drawing uneeded overlapping tiles.
 

Roa

Member
use polygons. You can load up a single image, batch the faces into a single buffer, and submit that for data crunching 1000 fold faster than trying to do this with sprite loops, objects, or tiles.

Plus its easier to scale, both visually and in scope.
 
R

Ramaraunt

Guest
Wow I thought I was really cleaver figuring out an equation to do this. But I guess I'm dumb because I have no clue what any of you are talking about :/
 
F

Fodderbot

Guest
You could also consider using viewport manipulations and views
 
  • Like
Reactions: Roa

Roa

Member
Yeah, I miss understood. Its late for me. You want to use views and scale them to zoom in and out.
 
R

Ramaraunt

Guest
Alright that makes more sense! Yeah i've begun doing this, but its hard to get the perfect size for everything. Either its way too big, and I cant see anything when I zoom out, or its too small and the pixels are too close together when I zoom in so I can't do what I want with them later on.
 
F

Fodderbot

Guest
You can actually get some fairly decent results with this sort of manipulation of your room space.

I did a short vid capture to show you an example from the level editor I'm developing for my current game.
Its roungh but It might give you a few ideas.


Fodder
 
R

Ramaraunt

Guest
Yeah I came up with a solution for the sprites not being visible when zoomed out
Code:
if view_wview < view_wport
{
    draw_self();
}
else
{
    if view_wview < view_wport * 2
    {
        draw_sprite(spr_small_star,0,x,y);
    }
    else
    {
        if view_wview < view_wport*4
        {
            draw_sprite(spr_4x_star,0,x,y);
        }
        else
        {
            if view_wview < view_wport*8
            {
                draw_sprite(spr_8x_star,0,x,y);
            }
            else
            {
                if view_wview < view_wport*16
                {
                 draw_sprite(spr_16x_star,0,x,y);
                }
                    else
                    {
                    if view_wview < view_wport * 32
                    {
                        draw_sprite(spr_big_star,0,x,y);
                    }
                    else
                    {
                        if view_wview < view_wport * 64
                        {
                            draw_sprite(spr_huge_star,0,x,y);
                        }
                    }
                }
            }
        }
    }
}
Now the only problem is, I can't zoom out all the way. I guess the system I have right now is not the best. *EDIT* Fixed it so I can zoom out, though the zoom speed isn't the best at times.
 
Last edited by a moderator:
F

Fodderbot

Guest
If your stars don't have to be interactive, you can display them as backgrounds and you will save alot of processing power and cpu cycles. you can always base star selection based on location of the pointer mapped to a ds_grid cell that contains an object instance ID.

the trick is to only use sprites for really important interactive items like characters mob etc.
 
F

Fodderbot

Guest
Its pretty easy. Here is a milky-way-esque galaxy I made in GM:Studio. This one has 10,000 stars.



I want to make a giant room now, 10,000 times 10,000, for you to zoom in, drag your mouse to move around, etc. This will be the main map for a game I'm working on. Any help would be appreciated.
You know if you stare long enough at the center of this in a dark room it looks like the stars are moving.
 
R

Ramaraunt

Guest
I dropped it to 5000 (which is still A LOT of stars), and I'm getting no performance drop whatsoever. So performance isn't an issue right now, the issue is finding a way to generate pseudo-random solar systems for each star. Using seeds so they don't have to be saved in memory constantly. Since game maker has a built in randomize seed function this is easy.

Also, I eventually want to make a ds list for each star with all of the star's neighbors, for ai pathing. Is there a good way to do this?

Another issue is, it takes a long time to load this map (obviously). This is fine, because it runs fine after it loads. The issue is, I eventually want the player to go back and forth from this map to a local map where they can pew pew around in their space ship. Is there a way to load this new room for local movement, and keep the global map up? Or maybe there is a way to have this work with views? or maybe something else?
 
Last edited by a moderator:

Bingdom

Googledom
I got a question, would it be better to put this whole thing as a surface, then draw it as a surface or have i been mistaken, that it's the same thing. :)
 
T

ThunkGames

Guest
I got a question, would it be better to put this whole thing as a surface, then draw it as a surface or have i been mistaken, that it's the same thing. :)
Doing this plus draw_surface_part would make performance impact negligible. Interacting with the stars, however, would be an impossibility (unless the data was also in a data structure) without checking the color of each pixel, which would be problematic in and of itself.
 

Bingdom

Googledom
Doing this plus draw_surface_part would make performance impact negligible. Interacting with the stars, however, would be an impossibility (unless the data was also in a data structure) without checking the color of each pixel, which would be problematic in and of itself.
Thanks for clearing that up, i have much to learn ;).
 
R

Ramaraunt

Guest
Alright this is getting good. Got solid frames with 5000 stars. Now I'm working on the solar systems. Maybe I could use a sprite artist, but its looking alright for now.

I got the sun generation done, even is a 1 in 1000 chance for a binary system. Only having the engine draw basic circles to signify planets.
 
T

Teslatronik

Guest
Nice work pal. you definitely need a way to find them planets quicker ;) but the galaxy shape is spot on! I've subbed to you on YT.. I'll keep my eye on this.
 
F

Fodderbot

Guest
If you need to find a stellar system quicker you could store any system objects created by their id in ds_list structure.
the trick is to have a unique id for each location instead of two (x,y) positional values you can create this key for finding your system quite easily based on its position.

For example:
If you have an area or grid of 100 x 100
Take the y value and multiply it by 100 and add the the x value to the result.
This gives you a unique key for each location on your map.
therefore when you need to know system information of a specific location do the math on the location ((y*100)+x) input it into your
ds_list to find the object id of your system object and woolahh, access to the object that has all your relevant data in it.

Fodder
 
Top