GameMaker Making a object "instance" made out of multiple instances

M

Mythi.T

Guest
I know the title seems wack as hecc, but I will explain what I am looking for now, as the I can't do that in one sentence.

So, take the flash game "Galaxy Siege 3" as my example
LINK: https://www.silvergames.com/en/galaxy-siege-3
The ship you control in this game is made out of separate blocks or tile or sections, each containing a weapon or a resource collector or a buff "block" or section

I want to make a ship system like the one in Galaxy Siege 3 but I have absolutely no clue how.
All I want to know is how to program a system that "links" each separate ship component, where each component or block is a single instance, but all put together, this cluster of them behaves like a single instance, but each block or section has its own identity, so they can keep a variable, run their own code, and destroy themselves without deleting the entire ship. Basically how do I make the ship seen in Galaxy Siege 3.

If you can provide answers that would be great. If you don't know how to solve my problem, linking me to other resources would be great as well. I would rather learn how then to copy code.
 
Last edited by a moderator:

TheouAegis

Member
Since you brought up the game, that means that you have played it, right? So then you should be familiar with one of the core aspects of shipbuilding in that game: all of the parts are placed on a grid. Furthermore, the grid is centered in the middle bottom cell. Since you are obviously a beginner, just use a ds_grid of the same size as the maximum size of the ship. Fill every cell in the grid with a value of noone. Set the value of your middle bottom cell to -1 and then set the sails around it that will be available to build on also to -1. So if a cell has a value of -1, it can be built on, but if it has a value of no one, it cannot be built on. when the player puts a part of the ship on a cell, you can either set that sell to the ID of the part or to some numerical value (up to you). if the player picks up a part that has already been placed in order to move it around, set the cell that the part was in to -1 immediately. You would been basically be using a drag and drop inventory to handle placement of the ship parts. Then for the actual gameplay, well, in Galaxy Siege the ship doesn't rotate, does it? if that's the case, then all you have to do is move all ship parts left or right the same amount or up and down the same amount or whatever. However if you are going to rotate the ship, then you will need to use the lengthdir_* functions to track where each piece will be relative to the middle bottom cell.
 

samspade

Member
I know the title seems wack as hecc, but I will explain what I am looking for now, as the I can't do that in one sentence.

So, take the flash game "Galaxy Seige 3" as my example
LINK: https://www.silvergames.com/en/galaxy-siege-3
The ship you control in this game is made out of separate blocks or tile or sections, each containing a weapon or a resource collector or a buff "block" or section

I want to make a ship system like the one in Galaxy Siege 3 but I have absolutely no clue how.
All I want to know is how to program a system that "links" each separate ship component, where each component or block is a single instance, but all put together, this cluster of them behaves like a single instance, but each block or section has its own identity, so they can keep a variable, run their own code, and destroy themselves without deleting the entire ship. Basically how do I make the ship seen in Galaxy Siege 3.

If you can provide answers that would be great. If you don't know how to solve my problem, linking me to other resources would be great as well. I would rather learn how then to copy code.
That basic idea is very straightforward and not very complicated. The full idea of what you see in galaxy siege would be moderately complicated, but still doable.

Here is a very, very basic example:

Code:
///obj_ship create event

my_gun = instance_create_layer(x, y, layer, obj_gun);
with (my_gun) {
    owner = other.id;
}

///obj_gun step event
with (owner) {
    other.x = x;
    other.y = y;
}
You can follow that same principal for parts added to the side, the back etc.

If you were trying something like galaxy siege, I would use a grid. But it might be easier to start with the above method where you have a central object that spawns other objects.
 
Top