Seite 1 von 1

Beim dauerhaften Drücken auch weitermachen

Verfasst: Freitag 18. Juni 2010, 13:29
von Weltbesiedler

Code: Alles auswählen

import pygame, sys, time, random
pygame.init()
uhr = pygame.time.Clock()

screen = pygame.display.set_mode ([1900, 1000])
screen.fill ([255, 255, 255])

z = 400

colorx = random.randint(1, 255)
colory = random.randint(1, 255)
colorz = random.randint(1, 255)


x = random.randint(1, 100)
y = random.randint(1, 100)

r = random.randint(10, 30)

x2 = random.randint(10, 30)
y2 = random.randint(10, 30)

x3 = random.randint(10, 30)
y3 = random.randint(10, 30)

x4 = random.randint(10, 30)
y4 = random.randint(10, 30)

color  =((colorx, colory, colorz))


pygame.display.flip() 


while True: 
     for event in pygame.event.get(): 
       if event.type == pygame.QUIT:
            sys.exit()
       if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_a:
                 startpos = ((200 + x, 100 + y))
                 endpos = ((200 + y, 150 + x))
                 x = x + 3
                 y = y + 6
                 pygame.draw.line(screen, color, startpos, endpos, 1)
       if event.type == pygame.KEYUP:
            if event.key == pygame.K_a:
                 startpos = ((2 + x,1 + y ))
                 endpos = ((2 + y, 1 + x))
                 y = y + 2
                 x = x + 4
                 pygame.draw.line(screen, color, startpos, endpos, 1)
       if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_l:
                startpos2 = ((2 + x , 3 + y))
                endpos2   = ((z + y , 4 + z))
                z = z + 4
                x = x + 2
                y = y + 3
                pygame.draw.line(screen, color, startpos2, endpos2, 1)
       if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_s:
                r = r + 2
                radius = r
                pos    = ((x, y))
                pygame.draw.circle(screen, color, pos, radius, 1)
       if event.type == pygame.KEYDOWN:
            if event.type == pygame.K_p:
                point1 = ((x2, y2))
                point2 = ((x3, y3))
                point3 = ((x4, y4))
                pygame.draw.polygon(screen, color, point1, point2, point3, 1)
                
       pygame.display.update()
     uhr.tick(10)
Wie mache ich hier, dass wenn ich auf den Buchstaben drauf bleibe, auch noch gezeichnet wird?

Mit freundlichen Grüßen

Weltbesiedler

Re: Beim dauerhaften Drücken auch weitermachen

Verfasst: Freitag 18. Juni 2010, 14:17
von rads
Ok, ich gebe zu, es ist Freitag und Spaß an der Freude haben wir schon lange nicht mehr.

aber wurde die Frage nicht von Jonas freundlicherweise sogar an dich beantwortet?

http://www.python-forum.de/viewtopic.php?f=4&t=23066

Mal davon abgesehen das zweimal hintereinader die gleiche If Bedingung zu schreiben schon
mehr als nur fragwürdig ist.