国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

搖桿數(shù)據(jù)記錄

2022-10-27 18:40 作者:weezyr  | 我要投稿


import pygame#加載庫

# 定義顏色

BLACK ? ?= ( ? 0, ? 0, ? 0)

WHITE ? ?= ( 255, 255, 255)


#這是一個簡單的類,將幫助我們打印到屏幕上。它與操縱桿無關(guān),只是輸出信息。

class TextPrint:

? ? def __init__(self):

? ? ? ? self.reset()

? ? ? ? self.font = pygame.font.Font(None, 20)


? ? def print(self, screen, textString):

? ? ? ? textBitmap = self.font.render(textString, True, BLACK)

? ? ? ? screen.blit(textBitmap, [self.x, self.y])

? ? ? ? self.y += self.line_height

? ? ? ?

? ? def reset(self):

? ? ? ? self.x = 10

? ? ? ? self.y = 10

? ? ? ? self.line_height = 15

? ? ? ?

? ? def indent(self):

? ? ? ? self.x += 10

? ? ? ?

? ? def unindent(self):

? ? ? ? self.x -= 10

#設(shè)置屏幕得到寬度和長度 [width,height]

pygame.init()#初始化

size = [300, 300]

screen = pygame.display.set_mode(size)

pygame.display.set_caption("controller_test")

#被用來管理屏幕更新的速度

clock = pygame.time.Clock()

# 初始化joystick

pygame.joystick.init()

# 準備好打印

textPrint = TextPrint()

date = open('controll_joystick_date.txt',"w+")#新建數(shù)據(jù)文本

done = False#循環(huán)

#----程序主體部分--------

while done == False:#無線循環(huán)主體程序

? ?for event in pygame.event.get():#獲取玩家輸入

? ? ? ?if event.type == pygame.QUIT:

? ? ? ? ? done=True

? ? # 繪制的步驟

? ? #首先,用白色清除屏幕。不要放其它的繪圖指令

? ? #在這條上面的指令,將會被擦除

? ?screen.fill(WHITE)

? ?textPrint.reset()

? ?joystick_count = pygame.joystick.get_count()#獲取搖桿數(shù)目

? ?for i in range ( joystick_count ):#

? ? ? ? joystick = pygame.joystick.Joystick(i)

? ? ? ? joystick.init()

? ? ? ? axes = joystick.get_numaxes()#獲取軸數(shù)目

? ? ? ? for i in range ( axes ) :

? ? ? ? ? ? axis_0 = joystick.get_axis( 0 )#左搖桿x軸

? ? ? ? ? ? axis_1 = joystick.get_axis( 1 )#左搖桿y軸

? ? ? ? ? ? axis_2 = joystick.get_axis( 2 )#右搖桿x軸

? ? ? ? ? ? axis_3 = joystick.get_axis( 3 )#右搖桿y軸

? ? ? ? ? ? axis_4 = joystick.get_axis( 4 )#左板機

? ? ? ? ? ? axis_5 = joystick.get_axis( 5 )#右板機

? ? ? ? textPrint.print(screen,"Left_stick_x_axis value: {:>6.4f}".format(axis_0))

? ? ? ? textPrint.print(screen,"Left_stick_y_axis value: {:>6.4f}".format(axis_1))

? ? ? ? textPrint.print(screen,"Right_stick_x_axis value: {:>6.4f}".format(axis_2))

? ? ? ? textPrint.print(screen,"Right_stick_y_axis value: {:>6.4f}".format(axis_3))

? ? ? ? textPrint.print(screen,"Left_trigger value: {:>6.4f}".format(axis_4))

? ? ? ? textPrint.print(screen,"Right_trigger value: {:>6.4f}".format(axis_5))

? ? ? ? textPrint.unindent()

? ? ? ? date.write("{:>6.4f}\n".format(axis_3))#把搖桿數(shù)值寫入文本

? ?pygame.display.flip()

? ?clock.tick(20)

date.close()

pygame.quit ()


搖桿數(shù)據(jù)記錄的評論 (共 條)

分享到微博請遵守國家法律
西青区| 宜阳县| 夹江县| 义马市| 阳高县| 辉县市| 伊吾县| 新安县| 巍山| 绥化市| 年辖:市辖区| 利川市| 高要市| 会昌县| 宿松县| 济南市| 米林县| 蕲春县| 柳州市| 厦门市| 五寨县| 眉山市| 曲麻莱县| 从化市| 化隆| 衢州市| 滦南县| 南平市| 米泉市| 莒南县| 诸城市| 凤阳县| 买车| 卢氏县| 秀山| 康保县| 新竹市| 当涂县| 巴彦淖尔市| 合肥市| 东源县|