Function UpdatePlayer()
FrameTime# = GetFrameTime()
If GetDirectionX() <> 0.0 Or GetDirectionY() <> 0.0
SetSpriteAngle( Player.SpriteNo, Ang# + 180.0 )
OldX# = GetSpriteXByOffset( Player.SpriteNo )
OldY# = GetSpriteYByOffset( Player.SpriteNo )
Speed# = ( 4.0 * Engine.FrameTime# )
XDist# = RayCastX#( OldX#, OldY#, Ang#, Speed#, 2.5 )
YDist# = RayCastY#( OldX#, OldY#, Ang#, Speed#, 2.5 )
NewX# = NewXPosition#( OldX#, Ang#, XDist# )
NewY# = NewYPosition#( OldY#, Ang#, YDist# )
SetSpritePositionByOffset( Player.SpriteNo, NewX#, NewY# )
Player.CurrentFrame# = Player.CurrentFrame# + ( 16.0 * Engine.FrameTime# ) : If Player.CurrentFrame# >= 16.0 Then Player.CurrentFrame# = ( Player.CurrentFrame# - 16.0 )
Else
Player.CurrentFrame# = CurveValue#( Player.CurrentFrame#, 13.0, 2.5 )
EndIf
SetSpriteFrame( Player.SpriteNo, Round( Player.CurrentFrame# ) )
EndFunction
`===============================================================================================
`===============================================================================================
`===============================================================================================
Function RayCastX#( X#, Y#, Ang#, Dist#, Radiius# )
X2# = NewXPosition#( X#, Ang#, Radiius# )
If SpriteRayCast( X#, Y#, X2#, Y# ) Then Dist# = 0.0
EndFunction Dist#
`===============================================================================================
`===============================================================================================
`===============================================================================================
Function RayCastY#( X#, Y#, Ang#, Dist#, Radiius# )
Y2# = NewYPosition#( Y#, Ang#, Radiius# )
If SpriteRayCast( X#, Y#, X#, Y2# ) Then Dist# = 0.0
EndFunction Dist#
2D sliding collision complete. No Physics object required