pong - grafika ship
This commit is contained in:
38
dzien_01/d_04_pong.py
Normal file
38
dzien_01/d_04_pong.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import pgzrun
|
||||
# Start programu
|
||||
WIDTH = 1000
|
||||
HEIGHT = 676
|
||||
TITLE = "PONG - najlepsza gra na świecie ;-)"
|
||||
|
||||
# definicja sprita
|
||||
sprite = Actor("ball.png")
|
||||
ship = Actor("ship.png")
|
||||
sprite.x = WIDTH//2
|
||||
sprite.y = HEIGHT//2
|
||||
|
||||
# Najważniejsze funkcje sterujące
|
||||
def update():
|
||||
if keyboard.d:
|
||||
sprite.x += 5
|
||||
if keyboard.a:
|
||||
sprite.x -= 5
|
||||
if keyboard.w:
|
||||
sprite.y -= 5
|
||||
if keyboard.s:
|
||||
sprite.y += 5
|
||||
|
||||
if sprite.y > HEIGHT:
|
||||
sprite.y = 0
|
||||
elif sprite.y < 0:
|
||||
sprite.y = HEIGHT
|
||||
elif sprite.x < 0:
|
||||
sprite.x = WIDTH
|
||||
elif sprite.x > WIDTH:
|
||||
sprite.x = 0
|
||||
|
||||
|
||||
def draw():
|
||||
screen.blit("tomulus64.jpg", (0,0) )
|
||||
sprite.draw()
|
||||
|
||||
pgzrun.go()
|
||||
BIN
dzien_01/images/ship.png
Normal file
BIN
dzien_01/images/ship.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
Reference in New Issue
Block a user