Example of OnGyroscope/OnAccelerometrr
Posted: Mon Aug 15, 2022 10:00 am
Hello
Had anyone any working sniper using gyroscope/accelerometer ?
Had anyone any working sniper using gyroscope/accelerometer ?
The Cross-Platform Multimedia Application Layer
https://forums.hollywood-mal.com/
Code: Select all
@DISPLAY {Title = "Gyroscope and Accelerometer Test",Mode = "AutoFullScreen", X = #LEFT, Y = #TOP, Width = 414,
Height = 896, Color = #BLACK}
Accx=1
accy=1
accz=1
gyrox=1
gyroy=1
gyroz=1
Function p_OnAccelerometer(msg)
accx=msg.x*10
accy=msg.y*10
accz=msg.z*10
EndFunction
Function p_OnGyroscope(msg)
gyrox=msg.x*10
gyroy=msg.y*10
gyroz=msg.z*10
EndFunction
InstallEventHandler({OnAccelerometer = p_OnAccelerometer,OnGyroscope = p_OnGyroscope})
Repeat
CheckEvents()
Wait(5)
Cls()
Locate(0,0)
NPrint("Acc X = "..accX)
NPrint("Acc Y = "..accY)
NPrint("Acc X = "..accZ)
NPrint("")
NPrint("Gyro X = "..accx)
NPrint("Gyro Y = "..accy)
NPrint("Gyro Z = "..accz)
SetFillStyle(#FILLCOLOR)
Circle(180,180,40,#YELLOW)
Circle(200+accx,200-accy,20,#GREEN)
SetFillStyle(#FILLNONE)
Circle(200,200,20,#BLACK)
Forever