# How to get the movement of the Space Pilot spacecraft?

• 9th November 2021, 01:32 PM
daryuss
How to get the movement of the Space Pilot spacecraft?
Hi.
I tried to do the eight-way "rotary" motion to get the same motion as the space pilot spacecraft:
I almost succeeded, but I can't get it to stop by pressing the diagonal, in the eight retention corners.
Generally degrees are used, but using a counter with the maximum value set at 32 "directions", the 8 reference directions are: 0-4-8-12-16-20-24-28. You should try using the Flags on/off method. Anyone know if there is a similar example to download?
It would also be useful for top view driving games, because the "Race car" movement is too difficult.
• 9th November 2021, 03:36 PM
fredetmumu
like that ?Attachment 30758
• 9th November 2021, 07:11 PM
daryuss
WOW. You are great, but really great. 100000 thanks!
• 9th November 2021, 08:14 PM
fredetmumu
Attachment 30759

this version is better with 90 degree and 180 degree
• 10th November 2021, 05:45 AM
daryuss
@Fredetmumu: Thanks again. Honestly, I wouldn't have gotten there! This will be very useful to me.. (I sent you a p.m.)
• 10th November 2021, 09:26 AM
MuddyMole
That seems a little buggy - rotation towards a diagonal (NE, SE, SW, NW) is twice as quick as rotating towards one of the four cardinal directions (N, E, S, W), and it's also possible to hold an angle other than the main 8 directions. It's also quite complicated.

A useful trick I've found, is to have an invisible, stationary object with an 8-direction movement, and just use that to get the direction the player's direction input - it's so much easier than having loads of similar events checking for different combinations of arrow keys being pressed, and often if the player is holding down several at the same time, you'd want to know which they pressed last, etc.

https://1drv.ms/u/s!Atq7cUIJ7uexsUxT...tG8X3?e=3ONKMT
• 10th November 2021, 12:44 PM
Patrice
Physic movement can do it without any event.
• 10th November 2021, 02:11 PM
fredetmumu
Patrice : zero lignes ! ;D
• 15th November 2021, 06:07 AM
daryuss
@MuddyMole, Patrice: Many thanks, you have been genius. Now I have to study the method to stop the rotation, once reached, of the angles 45, 135, 255, 315 (in practice, the 4 diagonals) when you leave the keys (or the joystick). Angles 0, 90, 180, 270 are now ok. Thanks again.
• 15th November 2021, 03:05 PM
fredetmumu
i just try space pilot and it seems that when you release keys, rotation stop at the actual angle and not at the next diagonal
• 15th November 2021, 05:20 PM
MuddyMole
Quote:

Originally Posted by fredetmumu
i just try space pilot and it seems that when you release keys, rotation stop at the actual angle and not at the next diagonal

That's true.

Stopping at the diagonals is actually quite tricky. Technically, my version does it, but you need to release two arrow keys at *exactly* the same moment, which is very difficult.
You could easily make it so that once the player stops pressing any arrow keys, the ship rotates towards the nearest of the 8 main directions, but with 360 degree sprite rotation it will look quite "jittery" (with 32 directions of animation, you could probably get away with it).

eg. https://1drv.ms/u/s!Atq7cUIJ7uexsU0Q...Bpki-?e=YKMNlY

The only alternative that springs to mind, would be to add some kind of delay, to check if the player releases the two arrow keys at *almost* exactly the same time - but that would make the controls less responsive, which is the last thing you want to do in a fast-paced shooter.

Personally, I actually found that control scheme really awkward and unnatural. I grew up playing a lot of Sopwith II ( https://www.youtube.com/watch?v=B8SLHKPxw4Q ) and various Asteroids clones, so something more like a racecar movement feels a lot better to me (and more "realistic" - if you're flying a plane, you don't pull the joystick left to fly East; you pull it left to turn left).
• 15th November 2021, 07:55 PM
danjo
i wrote a bosconian and also time pilot clone.. i should really check out what i did on those, coz it seems like the same 8 dir movment you're after. - i will check later tonight at home if you're still struggling with this
• 15th November 2021, 11:50 PM
danjo
Ok, upon checking, the bosconian used 8 dir, and was "so so" it still did angles, but the Time Pilot was all coded, and its really good... but not a simple do this and this... it has 40 lines (although it could be optimized), but it involved setting a direction target, and then rotating the ship depending on which way it was going to the new dir, So it flew in every direction properly without resetting back to other anges.
• 15th November 2021, 11:59 PM
danjo
My code for time pilot flying:
Code:

```[ fly jet ]         * direction target of player jet >= 32                 player jet : Set direction target to 0         * facing direction of player jet >= 32                 player jet : Set facing direction to 0         // select a direction to face jet         * Always                 player jet : Set direction to facing direction( "player jet" )         // determine which way to rotate depending on target direction         // facing 0         * facing direction of player jet = 0         + direction target of player jet >= 4         + direction target of player jet <= 16         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 0         + direction target of player jet >= 20         + player jet: do turn is on                 player jet : Set facing direction to 28                 player jet : Set do turn off         // facing 4         * facing direction of player jet = 4         + direction target of player jet >= 8         + direction target of player jet <= 20         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 4         + direction target of player jet >= 24         + player jet: do turn is on                 player jet : Set facing direction to 0                 player jet : Set do turn off         // facing 8         * facing direction of player jet = 8         + direction target of player jet >= 12         + direction target of player jet <= 24         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 8         + direction target of player jet >= 28         + player jet: do turn is on           OR         * facing direction of player jet = 8         + direction target of player jet < 8         + player jet: do turn is on                 player jet : Set facing direction to 4                 player jet : Set do turn off         // facing 12         * facing direction of player jet = 12         + direction target of player jet >= 16         + direction target of player jet <= 28         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 12         + direction target of player jet < 12         + player jet: do turn is on                 player jet : Set facing direction to 8                 player jet : Set do turn off         // facing 16         * facing direction of player jet = 16         + direction target of player jet >= 20         + direction target of player jet <= 32         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 16         + direction target of player jet < 16         + player jet: do turn is on                 player jet : Set facing direction to 12                 player jet : Set do turn off         // facing 20         * facing direction of player jet = 20         + direction target of player jet >= 24         + player jet: do turn is on           OR         * facing direction of player jet = 20         + direction target of player jet <= 4         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 20         + direction target of player jet < 20         + player jet: do turn is on                 player jet : Set facing direction to 16                 player jet : Set do turn off         // facing 24         * facing direction of player jet = 24         + direction target of player jet >= 28         + player jet: do turn is on           OR         * facing direction of player jet = 24         + direction target of player jet <= 8         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 24         + direction target of player jet < 24         + player jet: do turn is on                 player jet : Set facing direction to 20                 player jet : Set do turn off         // facing 28         * facing direction of player jet = 28         + direction target of player jet <= 12         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 28         + direction target of player jet >= 16         + direction target of player jet < 28         + player jet: do turn is on                 player jet : Set facing direction to 24                 player jet : Set do turn off         // reset flag         * Always                 player jet : Set do turn off         // fly         * Repeat while Player 1 Moved top         + NOT Repeat while Player 1 Moved left         + NOT Repeat while Player 1 Moved right         + NOT Repeat while Player 1 Moved down                 player jet : Set direction target to 8         * Repeat while Player 1 Moved top         + Repeat while "Left Arrow" is pressed         + NOT Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved right                 player jet : Set direction target to 12         * Repeat while Player 1 Moved top         + Repeat while Player 1 Moved right         + NOT Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved left                 player jet : Set direction target to 4         * Repeat while Player 1 Moved right         + NOT Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved left         + NOT Repeat while Player 1 Moved top                 player jet : Set direction target to 0         * Repeat while Player 1 Moved left         + NOT Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved top         + NOT Repeat while Player 1 Moved right                 player jet : Set direction target to 16         * Repeat while Player 1 Moved left         + Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved top         + NOT Repeat while Player 1 Moved right                 player jet : Set direction target to 20         * Repeat while Player 1 Moved right         + Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved top         + NOT Repeat while Player 1 Moved left                 player jet : Set direction target to 28         * Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved top         + NOT Repeat while Player 1 Moved left         + NOT Repeat while Player 1 Moved right                 player jet : Set direction target to 24         // SHOOT         * Player 1 Pressed fire 1         + Number of player bullet < 3                 New Objects : Create player bullet at (-5,-2) from player jet (action point)                 player bullet : Set direction to Dir( "player jet" )                 player bullet : Set speed to 40                 player bullet : Bring to back         * Always                 player bullet : Add 1 to Alterable Value A         * Alterable Value A of player bullet >= 40                 player bullet : Destroy         * player bullet leaves the play area                 player bullet : Destroy         // hits         * Collision between player bullet and biplane                 biplane : Destroy                 player bullet : Destroy```
• 24th November 2021, 06:51 AM
daryuss
MuddyMole, danjo and the others who responded. Many thanks. Also you are right, leaving the keys the rotation of the spacecraft stops, the tutorial you have done is perfect (I did not have time to check it well). I'm not as good as you are, so the best I can do is reciprocate by sharing this little game that I planned a few years ago, and I hope you like it:
• 24th November 2021, 06:57 AM
daryuss
Quote:

Originally Posted by danjo
My code for time pilot flying:
Code:

```[ fly jet ]         * direction target of player jet >= 32                 player jet : Set direction target to 0         * facing direction of player jet >= 32                 player jet : Set facing direction to 0         // select a direction to face jet         * Always                 player jet : Set direction to facing direction( "player jet" )         // determine which way to rotate depending on target direction         // facing 0         * facing direction of player jet = 0         + direction target of player jet >= 4         + direction target of player jet <= 16         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 0         + direction target of player jet >= 20         + player jet: do turn is on                 player jet : Set facing direction to 28                 player jet : Set do turn off         // facing 4         * facing direction of player jet = 4         + direction target of player jet >= 8         + direction target of player jet <= 20         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 4         + direction target of player jet >= 24         + player jet: do turn is on                 player jet : Set facing direction to 0                 player jet : Set do turn off         // facing 8         * facing direction of player jet = 8         + direction target of player jet >= 12         + direction target of player jet <= 24         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 8         + direction target of player jet >= 28         + player jet: do turn is on           OR         * facing direction of player jet = 8         + direction target of player jet < 8         + player jet: do turn is on                 player jet : Set facing direction to 4                 player jet : Set do turn off         // facing 12         * facing direction of player jet = 12         + direction target of player jet >= 16         + direction target of player jet <= 28         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 12         + direction target of player jet < 12         + player jet: do turn is on                 player jet : Set facing direction to 8                 player jet : Set do turn off         // facing 16         * facing direction of player jet = 16         + direction target of player jet >= 20         + direction target of player jet <= 32         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 16         + direction target of player jet < 16         + player jet: do turn is on                 player jet : Set facing direction to 12                 player jet : Set do turn off         // facing 20         * facing direction of player jet = 20         + direction target of player jet >= 24         + player jet: do turn is on           OR         * facing direction of player jet = 20         + direction target of player jet <= 4         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 20         + direction target of player jet < 20         + player jet: do turn is on                 player jet : Set facing direction to 16                 player jet : Set do turn off         // facing 24         * facing direction of player jet = 24         + direction target of player jet >= 28         + player jet: do turn is on           OR         * facing direction of player jet = 24         + direction target of player jet <= 8         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 24         + direction target of player jet < 24         + player jet: do turn is on                 player jet : Set facing direction to 20                 player jet : Set do turn off         // facing 28         * facing direction of player jet = 28         + direction target of player jet <= 12         + player jet: do turn is on                 player jet : Add 4 to facing direction                 player jet : Set do turn off         * facing direction of player jet = 28         + direction target of player jet >= 16         + direction target of player jet < 28         + player jet: do turn is on                 player jet : Set facing direction to 24                 player jet : Set do turn off         // reset flag         * Always                 player jet : Set do turn off         // fly         * Repeat while Player 1 Moved top         + NOT Repeat while Player 1 Moved left         + NOT Repeat while Player 1 Moved right         + NOT Repeat while Player 1 Moved down                 player jet : Set direction target to 8         * Repeat while Player 1 Moved top         + Repeat while "Left Arrow" is pressed         + NOT Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved right                 player jet : Set direction target to 12         * Repeat while Player 1 Moved top         + Repeat while Player 1 Moved right         + NOT Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved left                 player jet : Set direction target to 4         * Repeat while Player 1 Moved right         + NOT Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved left         + NOT Repeat while Player 1 Moved top                 player jet : Set direction target to 0         * Repeat while Player 1 Moved left         + NOT Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved top         + NOT Repeat while Player 1 Moved right                 player jet : Set direction target to 16         * Repeat while Player 1 Moved left         + Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved top         + NOT Repeat while Player 1 Moved right                 player jet : Set direction target to 20         * Repeat while Player 1 Moved right         + Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved top         + NOT Repeat while Player 1 Moved left                 player jet : Set direction target to 28         * Repeat while Player 1 Moved down         + NOT Repeat while Player 1 Moved top         + NOT Repeat while Player 1 Moved left         + NOT Repeat while Player 1 Moved right                 player jet : Set direction target to 24         // SHOOT         * Player 1 Pressed fire 1         + Number of player bullet < 3                 New Objects : Create player bullet at (-5,-2) from player jet (action point)                 player bullet : Set direction to Dir( "player jet" )                 player bullet : Set speed to 40                 player bullet : Bring to back         * Always                 player bullet : Add 1 to Alterable Value A         * Alterable Value A of player bullet >= 40                 player bullet : Destroy         * player bullet leaves the play area                 player bullet : Destroy         // hits         * Collision between player bullet and biplane                 biplane : Destroy                 player bullet : Destroy```

Nice this code that makes it look like we are programming the example in C plus! :D (I'll try from scratch based on this!)
• 27th November 2021, 05:57 AM
danjo
that code is what happens when you copy from fusion; and paste to notepad++ ; this is taken directly from my time pilot version ( same as what you call space pilot )
• 30th November 2021, 08:35 AM
daryuss
Quote:

Originally Posted by danjo
that code is what happens when you copy from fusion; and paste to notepad++ ; this is taken directly from my time pilot version ( same as what you call space pilot )

Great!
Howevwer I took the space pilot game as an example because it has the best movement to create games of the genre, and it can also be used for top view driving games (for example you could create a version of The Last V8 arcade, that C = 64 and other clones were too frustrating!).
But how do you export the event code from ClickTeam fusion to the text file? (Never stop learning :) !).
• 30th November 2021, 09:47 AM
c4t
Quote:

Originally Posted by daryuss
how do you export the event code from ClickTeam fusion to the text file? (Never stop learning :) !).

Choose Edit Select all when in the event editor and then copy. Then paste it into a text file.
• 30th November 2021, 12:11 PM