• 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!

Game Mechanics Build your own spaceship idea

Psycho_666

Member
Hey.
Long story short: I'm toying with the idea of "build your own spaceship" game. You assemble different kinds of spaceships using different modules and system ala Gratuitous space battles.

Short story long: I've been toying with this idea for years now. And the current situation gives me time to try and do something about it.
You will build your ship on multiple layers of design:
Layer 1: you will put together different modules. Hull, where generators, storage, etc will be, weapon modules, where weapons and ammo are, engine modules, etc etc...
Layer 2: each module will have a bunch of systems attached to it. For example the weapon modules will have let's say 2 weapon systems and 2 general systems for ammo storage or energy for lasers or command modules for drones or stuff like that. On the other hand the engine module have only engine systems and fuel storage. So my idea is that even if you use the same modules you can design the systems differently so you will have pretty much a different ship no matter it uses the same modules.

Execution: I am massively worried this is just a bunch of arrays transfering numbers between each other.
The ship will be basically an array that is full of arrays for each module that is full of arrays for each system in the module.

Variety: that's easy. Basic projectile weapons, missiles, heat seeking missiles, light lasers, laser cannons that doesn't rotate and shoot only straight ahead, light plasma guns, heavy plasma cannon, decoy systems, drone systems for offense and defense, repair modules, light speed engines, burst engines for quick maneuvers, etc etc...

Goal: the idea is to be able to build whatever ship you want and be able to travel between planets and do missions and stuff like that. You build the ship as you like it. Different modules have different visuals so you do as you like.
Remember Freelancer? Basically that, but much simpler and 2D.

How does that sound to you, good people? My main concern is making the ship building system. Everything else I can do and have done before.

PS: I found a really nice image online perfectly illustrating my idea...
preview.jpg
 
Last edited:
Approved!

Perhaps have a technology tree type system. Where there is some way to unlock / research / buy / discover new technologies. So at first you are limited to basic tech. Then you can spend time to research new components. Maybe the highest tech components have to be discovered on missions / hard-to-find planets etc...

I'm imagining a kind of X-Com / Kerbal Space Program / Captain Forever / Star Control 2 mash-up kind of strategy/action/adventure game!
 

Psycho_666

Member
My idea was more of a Freelancer thing where you explore the galaxy and every system have some specialization and you can buy unique stuff from them that you can't from the other systems.
I don't want to overcomplicate things with research and upgrades before I've done the basic stuff...
I'm honestly most worried about building the ship and then controling the thing, cause I need to make each part rotate around central point and act independently but in unison with the rest and that can become a mess...
 
My idea was more of a Freelancer thing where you explore the galaxy and every system have some specialization and you can buy unique stuff from them that you can't from the other systems.
I don't want to overcomplicate things with research and upgrades before I've done the basic stuff...
Good point, get the basics working first. I didn;t play Freelancer

I'm honestly most worried about building the ship and then controling the thing, cause I need to make each part rotate around central point and act independently but in unison with the rest and that can become a mess...
My first thought was to have a grid-based layout for constructing the ship, where you can easily snap parts into the grid layout. Then for in-game, you copy the complete ship to a single surface so its just one sprite.

Of course, then you have to worry still about tracking the positions of the various weapons and firing points. And do the separate modules have their own hitpoints. In which case you would still have to build hitboxes for them. And would have to have a system to show damage on the single sprite.

Having them as separate modules would make the above easier in-game, but then you need a solid instance linking system to keep the parts together, and like you said, a way to have all the parts operating together.

If you have a static core of the ship, and everything else is parented to it, you can just have them maintain their position using GML built-in trig functions.

And then each module could have its own "Step" code - but what you do is you put the operating code in a User Event for each module. Then the static core of the ship maintains a list of all modules attached to it. The static core can then run the User Event code manually, then you have precise control over the modules and when they run their code.

Well lots of things to think about. If you have an idea already, happy to discuss/critique with you. I quite like these kinds of games.
 

HayManMarc

Member
I've always wanted to do this, too. Either with spaceships or battle cars (Car Wars). I started a Car Wars clone, but was soon crushed by the scope of the idea. I realized that this would take way more planning than my experience was really capable of. Perhaps someday.

Good luck to you. It's a great idea.
 

Psycho_666

Member
If you have a static core of the ship, and everything else is parented to it, you can just have them maintain their position using GML built-in trig functions
That's what I was thinking of...
What is that trig function you are talking about?

I was thinking about just drawing the ship into a single.image as you suggested earlier, but I want to be able to generate NPC ships as well and I would have to run scripts to draw them as a single image before I start the battle screen and it gets complicated... Once I get the system of central module that control all other modules, I can just use that system for all ships in game.

Maybe I won't go to the depth of individual module HP. I'm thinking more of an arcade style twin stick or something mile that.
I realized that this would take way more planning than my experience was really capable of.
Honestly, once I complete the system for ship construction and make the combat scripts the rest of the game will be just data entry...
Go near a planet and a window opens where you can trade, repair, upgrade modules, etc. Same with space stations. You have one screen for a solar system and one galaxy map screen. With that done it's just data entry...
 
What is that trig function you are talking about?
I was thinking of point_distance() / point_direction() (which are vector functions actually) and lengthdir_x() / lengthdir_y() - you can also use dcos() dsin() for object positioning.

At the moment, I have a parenting system. When I link an instance to another, the child instance saves the parent id, the current distance from the parent object, and the current angle to the parent instance.. Then I do this in the step event of all instances:

Code:
// Positioning for multi-instance objects linked together
if ( valid(parent_instance) )
{
    var _angle =  angle_offset + parent_instance.angle
        
    //var dX = lengthdir_x(distance_from_center_of_parent, (angle) mod 360);
    var dX = distance_from_center_of_parent * dcos(_angle)

    //var dY = lengthdir_y(distance_from_center_of_parent, (angle) mod 360);
    var dY = distance_from_center_of_parent * dsin(_angle) *-1
        
    x_3D = parent_instance.x_3D + dX
    y_3D = parent_instance.y_3D + dY
}
I left the commented out code in their, because its possible to do it with either lengthdir_x/y or dcos/dsin, whichever you are more familiar with.

I don't know if this is the best way to do it, but its working for me at the moment.
 

Rob

Member
I have played a lot of sci-fi 4X games, as well as games like Freelancer and I always found the ship design to be one of the things I like the most about that kind of game, and it's something I've thought about on and off over the years - eg "How to make an engaging ship design system in an efficient way that makes sense both as a player and designer / programmer."

Ascendancy just had x amount of squares that you could put anything on (iirc) and the bigger the ship, the more space/squares you had.

ascendancy ship design.png

Stellaris does this a little better where you still have squares/spaces but you have to decide what each of the 3 "slots" of a ship design will be. Is it point defence, ship hangar, long / medium / short range weaponry - and then the shields/armour/extras can be added as well, in specific slots (shields/armour share the same squares).

Stellaris Ship Design

I could show other things like Wayward Terran Frontier Falls, Star Command, The X Series? but I think the most in depth designer I've found is Starship Corporation, but I never bought the game due to bad reviews.

As a player I'd like to be able to decide where my defences would be. If it's a 2D game, that would mean the ability to put less/more/no shields or armour on each of the 4 sides (assuming each side of the ship took damage separately). If there is some kind of power/power management system, I'd like to be able to place whatever power sources there are wherever I like, and the option to give them more/less/no protection. I'd also want to have different hull parts that I could add remove with the option for more/less turrets/engines/other weapons/cargo space etc. If the cockpit takes damage separately, I'd want to be able to place that where I like too (or at least have some options).

As a designer/programmer that would be a LOT of work though lol.
 

Psycho_666

Member
I always found the ship design to be one of the things I like the most about that kind of game, and it's something I've thought about on and off over the years - eg "How to make an engaging ship design system in an efficient way that makes sense both as a player and designer / programmer."
Me too :) it's about creativity, not really min maxing. There are games where there is one objectively better solution than all the others and you have no reasons to use anything else. My idea is to build it as you like. More weapons for glass cannon, more engines for manuverability, more drones for repairs and decoys and defenses and stuff ...
(assuming each side of the ship took damage separately)
No, that is way too complicated. Actually it's not, but it will be a huge mess to program on top of everything else and I really want to do the ship building algorithms first.
If there is some kind of power/power management system, I'd like to be able to place whatever power sources there are wherever I like, and the option to give them more/less/no protection. I'd also want to have different hull parts that I could add remove with the option for more/less turrets/engines/other weapons/cargo space etc. If the cockpit takes damage separately, I'd want to be able to place that where I like too (or at least have some options).
As a player I'd like to be able to decide where my defences would be. If it's a 2D game, that would mean the ability to put less/more/no shields or armour
Yes, that is the idea. You can have different modules for visual appeal but the modules are not set. You set the modules as well with different systems.
For example you can have a basic weapon module with 1 weapon system and 1 generic system. So you can do lasor with power generator for the laser or heat seeking missiles with storage for the missiles or the most basic machine gun with storage for ammo.

I have an idea for the pilot cabin, but I don't want to do that before I am done with the basic setup.
I am still trying to figure out in my head one thing: I have a grid on which you place your modules and that way you build your ship like a blueprint. But I want to have 1 square modules, larger 2 square modules and huge 4 square modules and that is messing with me... I want to figure that out first.

The idea was to make an array and store each part in its own part of the array, but a 4 square module would need to take 4 parts of the array and that is messing with me. How to store the same thing in an array 4 times without messing up the for cycles...
 

Rob

Member
base the for cycles on the size of the item eg instead of += 1 += 2 and you can have different width/heights eg 2 across, 3 high
 

Rob

Member
Elaborate please?
GML:
module_width = 2;
module_height = 3;
module_part = 24;

if (mouse_check_button_pressed(mb_left) ){

   for (var yy = grid_y; yy < (grid_y + module_height); yy ++){

      for (var xx = grid_x; xx < (grid_x + module_width); xx ++){
          module_array[xx, yy] = module_part;
      }

   }
}
Something like that?
 

Psycho_666

Member
module_width = 2;
module_height = 3;

for (var yy = 0; yy < module_height; yy ++){
for (var xx = 0; xx < module_width; xx ++){
if (mouse_check_button_pressed(mb_left) ){


}
}

That loop will skip over the smaller parts though.
So I may have to run multiple loops to be able to cover all possible sizes and combinations.

OK, I will try some things and I will see what I can do.
 
I am still trying to figure out in my head one thing: I have a grid on which you place your modules and that way you build your ship like a blueprint. But I want to have 1 square modules, larger 2 square modules and huge 4 square modules and that is messing with me... I want to figure that out first.
Not sure how hard this would be to do, but my first implementation idea would be something like this:

1) Setup the info for the various parts which are available. Each part has information on how big it is.
2) Use a grid to represent the current ship. At first the grid is empty / all cells are available. When placing a part, you can use ds_grid_get_sum() supplied with the size of the part to check if the space is free - a sum of 0 would been all spots on the grid where you want to place the part are free. You could mark areas that are not part of the ship with negative values, those areas are not available to place anything.
3) When you place a part, use ds_grid_set_region() to mark those spots as taken. Any weapons added to the ship are also added to a list which stores which parts have been added to the ship and where.

Each part would have a unique id, so that unique id would be the value you set the grid to. Then you know which part is taking up which squares.

So I'd have a database of parts, a grid to help placing the parts during ship construction, and another list which record which parts have been placed on the ship that can be used to easily know which parts/weapons are currently on the ship when in-game.
 

Psycho_666

Member
Not sure how hard this would be to do
I'm not saying it's difficult. It probably isn't, since we had in a long long time ago in games. I just can't quite wrap my head around it.
I'm toying with the idea of having the array be for parts despite the size, instead of squares on the blueprint. That way I care about the parts and the grid and size matter literally only for the drawing.
Something like part 10 is 25pixels left of the center, connected to part 17 to the left and part 184 downwards. And then when drawing I go to the part 10 data array and get how big it is, how it connects to the others, what system can this part have and so on.
That way I completely exclude having a grid 10x10 and trying to fit stuff I to it...
 
Top