The following method will spawn a bullet that will be harmful for any plane that crosses its path.
SpawnShot
to the game
class. The parameter will be a plane
object.Method SpawnShot:Int (plane:ftObject)
If (plane = enemy And canShoot = True) Or plane=player Then
40
pixels in front of the plane. That is the starting point for the bullet.Local vec:Float[] = plane.GetVector(40,0,True)
Local s:ftObject = eng.CreateImage(atlas,128,64,12,16, vec[0],vec[1])
s.SetAngle(plane.GetAngle())
15
and ensure that it will wrap around the screen edges.s.SetSpeed(15) s.SetWrapScreen(True)
grpShot
.s.SetColGroup(grpShot)
s.SetColWith(grpPlayer, True) s.SetColWith(grpEnemy, True)
6
pixels. By default, circle-to-circle collision detection is used.s.SetRadius(6)
2000
milliseconds. Create an object timer with a timer ID of tmDelete
, which will fire in 2000
milliseconds.eng.CreateObjTimer(s,tmDelete,2000)
plane
is equal to enemy
.If plane = enemy Then
canShoot
to False
and create an object timer with the ID tmCanShoot
and a time of 300
milliseconds.canShoot = False eng.CreateObjTimer(plane,tmCanShoot,300) Endif
Inside the engine
class, we will detail the corresponding callback method and set the canShoot
field back to True
.
sndShoot.Play()
Endif Return 0 End
18.225.235.144