コード例 #1
0
def Move(angle,cellX,cellY):
    UpdateBackground()
    
    
    """Load the Bot Image"""
    botImg= pygame.image.load("Images/Grid BOt.png")
    # screen.blit(botImg,(15,15))
    rotator.blitRotate(screen,botImg,(cellX,cellY),angle)
コード例 #2
0
""" Set The Title of Screen"""

pygame.display.set_caption("Display Text")

""" Load the Image"""
screenImg = pygame.image.load("Images/MicroMouse Grid.jpg")

""" Display Image at Specific Co-Ordinate"""

screen.blit(screenImg,(0,0))


"""Load the Bot Image"""
botImg= pygame.image.load("Images/Grid BOt.png")
# screen.blit(botImg,(15,15))
rotator.blitRotate(screen,botImg,(15,15),180)

path=[]

pathInput = ""

stepNum=1

currentAngle=180
currentDirection=4
state=""
steps=0
cellX=15
cellY=15

def decideAngle(turn,currentAngle):
コード例 #3
0
pygame.display.set_caption("Rotate Image")
""" Load the Image"""
screenImg = pygame.image.load("Images/Background.png")
""" Display Image at Specific Co-Ordinate"""

screen.blit(screenImg, (0, 0))
"""Load the Image to be Rotated"""
Image = pygame.image.load("Images/Stepper Motor Symbol.png")

EventStatus = "None"
angle = 0

while True:

    pygame.display.update()

    rotator.blitRotate(screen, Image, (200, 100), angle)

    angle = angle - 20
    time.sleep(1)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            EventStatus = "Quit"
            break

    if EventStatus == "Quit":
        break

print("Closing")
コード例 #4
0
print("Steps: " + str(steps))

done = False
count = 0
while not done:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                done = True

    pos = (screen.get_width() // 2, screen.get_height() // 2)
    pos = (200, 200)

    if count < steps:
        # screen.fill(0)
        rotator.blitRotate(screen, image, pos, (w // 2, h // 2), angle)
        angle -= stepAngle
        count += 1
        pygame.display.flip()
        pygame.display.update()
        time.sleep(1)

    # pygame.draw.line(screen, (0, 255, 0), (pos[0]-20, pos[1]), (pos[0]+20, pos[1]), 3)
    # pygame.draw.line(screen, (0, 255, 0), (pos[0], pos[1]-20), (pos[0], pos[1]+20), 3)
    # pygame.draw.circle(screen, (0, 255, 0), pos, 7, 0)

pygame.quit()
コード例 #5
0
# Check whether stepsCount has reached the number of steps calculated
    if count < steps:  # If not reached then Rotate the wheel by 1 step angle

        #To Display Text: StepCount

        font = pygame.font.SysFont('Times New Roman', 35)

        text = font.render(str(count + 1), False, (255, 255, 255),
                           (85, 49, 133))

        screen.blit(text, (1070, 495))
        time.sleep(0.3)

        #To Rotate Wheel
        rotator.blitRotate(screen, image, (200, 200), angle)

        #Update StepAngle , StepCount and Distance Travelled
        angle -= stepAngle
        count += 1

        distanceTravelled = distanceTravelled + round(distIn1Step, 3)

        distanceTravelled = round(distanceTravelled, 3)

        #To Show Text: Distance Travelled
        font = pygame.font.SysFont('Times New Roman', 35)
        text = font.render(str(distanceTravelled), False, (255, 255, 255),
                           (85, 49, 133))

        # # To Clear the previous distance travelled value
コード例 #6
0
        if data1 == 0:

            while data2 == 1:
                print("In While")
                data2 = phy.dRead(2)
            screenImg = pygame.image.load("Images/background.jpg")
            screen.blit(screenImg, (0, 0))

            img = pygame.image.load("Images/arrow.png")

            newimg = pygame.transform.scale(newimg, (400, 400))

            for i in range(10, 360, 10):
                # print("in For")
                pygame.display.update()
                rotator.blitRotate(screen, newimg, (280, 300), -i)
                print("in For")
                s(0.1)

        elif data2 == 0:
            while data1 == 1:
                data1 = phy.dRead(1)
            screenImg = pygame.image.load("Images/background.jpg")
            screen.blit(screenImg, (0, 0))

            img = pygame.image.load("Images/arrow.png")

            newimg = pygame.transform.scale(img, (400, 400))

            for i in range(10, 360, 10):
                pygame.display.update()
コード例 #7
0
menu = pygame.image.load('MENU.png')
wheel1 = pygame.image.load('WHEEL.png')
wheel2 = pygame.image.load('WHEEL.png')
grid = pygame.image.load('grid.png')
bot = pygame.image.load('bot.png')
angle = 0
win = pygame.display.set_mode((1000, 700))

pygame.display.set_caption('Step Simulator')
pygame.display.update()
run = True
while run:
    win.blit(menu, (0, 0))
    win.blit(grid, (700, 0))
    #win.blit(bot, (700, 0))
    rotator.blitRotate(win, bot, (700, 2), 180)
    font = pygame.font.SysFont('SHOWCARD GOTHIC', 45)
    sa1 = font.render(str(b), True, (0, 0, 0))
    win.blit(sa1, (550, 200))
    sa2 = font.render(str(y), True, (0, 0, 0))
    win.blit(sa2, (550, 465))
    sn1 = font.render(str(int(step_num)), True, (0, 0, 0))
    win.blit(sn1, (580, 270))
    sn2 = font.render(str(int(step_num2)), True, (0, 0, 0))
    win.blit(sn2, (580, 535))
    wd1 = font.render(str(int(c)), True, (0, 0, 0))
    win.blit(wd1, (670, 310))
    wd2 = font.render(str(int(z)), True, (0, 0, 0))
    win.blit(wd2, (675, 580))

    if step_num >= 0:
コード例 #8
0
# Rotating Image Load

roimg=pg.image.load("Images/Circle Rotator Image.jpg")


#Text Print

font=pg.font.SysFont("Ariel", 40, 4)
text=font.render("The Number of Steps are- " + str(totste), True, (255,255,255))

screen.blit(text,(0,700))

while True:
    pg.display.update()
    
    while ste<=totste:
        rotator.blitRotate(screen, roimg, (100,100), angle)
    
        angle=angle+stan
    
        s(1)
        
        ste=ste+1
    
    for event in pg.event.get():
        if event.type==pg.QUIT:
            pg.quit()
            evesta="quit"
            break
    if evesta=="quit":
        break
# Check whether stepsCount has reached the number of steps calculated
    if count < steps:  # If not reached then Rotate the wheel by 1 step angle

        #To Display Text: StepCount

        font = pygame.font.SysFont('Bauhaus 93', 35)

        text = font.render(str(count + 1), False, (255, 255, 255),
                           (85, 49, 133))

        screen.blit(text, (160, 530))
        time.sleep(0.3)

        #To Rotate Wheel
        rotator.blitRotate(screen, image, (27, 18), angle)

        rotator.blitRotate(screen, image2, (366, 377), angle)

        #Update StepAngle , StepCount and Distance Travelled
        angle -= stepAngle
        count += 1

        distanceTravelled = distanceTravelled + round(distIn1Step, 3)

        distanceTravelled = round(distanceTravelled, 3)

        #To Show Text: Distance Travelled
        font = pygame.font.SysFont('Bauhaus 93', 35)
        text = font.render(str(distanceTravelled), False, (255, 255, 255),
                           (85, 49, 133))
コード例 #10
0
            done = True

    if count < steps:
        #To display steps
        font1 = pygame.font.SysFont('Times New Roman', 42)
        text5 = font1.render(str(count + 1), False, (255, 255, 255),
                             (153, 0, 255))
        screen.blit(text5, (455, 160))

        text6 = font1.render(str(count + 1), True, (255, 255, 255),
                             (153, 0, 255))
        screen.blit(text6, (455, 406))

        time.sleep(0.3)
        #To rotate wheel
        rotator.blitRotate(screen, image1, (27, 10), angle)
        rotator.blitRotate(screen, image2, (27, 315), angle)

        angle -= stepAngle
        count += 1

        distanceTravelled = distanceTravelled + round(distIn1Step, 3)
        distanceTravelled = round(distanceTravelled, 3)

        # To Show Text: Distance Travelled
        font2 = pygame.font.SysFont('Times New Roman', 40)
        text7 = font2.render(str(distanceTravelled), False, (255, 255, 255),
                             (153, 0, 255))
        screen.blit(text7, (810, 535))

        #To show status
コード例 #11
0
    if EventStatus == "Quit":
        break

    screen.blit(screenImg, (0, 0))

    #To Move Image in y direction till it reaches end and then move in x direction
    if cellY <= 420:
        cellY = cellY + 30

    elif cellX <= 420:
        cellX = cellX + 30
    else:
        state = "done"

    screen.blit(botImg, (cellX, cellY))

    #-------------------------------------------

    #To Move as well as Rotate Image
    if state == "done":
        if cellYRotate <= 420:
            cellYRotate = cellYRotate + 30
            angle = 180

        else:
            cellXRotate = cellXRotate + 30
            angle = 270

        rotator.blitRotate(screen, botImg, (cellXRotate, cellYRotate), angle)