# Four Difficults Problems (to me)

Hello, I have a problem… I want make a game like Star-Control Time-Warp, because I want make my owns ships… But appears 4 difficults:

1- I need the ship make an aceleration, but when gain a maximun velocity (this is diferent in each ship) the aceleration stops and the ship flies with these maximun velocity, and then, when you don’t press the key, doesn’t do a desaceleration, of course, you can start pressing up again in other direction to gain velocity, without greater de maximun velocity of the ship.

2- I also need when the ship collision ones which others, they “bounce”, in oposite direction with the other ship, but this bounce would depend of two factors, one is the velocity of each ship, that isn’t constant, and the other is the mass of the ship (this is different in each ship), that is constant in the ship.

3- I don’t know how to make some actions because I don’t understand the Time and Timers, I never has been worked with timer controls like this. I want to do some like “wait”, for example: when I press “S”, the ship fires a laser, I know how to do it, but the laser would be 0.1 seconds in the world and then dissapear… I can create an object “Laser” in the position x and y of the ship, do the laser direction be the same of the ship, but I don’t know how to delete the laser then 0.1 seconds.

4- The most difficult problem apparently: I want create a shot fired from a ship, but not from the ship’s origin, from te forward, the shot never touches the ship, I could do the direction of the shot be the same of the ship, and the position be the same of the ship too, and at these last values add some numbers “x” and “y” depending of the ship size, but this values added aren’t constants, because the ship rotate, for example: if the ship is looking the right, I would have to add “x” values of the position like the ship’s longe, and add “y” values like the ship’s width/2, but if te ship is looking up, I would have to add “x” values of the position of the ship like the ship’s width/2, and don’t add “y” values.

There are my problems, if you can help me, practically you created a Star-Control Time Warp (excuse my English, I really speak Spanish)
Thanks: Lizard-13

See example “Course.gdg” ( or Course3D or Course3D2Player ).

Example Course3D2Player has a such collision system.

Use a timer that add for example 0.05 to a variable “Lifetime” of each laser each 0.05 seconds :

```Conditions : Timer "LaserTimer" is > 0.05 seconds Actions : Reset timer and do +0.05 to variable Lifetime of Laser```

Then delete all lasers with the variable greater than a certain value :

```Conditions : Variable Lifetime of Laser is >= 0.1 Actions : Delete laser```

In the object editor, add a point ( see help for more information ) called for example “ShootCreation”. Then instead of creation your shoot at the position of the ship, you create it at the position of the point ( Create YourShoot at position YourShip.PointX(ShootCreation);YourShip.PointY(ShootCreation) if I remember correctly ).
Game Develop will turn the point so as to the latter always match the position you indicated, even if the ship is rotated.

Thanks very much, every that you saw is very util, you has been solved all my problems

If can’t change the name of each object (all calls same), because a ship fires many shots, and then of 2 seconds, the first, and only the first shot should be deleted.

I have it:```Conditions: At the beginning of the scene Actions: Pause timer "UrquanX_Shot_killer"```

``````         [code]Conditions: The key "S" is pressed, The timer "UrquanX_Shot" is > 0.5 seconds
``````

Actions:Create 1 object Ship_UrquanX_Shot, Do Direction of shot = Direction of UrquanX_Ship, Add a force to Ship_UrquanX_Shot Direction of force = Direction of UrquanX_Ship, Reset the timer “UrquanX_Shot”, Unpause timer “UrquanX_Shot_Killer” [/code]

``````          [code]Conditions:The timer "UrquanX_Shot_Killer" is > 2 seconds
``````

Actions: Delete object Ship_UrquanX_Shot, Reset timer “UrquanX_Shot_Killer”, Pause timer “UrquanX_Shot_Killer”[/code]

But, mathematically, the ship can fire 4 shots before one of they disappears, and then of 2 seconds the system delete all the shots, of course all calls same.

The example of Course.gdg is very useful, I solved the problem of the acelerity, and solve some others (because is in the space), I could make the ship continue with the velocity that gain and it not decrease, and I could make the ship turn without change the direction of the force and velocity (if you don’t press up), the problem is that if you turn in the opposite direction of the force and the velocity, and press up, the direction changes automatically, and the velocity continues to increase, the velocity should decreasing, because you make a opposite force, and the increase again where you look. I thought use a fisical formulae, it is a vector sum, C^2=A^2 + B^2 + 2AB.cos alfa, but is very difficult, the angle alfa maybe is the diference of the angle that look the ship from the angle of the force and velocity, but the two vectors… I don’t know who are they (one is the force and the other is the force created for the ship where it is looking, but use the same event, and it is the same vector)

Use a variable as said in my previous message to manage the shoot : The timer is only used to increment a variable, NOT to delete the shoots. It’s the variables which is used to delete the objects. And each objects has its own variable, each object is deleted one by one.

I don’t get what you want to do ?..
There are actions that can add forces using angle which can be used for example.

Yes… I know I didn’t explains correctly… I try explains it to you with 2 codes…

If I have It: ```Conditions: Press Up, Timer "Aceleration" > 0,1, Variable "Ship_Aceleration" < 100 Actions: +1 variable "Ship_Aceleration", Reset timer "Aceleration"```

And: ```Conditions: Always Actions: Add force to Ship with direction = ship's direction and lenght = variable "Ship_Aceleration" (dissipation 0)```

The ship will have an aceleration (+1 pixel every 0,1 second), and a max velocity (100 pixels/seconds), and if you don’t press up the ship never stop (it is good because is in the space), but if you turn, for example to back, and press up, the ship instantly change the direction and continues acelerating (it is bad because if you do a force in other direction, in this case to back, first the ship should do a desaceleration, and THEN of stop start an aceleration where you look, and it is diferent if the new direction and force isn’t the back, if only turn 1, 2 or 3 degrees and press up, the ship never stop, only reduce the velocity a small, and gain the aceleration again.

But if you have it:```Conditions: Press Up, Reset timer "aceleration" Actions: Add a force to ship with direction = ship's direction and lenght 10 (dissipate=1), Reset timer "aceleration"```

With this, the ship will can do a desaceleration if yo turn to other direction, because only add forces to the ship, but the ship willn’t have an aceleration, or yes (I don’t remember), the problem with this is: the ship don’t have a max velocity, if you don’t turn, or turn a small, the force adds, and adds, and adds (I quit the game when the ship go in a velocity incredible, I can’t control it )… I could add it:

```Conditions: The velocity of ship > 100 Actions: Add a force to the ship with direction = ship's direction - 180, and lenght = velocity of the ship - 100 (dissipate=1)```

With this the ship will have a max velocity (I think, I didn’t try it), because I add a opposite force with the extra-velocity of the ship for cancel it, but I can’t do it because in this space can appear planets, that add forces to ships, if a ship go near to a planet gain extra velocity (if uses the gravity correctly, if not crashes with the planet ), and it code couldn’t permise it .

Yes, I see, but the ship’s forces haves a dissipation, if I don’t press any key the ship should not stop. If I change the event and do: ``` Add to ship a force, angle : Ship.Direction()º and length : 200*TimeDelta() pixels (Dissipation : 1) ```