Here is some code to explain it. It prints the joystick input 0 - 1 and Joystick Output, also 0 - 1
BUT the output has been converted so that initial movements are finer than faster movements the other extreme
SetScreenResolution(1024,768)
SetWindowSize(1024,768,0)
SetVirtualResolution(1024,768)
SetPrintSize(16)
c1 = MakeColor(255,128,128)
global accel as float[20,3]
for i = 0 to 20
// get a value from 0 to 1 (emulating joystick)
accel[i,1] = (i * 5) / 100.0
//Convert to a value from 90 to 180
accel[i,2] = (90 + (accel[i,1] * 90))
//Now convert to a value between 0 and 1
accel[i,3] = 1 - sin(accel[i,2])
next i
do
for i = 0 to 20
print("Joystick = " + str(accel[i,1],3) + chr(9) + " Angle = " + str(accel[i,2],3) + chr(9) + " Acceleration = " + str(accel[i,3],3))
if i > 0
startX# = (i-1) * (GetVirtualWidth() / 20)
startY# = (getVirtualHeight() - 50) - (accel[i-1,3] * 500)
endX# = (i) * (GetVirtualWidth() / 20)
endY# = (getVirtualHeight() - 50) - (accel[i,3] * 500)
DrawLine(startX#, startY#, endX#, endY#, c1, c1)
endif
next i
sync()
loop
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt