Profilo di AlessandroV

Nome AlessandroV
Indirizzo email n/a
Messaggi1
  • Re: Pygame girare linea come lancette orologio
    Forum >> Programmazione Python >> Videogames
    Salve, devi provare a colorare lo schermo dentro il while . Te l'ho segnato con una freccia: (consiglio: aggiorna lo schermo solo una volta e fallo alla fine del loop così il programma sarà più fluido)




    import sys

    import math

    import pygame

    from pygame.locals import *

    pygame.init()

    win = pygame.display.set_mode((500, 500))

    pygame.display.set_caption("First Game")

    x = 50

    FPS = pygame.time.Clock()




    startpo = pygame.math.Vector2(320, 240)

    endpo = pygame.math.Vector2(170, 0)

    angle = 0

    y = 50

    green = (20, 220, 10)

    run = True

    while run:

    win.fill((0,0,0)) #<--- (0,0,0) sta per nero

    pygame.time.delay(100)


    for event in pygame.event.get():

    if event.type == pygame.QUIT:

    run = False

    angle = (angle+5) % 360

    current_endpo = startpo + endpo.rotate(angle)



    pygame.draw.line(win, green, startpo, current_endpo, 2)

    FPS.tick(30)

    pygame.draw.line(win, green, (200, 400), (200, 470))

    pygame.draw.line(win, green, (200, 400), (200, 470))

    pygame.draw.line(win, green, (200, 325), (200, 395))

    pygame.draw.line(win, green, (200, 325), (200, 395))

    pygame.draw.line(win, green, (200, 220), (200, 320))

    pygame.draw.line(win, green, (300, 220), (300, 260))

    pygame.draw.line(win, green, (300, 265), (300, 335))

    pygame.draw.line(win, green, (200, 195), (200, 215))

    pygame.draw.circle(win, green, (200, 170), 17)

    for i in range (1, 500):

    pygame.draw.line(win, green, (400, 400), (400, 400))

    pygame.display.update()







    pygame.quit()

    sys.exit(0)











    pygame.quit()

    sys.exit(0)




    --- Ultima modifica di AlessandroV in data 2020-04-17 11:13:23 ---