Animation von Position und Größe
Abschlussbedingungen
import random
import pgzrun, pygame
WIDTH, HEIGHT = 500, 500
rechteck = Rect((WIDTH/2, HEIGHT/2), (20, 20))
def update():
pass
def draw():
screen.fill("white")
screen.draw.filled_rect(rechteck, "red")
def on_mouse_down():
mausposition = pygame.mouse.get_pos()
animate(rechteck,
center=mausposition,
tween='bounce_end',
duration=1)
def on_key_down():
groesse = (random.randint(10, 100), random.randint(10, 100))
animate(rechteck,
size=groesse,
tween='bounce_end',
duration=1)
pgzrun.go( )
Zuletzt geändert: Donnerstag, 3. April 2025, 14:56