SpawnPlayerShot
.Method SpawnPlayerShot:Int()
20
pixels in front of the ship. For this, we can use the GetVector
method. It needs the distances and the angle from it, which will be the same as the ship's angle.Local ds:Float[] = player.GetVector(20, player.angle)
Local sht:ftObject = eng.CreateImage(atlas, 0,96,16,16, ds[0],ds[1])
sht.SetAngle(player.angle)
25
and the actual speed to the player speed + 10
.sht.SetMaxSpeed(25.0) sht.SetSpeed(player.speed+10.0)
sht.SetScale(0.5) sht.SetWrapScreen(True)
layerGame
.sht.SetLayer(layerGame)
tmObjRemove
to remove the shot after 2500
milliseconds.eng.CreateObjTimer(sht, tmObjRemove, 2500)
sht.SetColGroup(grpShot) sht.SetColWith(grpComet, True) sht.SetRadius(2)
sndShot
sound and close the method.sndShot.Play() Return 0 End
Besides spawning the shot from the player ship and letting it travel in the direction your ship was heading to, this method will also play the corresponding sound effect for the shot.