The OnObjectUpdate
method has one parameter, the object that is updated.
1. Check if the object is equal to
g.player
.Method OnObjectUpdate:Int(obj:ftObject) If obj = g.player Then
2. If the up arrow key is pressed, add
1.5
times the enginedelta
field value to the object (player) with theAddSpeed
method. Also, spawn a player engine particle withg.SpawnPlayerEngine
.If KeyDown(KEY_UP) 'Speed up obj.AddSpeed(1.5*delta) g.SpawnPlayerEngine() Endif
3. Check if the left arrow key is pressed. Then set the angle,
15*delta
degrees relative to its current angle withSetAngle
.If KeyDown(KEY_LEFT) 'turn left obj.SetAngle(-15.0 * delta,True) Endif
4. If the right arrow key is pressed, set the angle,
+15*delta
degrees relative to its current angle withSetAngle
.If KeyDown(KEY_RIGHT) 'turn right obj.SetAngle(15.0 * delta,True) Endif
5. Check if the S key was pressed, then spawn a player shot with
g.SpawnPlayerShot
.If KeyHit(KEY_S) 'Shoot your gun...