Displays the information that you tilt the device.
//---------------------------------------------------------------------------------------------- // motion test //---------------------------------------------------------------------------------------------- print "versionXBiOSMotion$=";versionXBiOSMotion$() setFunctionKey(0,"end" ,'!') setFunctionKey(1,"pause" ,'p') setFunctionKey(2,"start" ,'s') setFunctionKey(3,"clear" ,'c') setFunctionKey(4,"degree",'d') setFunctionKey(5,"veloc" ,'v') setFunctionKey(6,"rotate",'r') displayFunctionKey(YES,0,6) kBackgroundAlpha(0.9) int mode=MOTION_DEGREE if motionStart(10,mode) then { print localizedString("モーションは使えません","Can't use motion.") end } printMode(mode) float x,y,z int ky,cnt,i while YES if not kbhit() then { i=0 cnt=motionCount() if cnt>0 then locate(0,1):print "cnt=";cnt while cnt>0 x=motionGetRotation(y,z) locate(0,2+i) if mode=MOTION_ROTATION then { if isLocalizeJapan() then { print using "左右=+#.####,上下=+#.####,方位=+#.####";x,y,z } else { print using "pitch=+#.####,roll=+#.####,yaw=+#.####";x,y,z } } else { if mode=MOTION_DEGREE then { if isLocalizeJapan() then { print using "角度:x=+##.####,y=+##.####,z=+##.####";x,y,z } else { print using "degree:x=+##.####,y=+##.####,z=+##.####";x,y,z } } else { if isLocalizeJapan() then { print using "角速度:x=+##.####,y=+##.####,z=+##.####";x,y,z } else { print using "velocity:x=+##.####,y=+##.####,z=+##.####";x,y,z } } } cnt=cnt-1 i=i+1 if kbhit() then break endwhile } else { ky=inkey() switch ky case 'p' motionPause(YES) print "Pause" break case 's' motionPause(NO) print "Start" break case 'c' cls() motionClear() break case 'd' mode=MOTION_DEGREE motionSelectData(mode) cls() motionClear() printMode(mode) break case 'v' mode=MOTION_VELOCITY motionSelectData(mode) cls() motionClear() printMode(mode) break case 'r' mode=MOTION_ROTATION motionSelectData(mode) cls() motionClear() printMode(mode) break default: // 念のため / just in case beep() break endswitch if ky='!' then break } endwhile motionEnd() end //---------------------------------------------------------------------------------------------- func printMode(mode;int) locate(0,2) if mode=MOTION_DEGREE then print localizedString("角度 ","DEGREE ") if mode=MOTION_VELOCITY then print localizedString("角速度 ","VEROCITY") if mode=MOTION_ROTATION then print localizedString("オイラー角","EULER ") endfunc func str localizedString(js;str,es;str) if isLocalizeJapan() then return(js) return (es) endfunc //----------------------------------------------------------------------------------------------
Zip file : XBtests.zip
No comments:
Post a Comment