This shows you the differences between two versions of the page.
ii:lab:laborator3 [2020/11/16 10:57] radu.mantu [Phaser] |
ii:lab:laborator3 [2020/11/25 10:25] (current) florin.stancu [Input de la utilizator] fix code |
||
---|---|---|---|
Line 102: | Line 102: | ||
import pygame | import pygame | ||
+ | from pygame import KEYDOWN | ||
screen = pygame.display.set_mode((800, 600)) | screen = pygame.display.set_mode((800, 600)) | ||
Line 113: | Line 114: | ||
if event.type == KEYDOWN: | if event.type == KEYDOWN: | ||
- | if event.key == K_UP: | + | if event.key == pygame.K_UP: |
print 'sageata sus' | print 'sageata sus' | ||
- | elif event.key == K_DOWN: | + | elif event.key == pygame.K_DOWN: |
print 'sageata jos' | print 'sageata jos' | ||
- | elif event.key == K_LEFT: | + | elif event.key == pygame.K_LEFT: |
print 'sageata stanga' | print 'sageata stanga' | ||
- | elif event.key == K_RIGHT: | + | elif event.key == pygame.K_RIGHT: |
print 'sageata dreapta' | print 'sageata dreapta' | ||
- | elif event.key == K_SPACE: | + | elif event.key == pygame.K_SPACE: |
print 'space' | print 'space' | ||
Line 159: | Line 160: | ||
===== Exerciții ===== | ===== Exerciții ===== | ||
- | Parcurgeti [[http://www.101computing.net/getting-started-with-pygame/|tutorialul]] | + | === Task-uri: === |
Creeați [[https://www.andoverpatio.co.uk/21/space-invaders/|Space Invaders]] plcand de la scheletul de cod de mai jos: | Creeați [[https://www.andoverpatio.co.uk/21/space-invaders/|Space Invaders]] plcand de la scheletul de cod de mai jos: | ||
+ | - **[20p]** Jucator: poate sa se deplaseze stanga(A) / dreapta(D) si sa lanseze proiectile (Space) | ||
+ | - **[20p]** Bunkere destructibile | ||
+ | - **[20p]** Inamici mobili organizati in 5 randuri | ||
+ | - **[20p]** Cel mai apropiat inamic de pe fiecare coloana ataca | ||
+ | - **[20p]** Score si High-Score (salvat intre run-uri) | ||
+ | === Resurse aditionale: === | ||
+ | * Parcurgeti [[http://www.101computing.net/getting-started-with-pygame/|acest tutorial]] pentru informatii aditionale. | ||
+ | * Porniti de la acest schelet de cod: | ||
<spoiler> | <spoiler> | ||
<file python main.py> | <file python main.py> | ||
Line 241: | Line 249: | ||
</file> | </file> | ||
</spoiler> | </spoiler> | ||
- | |||
- | \\ | ||
- | Task-uri: | ||
- | - **[20p]** Jucator: poate sa se deplaseze stanga(A) / dreapta(D) si sa lanseze proiectile (Space) | ||
- | - **[20p]** Bunkere destructibile | ||
- | - **[20p]** Inamici mobili organizati in 5 randuri | ||
- | - **[20p]** Cel mai apropiat inamic de pe fiecare coloana ataca | ||
- | - **[20p]** Score si High-Score (salvat intre run-uri) |