CurveAngle
Result = CurveAngle(DestAngle#, CurAngle#, Speed#)
 
Parameters:

    DestAngle# =The destination angle
    CurAngle# =The current angle
    Speed# =The speed
Returns:

    Result
 

      CurveAngle will return an auto-interpolated angle based on a given speed. This function will gradually move an angle from its current value to a destination value at a given speed. The result will be wrapped to within 360 degrees.




Mini Tutorial:


      Here's a simple example showing one usage of the CurveAngle function.

  
; Set the program to run at 60 frames per second or less
  SetFPS 60
  
; Create two variables Set
  GunX#=100
  GunY#=GetScreenHeight()-100
  
; Start of programs main DO/loop
  Do
   ; clear4 the screen to a dark blue colour
     Cls RGB(0,20,30)
     
     mx=MouseX()
     my=MouseY()
     
   ; calc the angle from the gun to the mouse pointer
     angle#=GetAngle2D(gunx#,guny#,mx,my)
     
     
   ;curve the angle to make it lag a bit behind the mouse.
     Currentangle#=CurveAngle(angle#,currentangle#,20)
     
     
   ; Draw the guns body
     CircleC gunx#,guny#,30,true,RGB(50,80,100)
     
   ; project a point from the guns origin out 100 units
   ; in it's current direction
     x2#=CosNewValue(gunx#,currentangle#,100)
     y2#=SinNewValue(guny#,currentangle#,100)
     
   ; draw from the guns origin point towards the projected point.
     Line gunx#,guny#,x2#,y2#
     
     
     Sync
  Loop
  
  
  




 
Related Info: CurveValue | GetAngle2D | WrapAngle :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com