isn:pygame03
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| isn:pygame03 [2019/11/14 10:41] – techer.charles_educ-valadon-limoges.fr | isn:pygame03 [2019/11/14 11:17] (Version actuelle) – [Les activités ...] techer.charles_educ-valadon-limoges.fr | ||
|---|---|---|---|
| Ligne 7: | Ligne 7: | ||
| <code python> | <code python> | ||
| - | flip(Surface, | + | pygame.transform.flip(Surface, |
| </ | </ | ||
| La fonction **flip** permet de faire une **symétrie axiale**, **verticale** ou **horizontale** ou les **deux**. | La fonction **flip** permet de faire une **symétrie axiale**, **verticale** ou **horizontale** ou les **deux**. | ||
| Ligne 24: | Ligne 24: | ||
| </ | </ | ||
| + | ==== La fonction rotate ==== | ||
| + | <code python> | ||
| + | pygame.transform.rotate(Surface, | ||
| + | </ | ||
| + | |||
| + | La fonction **rotate** permet de faire faire une rotation à la surface : | ||
| + | * l’angle passé en paramètre est exprimé selon le sens antihoraire, | ||
| + | |||
| + | Lien : https:// | ||
| + | |||
| + | ==== La fonction scale ==== | ||
| + | <code python> | ||
| + | pygame.transform.scale(Surface, | ||
| + | </ | ||
| + | La fonction scale permet de redimensionner une surface. On passe en paramètre la hauteur et la largeur de la surface cible. | ||
| ===== Le programme complet ===== | ===== Le programme complet ===== | ||
| <code python> | <code python> | ||
| Ligne 38: | Ligne 53: | ||
| x_fraise = 50 | x_fraise = 50 | ||
| y_fraise = 50 | y_fraise = 50 | ||
| - | largeur_fraise = 40 | ||
| - | hauteur_fraise = 40 | ||
| - | IMG_FRAISE = pygame.image.load(" | ||
| - | # image Ballon | + | IMG_FRAISE |
| - | x_ballon = 10 | + | # |
| - | y_ballon = 10 | + | |
| - | largeur_ballon = 20 | + | |
| - | hauteur_ballon = 20 | + | |
| - | IMG_BALLON | + | |
| - | ballonSpeed = [1, 0] | + | |
| - | #IMG_BALLON.move(ballonSpeed) | + | |
| - | ballonRect | + | |
| while not ARRET: | while not ARRET: | ||
| pygame.time.delay(100) | pygame.time.delay(100) | ||
| Ligne 58: | Ligne 64: | ||
| sys.exit() | sys.exit() | ||
| elif event.type == pygame.KEYDOWN: | elif event.type == pygame.KEYDOWN: | ||
| + | # symétrie axiale | ||
| if event.key == pygame.K_RIGHT: | if event.key == pygame.K_RIGHT: | ||
| - | | + | |
| + | elif event.key == pygame.K_UP: | ||
| + | IMG_FRAISE = pygame.transform.flip(IMG_FRAISE, | ||
| + | # rotation | ||
| elif event.key == pygame.K_LEFT: | elif event.key == pygame.K_LEFT: | ||
| - | | + | |
| - | + | # redimensionner | |
| - | ECRAN.blit(IMG_FRAISE, | + | elif event.key == pygame.K_DOWN: |
| - | + | | |
| - | ECRAN.blit(IMG_BALLON, | + | |
| - | ballonRect | + | |
| - | if ballonRect.right > LARGEUR: | + | |
| - | | + | |
| - | | + | ECRAN.blit(IMG_FRAISE, |
| + | | ||
| </ | </ | ||
| ==== Les activités ... ==== | ==== Les activités ... ==== | ||
| Ligne 78: | Ligne 85: | ||
| - | https:// | + | https:// |
| < | < | ||
| - | <iframe height=" | + | <iframe height=" |
| </ | </ | ||
isn/pygame03.1573724497.txt.gz · Dernière modification : 2019/11/14 10:41 de techer.charles_educ-valadon-limoges.fr
