五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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ù)記錄的評論 (共 條)

分享到微博請遵守國家法律
山阴县| 绍兴市| 东明县| 吉木乃县| 屏边| 如东县| 平舆县| 博兴县| 建湖县| 铁岭县| 威宁| 名山县| 遂溪县| 萍乡市| 临湘市| 江西省| 博兴县| 嵩明县| 白沙| 德惠市| 灵石县| 抚州市| 望都县| 朔州市| 斗六市| 恩施市| 青田县| 墨脱县| 正阳县| 曲沃县| 怀安县| 区。| 高清| 浦北县| 河间市| 金乡县| 阿合奇县| 阿图什市| 安岳县| 大厂| 阳原县|