## Výučba programovania tvorbou počítačových hier
[Miroslav "mirek" Biňas](https://bletvaska.github.io)
/ [**IT Burza 2023**](https://itburza.gvpt.sk/)
## Hráte sa počítačové hry?
![Saboteur](https://assets.nintendo.com/image/upload/c_fill,w_1200/q_auto:best/f_auto/dpr_2.0/ncom/software/switch/70010000012302/6b14a81d7a852afd6b2640a68034290c0971146e14d0b005e6eb69f4ed4aca4a)
## Naprogramovali ste si vlastnú počítačovú hru?
![Flappy Bird](images/flappy.gif)
![Game Analysis](images/analysis.png)
Note:
* https://www.researchgate.net/publication/324066514_Playing_Flappy_Bird_with_Deep_Reinforcement_Learning
[![Arcade Logo](images/logo-arcade.png)](https://arcade.academy/)
[![Pyglet Logo](images/logo-pyglet.png)](https://pyglet.org/)
[https://pyglet.org/](https://pyglet.org/)
### _Easy to use Python library for creating 2D arcade games._
## Inštalácia
```
$ pip install arcade
```
## Robíme okno
```python
import arcade
class Flappy(arcade.Window):
def __init__(self):
super().__init__()
game = Flappy()
arcade.run()
```
## [Štruktúra projektu](resources/flappy-skelet.zip)
```
.
├── assets
│ ├── images
│ │ ├── background.png
│ │ ├── flappy.png
│ │ └── pipe.png
│ └── sounds
│ ├── die.wav
│ ├── hit.wav
│ ├── point.wav
│ └── wing.wav
└── game.py
```
## Upozornenie!
(no best practices provided)
![Game Loop](images/game-loop-simple.png)
Note:
* http://gameprogrammingpatterns.com/images/game-loop-simple.png
## 2D Súradnicový sys.
![2D Coordinate System](images/2d.coordinate.system.png)
![Actor](images/invader.png)
## Kola, Fanta, Sprite!
* `sprite.center_x`, `sprite.center_y`
* `sprite.position`
* `sprite.width`, `sprite.height`
* `sprite.draw()`
## Sprite Handles
![Pygame Handles](images/handles.png)
![Collisions](images/collisions.png)
Note:
* https://treadgaming.blogspot.com/2016/06/video-game-physics-tutorial-part-ii.html
### Pygame Zero vs Arcade
[![Namakany den](images/namakany.den.png)](http://www.namakanyden.sk)
[www.namakanyden.sk](http://www.namakanyden.sk)
## Odkazy
* [projekt 1](resources/flappy-1.py), [projekt 2](resources/flappy-2.py) - projekty z workshopu
* [OOP verzia projektu](resources/flappy.zip)
* [Arcade Homepage](https://arcade.academy/)
* [Pyglet Homepage](https://pyglet.org/)
* [Multimediální knihovna Pyglet](https://mojefedora.cz/multimedialni-knihovna-pyglet/)
* Real Python: [článok 1](https://realpython.com/arcade-python-game-framework/), [článok 2](https://realpython.com/platformer-python-arcade/)
* Assets stolen from Github: [FlapPy-Bird](https://github.com/iJohnMaged/FlapPy-Bird)
* [PyWeek](https://pyweek.org/) - Python Game Programming Challenge
* [Kenney](https://www.kenney.nl/) - voľné asety pre vaše hry
![qr code](https://api.qrserver.com/v1/create-qr-code/?data=https://bit.ly/46MaJ7g&size=300x300)
(**https://bit.ly/46MaJ7g**)