Inside the OnObjectUpdate
method, we will control the player machine. For this, we will check if the collision markers are set and act accordingly.
Method OnObjectUpdate:Int(obj:ftObject) If obj = g.player Then
If obj.GetTransitionCount() = 0 Then
obj.SetAnimated(False)
If (KeyDown(KEY_UP) Or JoyDown(JOY_UP)) And g.hitWall = False And ((g.hitCrate<>Null And g.hitWall2 = False And g.hitCrate2=Null) Or g.hitCrate=Null) Then
64
pixels in front of the player.Local vec:Float[] = obj.GetVector(64,0,True)
500
milliseconds.obj.CreateTransPos(vec[0],vec[1], 500,False,0)
If g.hitCrate <> Null And g.hitWall2 = False Then
128
pixels in front of the player. That will be the target position for the crate's transition.Local vecC:Float[] = obj.GetVector(128,0,True)
g.hitCrate.CreateTransPos(vecC[0],vecC[1], 500,False,0) Endif Endif
-90
degrees within 500
milliseconds.If (KeyDown(KEY_LEFT) Or JoyDown(JOY_LEFT)) Then obj.CreateTransRot(-90, 500,True,0) Endif
If (KeyDown(KEY_RIGHT) Or JoyDown(JOY_RIGHT)) Then obj.CreateTransRot( 90, 500,True,0) Endif
Else obj.SetAnimated(True) Endif Endif Return 0 End
By detailing the OnObjectUpdate
method, we can control the player's machine now, and when collision detection is implemented, it won't move through the walls and will also be able to push the crates.
18.218.171.212