Control spaceship

P

Pegmis

Guest
Hello.
It has been a while.

I have been learning a lot in game maker and am trying now to figure out how to build and control a space ship in game maker.

I build a ship in the room, and am able to move the player around the room.
What I want to do is make an object (like the captains chair) that would allow me to control the whole ship (several objects put together)

I believe making a system that allows me to build a ship in the game would involve ds_grid system, but my main focus is making it so the player object stops moving, and the controls then move the whole ship.
 
F

float

Guest
Uhm, is this top-down? For transfer of control, you can always try a variable that points to which object is currently bound to the controls, i.e. when the player sits in the chair (_obj_control = obj_ship) then when you can then move the spaceship by changing your movement codes to reference the variable instead of obj_player.

As for the ship that is made up of several objects, you can try point_distance, and point_direction as a way to position them relative to the main body of the ship, so that they maintain their relative position even when you turn around the ship.
 
G

Gillen82

Guest
I think finite state machines is what you are after. Have a search for more information, but basically, for every "state" that your ship/captain can be in, you can load a specific script for the state. They also help to keep your project/code more organized
 
S

Sinaz20

Guest
I've been chatting with @Pegmis about his goals. I took it upon myself to make a little demo. It just became a fun challenge that gave me an opportunity to learn a lot more about GMS:2 (hoo, boy, I hope that's what you are using.)

I wanted to share where I'm at with it...

Dropbox Link Executable (Just follow the onscreen text directions!)

I have to document all the code and objects before I can post up the example source. I should have that done by tomorrow evening.

A quick breakdown of what's going on here...

I use the bottom-up nature of the layer system to control compositing of two cameras.

There is a series of layers that make up the ship environment. It contains all motion planning, crew characters, collision objects, collapsed autotile rooms, etc.

There is another couple of layers that handle a proxy ship in a space environment.

The compositing controller turns these layers on and off for each camera pass.

The ship environment is static to keep things like motion planning, collision, and such simple. The camera that renders it is inversely transformed by the proxy ship to get it to appear superimposed over the invisible proxy ship.

The characters are also inversely transformed to keep them upright in respect to the final view.

I'm using instance changing to change the behavior states of the captain character and the ship.

Using this method, you could basically neatly park a bunch of ship environments in the room... like in a grid... and composite each one to its own proxy ship flying around in the room.

All this art has been nicked from the internet... so of course, the assets are not to be used beyond this learning exercise...

Screenshot 2017-11-13 21.40.52.png

[edit] Actually, the captain sprite is mine, and the room tileset I made :p
 
Last edited by a moderator:
Top