## Tvorba počítačových hier v jazyku Python
[mirek](https://bletvaska.github.io)
/ [**41. Bratislavský Python Meetup**](https://www.meetup.com/pyconsk/events/274709044/)
## Hráte sa počítačové hry?
![Uncharted: Drake's Fortune](images/uncharted.jpg)
## Naprogramovali ste si vlastnú počítačovú hru?
![Arkanoid Logo](images/arkanoid.logo.jpg)
Note:
* https://i.ytimg.com/vi/2bdFsD_0HXI/maxresdefault.jpg
[![Kenney.nl](images/kenney-promo.png)](https://kenney.nl/)
[![Pygame logo](images/logo-pygame.png)](https://www.pygame.org/news)
[![SDL logo](images/logo-sdl.png)](https://www.libsdl.org/)
Since 1998
![Steam logo](images/logo-steam.jpg)
### Pygame Zero is for creating games without boilerplate.
Note:
* https://www.raspberrypi.org/magpi/wp-content/uploads/2015/06/35_PygameZero.jpg
## Installation
* Raspberry Pi - builtin
* `sudo dnf install pgzero mu`
* `pip install pgzero mu-editor`
## Installation Workaround
...because of last version 1.2 is from 2018
```bash
pip install pygame==2.0.0
pip install pgzero --no-deps
```
## Warning!
(no best practices provided)
![Game Loop](images/game-loop-simple.png)
Note:
* http://gameprogrammingpatterns.com/images/game-loop-simple.png
## [Project Structure](resources/project.zip)
```
.
├── game.py
├── sounds/
│ ├── hit.01.wav
│ └── hit.02.wav
└── images/
├── background.png
├── ball.png
├── brick.purple.png
├── brick.red.png
└── paddle.png
```
## 2D Coordinate System
![2D Coordinate System](images/2d.coordinate.system.png)
![Actor](images/ball.png)
## Actor Fields and Methods
* `actor.x`, `actor.y`, `actor.pos`
* `actor.image`
* `actor.width`, `actor.height`
* `actor.draw()`
## Pygame Handles
![Pygame Handles](images/pygame.handles.png)
![Collisions](images/collisions.png)
Note:
* https://treadgaming.blogspot.com/2016/06/video-game-physics-tutorial-part-ii.html
## Used Resources
* [javascript-arkanoid](https://github.com/aruvham/javascript-arkanoid) - rendition of the classic NES game Arkanoid using [p5.js](https://p5js.org/)
* Kenney: [Puzzle Pack](https://www.kenney.nl/assets/puzzle-pack) - original assets from Kenney
* [výsledný projekt](resources/game.py)
* [ukážkový projekt](resources/arkanoid.py)
## Links I.
* [Pygame Zero homepage](https://pygame-zero.readthedocs.io/) ([sk](https://pgzero-slovak.readthedocs.io/sk/latest/index.html))
* [Tvorba počítačových hier s Pygame Zero](https://bletvaska.gitbooks.io/tvorba-pocitacovych-hier-s-pygame-zero/content/) - poznámky ku tvorivej dielni
* [PyWeek](https://pyweek.org/) - Python Game Programming Challenge
* [Pygame Zero: snadno použitelný nástroj určený pro výuku programování](https://www.root.cz/clanky/pygame-zero-snadno-pouzitelny-nastroj-urceny-pro-vyuku-programovani/) - časť seriálu [Jazyky pro výuku programování](https://www.root.cz/serialy/jazyky-pro-vyuku-programovani/) na portáli [root.cz](https://www.root.cz)
## Links II.
* [Wireframe](https://wireframe.raspberrypi.org/) and [MagPi](https://www.raspberrypi.org/magpi/) Magazines
* [Code the Classics – Volume 1](https://wireframe.raspberrypi.org/books/code-the-classics1)
* [Mission Python](https://nostarch.com/missionpython) ([YouTube Video](https://www.youtube.com/watch?time_continue=2&v=_2aglIeW1kQ))
![qr code](https://api.qrserver.com/v1/create-qr-code/?data=https://bit.ly/3maUDNx&size=300x300)
(**https://bit.ly/3maUDNx**)