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

Windows How to create two puffs of smoke behind rotating ship, one on either side for dual thrusters

I

iNCEPTIONAL

Guest
I have a ship in my game that can move and rotate around the screen just like in Asteroids, and I want to be able to create a double smoke trail out the back with one smoke trail coming from each of the rear thrusters, but I can't seem to be able to get the correct position for the smoke to generate when the ship is able to change its angle like it does. If I tell it to create the two smoke objects at say x-45, y-10 and x-45, y+10 that only creates them in the right place if the ship hasn't rotated its angle at all. Can anyone give me some code that allows me to do this properly, so each of the smoke trails will start next to each thruster, regardless of what angle/rotation the ship is at, where it is onscreen, or what speed it's moving?

Note: I actually want to do the same thing for firing dual homing missiles out the front of the ship at some point too, so this will be really useful if I can figure it out.
 
E

Ethanicus

Guest
You should look into lengthdir. Using that and a bit of experimentation, you should be able to reliably get the positions of the thrusters.
 
B

Blackened

Guest
I had a duel laser lengthdir option in my asteroids style game and you can adapt it to work for your needs. This is how I did it:
//Code for duel lasers using lengthdir.
if keyboard_check_pressed(ord('X'))
{
with(instance_create(x+lengthdir_x(20,90+image_angle), y+lengthdir_y(20,90+image_angle), obj_laser1)) //Adjust len and dir to your liking.
{
direction = other.image_angle; //fires in direction of ships angle.
image_angle = other.image_angle; //adjusts laser angle to match ships angle.
speed = 12; //laser speed.
}

with(instance_create(x+lengthdir_x(20,-90+image_angle), y+lengthdir_y(20,-90+image_angle), obj_laser1))
{
direction = other.image_angle;
image_angle = other.image_angle;
speed = 12;
}
}
 
Last edited by a moderator:
Top