Pygame用户面板,旋转,边界

时间:2018-11-20 00:52:56

标签: python pygame

首先,我需要一个用户面板。用户将从那里输入3个输入。例如1)你的k是多少? A)[USERİNPUT] 2)您的M是什么? B)[用户输入] 3)您的名字是? C)[用户输入]每当用户应用这些答案时,pygame窗口都会打开。最后一个答案将是我们在右侧系统的下降平台与x方向之间的夹角。其他2个答案将进行arduino串行通信。最后应该有界限。该圆不能绕过障碍物。只需从系统左侧通过即可。我的代码如下。预先感谢您的四个回答:)

import pygame,sys
    pygame.init()


    win=pygame.display.set_mode((1030,650))
    pygame.display.set_caption("Seri Manipulator Kontrolü")

    x = 700
    y = 300
    width = 5
    height = 0
    vel = 5
    oxu= 870
    oyu= 420
    owu= 160
    ohu= 10
    oxd= 870
    oyd= 220
    owd= 160
    ohd= 10
    centeredobx=870
    centeredoby=230
    centeredboy=190
    centereden=10
    cubukx= 880
    cubuky= 320
    cubuken= 140
    cubukboy= 10


    def yazdir():
                    win.fill((0,0,0))
                    pygame.draw.circle(win, (0, 127, 255), (x, y), width, 0)
                    pygame.draw.rect(win, (255, 0, 0), (oxu, oyu, owu, ohu))
                    pygame.draw.rect(win, (255, 0, 0), (oxd, oyd, owd, ohd))
                    pygame.draw.rect(win, (255, 255, 0), (centeredobx, centeredoby, centereden, centeredboy))
                    pygame.draw.rect(win, (128, 128, 128), (cubukx, cubuky, cubuken, cubukboy))
                    pygame.draw.rect(win, (255, 0, 0), (1020, 220, 10, 200))
                    pygame.display.update()



    run = True
    while run:
        pygame.time.delay(100)
        for event in pygame.event.get():
            print(event)
            if event.type == pygame.QUIT:
                run = False
                pygame.quit()


        keys = pygame.key.get_pressed()

    if pygame.key.get_pressed() and x in range(865,1025) and y in range(225,235) or pygame.key.get_pressed() and x in range(865,1025) and y in range(415,425):
        return

    else:
            if keys[pygame.K_RIGHT] and 1010 > x > 860 and 235 <= y <= 415 and centeredobx <= 1005:
                centeredobx += vel
                cubukx += vel
                cubuken -= vel
                yazdir()

            if keys[pygame.K_LEFT] and 1010 > x > 860 and 235 <= y <= 415 and centeredobx >= 875:
                centeredobx -= vel
                cubukx -= vel
                cubuken += vel
                yazdir()


            if keys[pygame.K_LEFT] and x > 5:
                x -= vel
                yazdir()

            if keys[pygame.K_RIGHT] and x < 1005: 
                x += vel
                yazdir()

            if keys[pygame.K_UP] and y > 5 :
                y -= vel
                yazdir()

            if keys[pygame.K_DOWN] and y < 645:
                y += vel
                yazdir()




    pygame.quit()

0 个答案:

没有答案