This article is currently in the process of being translated into Czech (~26% done).
In this article series, we're building a complete Snake game from scratch. It makes sense to start with the Introduction and then work your way through the articles one by one, to get the full understanding.
If you want to get the complete source code for the game at once, to get started modifying and learning from it right now, consider downloading all our samples!
Úvod - Počítačová hra ve WPF
Stručné shrnutí tohoto článku - budeme postupně, krok za krokem vytvářet klasickou počítačovou hru - Hada - ve frameworku WPF. Výsledek bude vypadat nějak takto:

Tvorba počítačových her je velmi častým důvodem k tomu, že se lidé (a zvláště mladí lidé) chtějí naučit programovat. Obvyklá otázka je - "Jak mám začít, a co k tomu potebuju?" a odpověď "No, potřebuješ nějaký programovací jazyk, C++, C# nebo nějaký jiný populární. No a, když už ho umíš, nic jiého nepotřebuješ. Prostě začni vykreslováním pixelů na obrazovku a postupně dojdeš až k funkční hře."
No, ale většina lidí by pochopitelně ocenila pomocnou ruku s nízkoúrovňovými problémy. Proč ručně vykreslovat každý pixel na obrazovku, když existuje knihovna či framework, který tohle zvládne jednoduše sám - a programátor se tak může soustředit na budování zábavné hry? Takovýchto framewroků existuje celá řada - a WPF je jedním z nich.
A ano, WPF není úplně typická volba pro tvorbu her - určitě se jedná spíše o framework pro tvorbu pracovních aplikací. Nicméně obsahuje spoustu prvků vhodných pro tvorbu her - a také (což je stejně důležité) mechanismů pro kreslení a ovládání oken v systému Windows.
So, if you're looking to create a simple game, WPF might actually be a fine choice. At least it will be a great help for all the most basic aspects, like creating a Window, drawing a simple area for the game etc. If you want to add stuff like advanced 3D graphics and fast moving objects, might need more help from another library/framework, but it will do just fine for a simple game - for instance, a classic Snake game!
SnakeWPF
As a proof of concept, I have decided to create a WPF-based version of the extremely classical Snake game. It will use a regular WPF Window as its game area, as well as regular WPF controls/shapes to create the actual gameplay. The reason why I chose Snake is because it's fairly easy to implement (there's not that much logic to code) and because it can be implemented using simple geometric figures like squares and circles, which can be used very easily with the WPF framework. But also because it's still a really funny game, despite it's simplistic nature!
If you don't know the Snake game, I can only assume that you never owned a Nokia cellphone during the late 90's/early 2000's. The first version of Snake was written and demonstrated many years before that, but it became a major hit when Nokia decided to include their own version of it on all their cellphones.
The gameplay is as simple as it is entertaining: You move a virtual snake in one direction (left, right, up or down) in the hunt for food (sometimes an apple). When your snake hits the apple, it's consumed, your snake grows and a new apple appears on the screen. If you hit the walls or your own snake tail, the game ends and you have to start all over. The more apples you eat, the higher score you get but the more difficult it will get not to hit your own tail.
There are MANY variations to the gameplay - for instance, the speed with which your snake moves will often increase each time you eat an apple, making it harder and harder, but not all Snake implementations will do this. Another variation is the walls - some implementations will allow you to go through the wall and out on the opposite side, while other implementations will have the game end as soon as you hit the wall.
In our SnakeWPF, the walls are hard (the snake dies if it hits them), and the speed will increase exponentially for each apple you eat, up to a certain point.
Summary
Over the next several articles, we'll be implementing a nice version of the classic Snake game using the WPF framework. We'll start with the background in the next article, and in the end, we'll have our first, fully functional WPF-based game.
Please notice that while this IS a WPF tutorial, we will need a bit more C# code than normal, to implement the game logic etc. I will try to explain most of it as we move along, but in case you need a bit more knowledge about C#, don't forget that we have a nice, complete C# tutorial in our network!