[:tr]Basit Çoklu Oyuncu Motoru – Snake v2.0 – Giriş[:en]Simple Multiplayer Game Engine – Snake v2.0 – Introduction[:]

[:tr]close-up photography of human's hand tattoo

Bu sefer farklı bir yazı ile karşınızdayım. Bu yazı ile birlikte daha önce sizler ile paylaştığım oyun projelerine devam edeceğiz. Daha önce sizler ile paylaştığım örnek oyun projelerinin ikisi de (Tetris v1.0Tetris v2.0, Snake v1.0) tek oyuncu desteği sunmaktaydı ve çoklu oyuncu desteğini de eklemeyi istediğimi söylemiştim. Burada amacım basit bir çoklu oyuncu desteğini (oyuncular, lobi, mesajlaşma, senkronizasyon ve oyun mekanikleri) modern C++ kabiliyetlerini ve kütüphanelerini kullanarak nasıl yapıldığını sizlere göstermekti. Aslına bakarsanız, bir süre önce, bu anlamda da, basit bir ağ alt yapısı geliştirmeye başlamıştım ve bu amaçla da POCO kütüphanelerini kullanmaya başladım (Vcpkg Aracı yazımda da değinmiştim). Aslında, POCO kütüphanelerini daha önce herhangi bir amaç ile kullanmamıştım ama genel değerlendirmeler fena değildi. Hem kütüphaneyi öğrenmek hem de hızlı bir şekilde ağ alt yapısını geliştirmek için bu kütüphaneye yöneldim. Bunu kullanarak da, basit istemci, sunucu arasındaki haberleşmeyi gerçekleştiren sınıfları yazdım. Kullanımı nispeten kolay, dokümantasyonu fena olmayan bir kütüphaneydi. Fakat gel gör ki, bu kütüphaneyi Android için kullanmanın pek kolay olmayacağını fark ettim ve bu ağ alt yapısını QT ile geliştirmeye karar verdim.

QT’yi çok uzun bir süredir, farklı amaçlar için kullanılacak grafiksel kullanıcı arayüzüne sahip C++ uygulamaları geliştirmek için hem işte hem de kişisel projelerimde kullanıyorum. Oldukça kapsamlı, bir çok kabiliyeti içerisinde barındıran, çok güçlü bir topluluk desteği  ve kullanım alanı olan (Wiki’ye göre 1 milyondan fazla kullanıcısı ve 70 den fazla alanda kullanılıyor) bu kütüphaneyi (aslında kütüphaneden çok fazlası, kendi ifadeleri ile “cross-platform application development framework”), bence her C++ yazılımcısının öğrenmesinde fayda var. Eee ben de buna vesile olayım istedim 🙂

Qt seçimi yanında, çoklu oyuncu desteği getirirken başka neleri bu kapsama alabilirim diye düşündün ve artık de facto her yazılımcının bilmesi gereken birim test (unit tests), sürekli entegrasyon (continous integration) kavram ve kabiliyetlerini, bu oyun aracılığı ile C++ dünyasında nasıl uygulanabileceğini sizlerle paylaşmaya karar verdim. Bunun yanında, daha önce de amaçladığımı çoklu platform desteğini de her zaman göz önünde bulunduracağız, geliştirdiğimiz yazılımların özellikle android platformu için de çalışabilir olması benim için önemli.

Anlayacağınız üzere, çarşı biraz karıştı 🙂 Şaka bir yana, yazılım mühendisliği kavramlarını ve bu tarz araç ve teknolojileri (bu durumda QT, sürekli entegrasyon, birim test, vb.), öğrenmenin en iyi yolunun, birebir kullanmak olduğuna inanan bir insanım. Onun için her ne kadar Snake v 2.0’ın çıkışı biraz uzasa da, eğlenceli bir yazı dizisine yelken açtığımıza inanıyorum. Bu kapsamda sizlere aktaracağım konular, tabi buradakilerle muhtemelen sınırlı kalmayacak, aklıma gelen veya hoşuma giden kavram ve hususları da sizler ile paylaşacağım. Elbette, önceki konularımıza ilişkin yazılara (std::any ve SOLID yazıları gelecek 😉 devam edeceğim ama birinci önceliğim bu konu olacak. Bu arada ingilizce çeviriler de biraz aksadı, farkındayım 🙁 fırsat buldukça eksikleri gidereceğim ama öncelikli açıkçası çok fazla değil, tabi bir omuz atabilirim diyen olursa her zaman kapım, e-posta kutum, açık 😀

Peki yazıları ve içerikleri nasıl planladım, bundan sonra nasıl ilerleyeceğiz ve mevcut durum nedir konusuna gelecek olursak. Açıkçası ilk etapta bahsettiğim bu yeni teknoloji ve kavramlara ilişkin kısa ve sizlere yol gösterici ufak yazılar yazmayı planlıyorum. Bu yazıların hepsi bir yandan GitHub’da geliştirmeye devam ettiğim kod ile de paralel devam ediyor olacak. Teknolojilere hızlıca baktıktan sonra veya arada koda ilişkin de bir takım yazılar sizler ile paylaşacağım. Yazımın sonunda bu bağlamda yazmayı planladığım yazıların olası başlıklarını (kuvvetle muhtemel bunlar yolda değişecekler) listeledim, ileride yazıları yazdıkça, bağlantılarını güncelleyeceğim. Elbette, Yazı Dizileri ve Örnek Kodlar sayfası altında da kendilerine ait bir başlıkları olacak. Bu yazıları Basit Çoklu Oyuncu Motoru (BÇOM) – “Simple Multiplayer Game Engine (SMGE)” başlığı altında toplayacağım. Tabi motor dediğime bakmayın, öyle çok kapsamlı bir şey olmayacak ama yine de sizlere fikir vereceğini umuyorum 🙂

Aslında bakarsanız çoklu oyuncu için temel teşkil edecek istemci/sunucu alt yapısı için bir takım kodları geliştirdim. Bunlara, aşağıdaki SimpleMultiplayerGameEngine git repository’sinden ulaşabilirsiniz, hemen bir göz atın derim 😉

https://github.com/yazilimperver/SimpleMultiplayerGameEngine 

Dediğim gibi bunlar, birim test ve sürekli entegrasyon kavramlarını, basitçe gösterebilecek seviyede. Bunun ile birlikte, çalışır ve kullanılabilir durumda ve daha da önemlisi sizlere ağ programlama ve  QT’nin kabiliyetleri hakkında da fikir verecek seviyede. QT ve soket programlamaya ilişkin ayrı bir yazım da olacak inşallah.

Şimdi gelelim bu çoklu oyuncu desteği olayına. Açıkçası ilk etapta basitçe bir kütüphane aracılığı ile bunu geliştirip, daha önce sizler ile paylaştığım yılan oyununa eklemeyi planlıyordum. Şimdiki plan, öncelikle en altta haberleşmeden sorumlu bir alt yapı, üstüne bunu kullanıp, basit çoklu oyuncu kabiliyetlerini gerçekleyen üst bir yapı ve son olarak da, bunları kullanan uygulamalar geliştirmek olacak. Bu uygulamalar: konsol tabanlı ve grafiksel kullanıcı arayüzüne sahip QT tabanlı oyuncu uygulamaları, yine QT tabanlı soket haberleşmelerini ve çoklu oyuncu kabiliyetlerini test ve takip etmek için uygulamalar olacak.

BÇOM Yazıları:

  • Qt nedir?
  • SMGE haberleşme altyapısı ve Qt ile soket programlama
  • SMGE çoklu oyuncu kabiliyetleri
  • Sürekli entegrasyon
  • CMake betiklerinin oluşturulması
  • Birim testler
  • SMGE oyuncu istemcileri

[:en]close-up photography of human's hand tattoo

I back with a different post. We will continue to work on the game development projects that we had started. The two game projects that I shared with you (Tetris v1.0Tetris v2.0, Snake v1.0provide single player support and I was planning to continue with a simple multiplayer support for those games. It is time! I intend to show you how we can implement simple multiplayer game features such as player/lobby management, messaging, simple synchronization and associated game mechanics using modern C++. In fact, I had already started to implement those using POCO library (check out Vcpkg Tool). To be honest, I had not used POCO library before but reviews and feedbacks were not bad. So, I started to use this library and implement simple protocol for client and server. However, then I realized that it will not be that easy to use this library for android platform, so I decided to go with QT.

I have been using QT for a long time to develop C++ GUI based applications on different platforms. It is very broad and capable library, its community is huge and has widespread usage. It is a cross-platform application development framework for desktop, mobile and embedded systems. If you are a C++ developer, I strongly suggest you to learn this library. Hopefully, with this post, I conduce you to learn this library :).

In addition to QT choice, I started to think about other possible topics that I can conver during developing this. Then, I decided to also include topics that every developer, IMHO of course, should know such as unit testing, continous integration and their application for C++ projects. Of course, we will still continue to develop this capability in cross-platform nature, especially, it should support android platform. I strongly believe that the best way to learn such concepts and technologies is to get your hands dirty and apply them in real project. Although, this may delay the Snake v2.0, it will be an education, and hopefully, entertaining journey. Of course, the scope will not be limited to ones that I just mentioned, I will try to enrich it as much as possible during the course. Meanwhile, I will continue to write about the topics that I already started (i.e. std::any and SOLID), but the priority will be this series.

So how did I plan the content of posts, how will we proceed from now on and what is the current situation? Frankly, I am planning to write short and guiding little articles about these new technologies and concepts that I mentioned in the first place. Meawhile, all of these articles will be reflected in code that I still develop and put on GitHub. After a quick look at the technologies, I will share with you also number of articles specifically about the code. At the end of my article, I have listed the possible titles of the articles I plan to write in this series (these are likely to change on the way), and as I write articles in the future, I will update their links. Of course, they will also have a title of their own under the Series and Example Codes page. I will collect all these articles under the title “Simple Multiplayer Game Engine (SMGE)“. Although, I called it engine, it will not be a very comprehensive or complete library, but it will give you glimpse of such engines 🙂

In fact, I have developed a set of codes for the client / server infrastructure that will serve as the basis for the multiplayer infrastructure. You can access them from the following SimpleMultiplayerGameEngine git repository, take a quick look;)

https://github.com/yazilimperver/SimpleMultiplayerGameEngine 

As I said, they are simple enough to show the concepts of unit testing and continuous integration. Additionally, it is operational and usable and, more importantly, gives you insight into the capabilities of network programming and QT. By the way, there will be a separate post about QT and socket programming.

Now let’s have a look at multiplayer support scope. Previously, I was simply planning to develop it as a library and add it to the snake game that I shared with you before. The current plan is, first of all, to develop a communication infrastructure at the bottom layer, then another layer that uses simple multiplayer capabilities will be developed, and finally applications that use these capabilites will be developed. The applications will be: QT-based GUI and console based client applications, there will also be applications to test and monitor socket communications and multiplayer capabilites.

SMGE Articles:

  • What is Qt?
  • SMGE communication infrastructure and socket programming in QT
  • SMGE capabilities
  • Continuous Integration
  • Unit tests
  • CMake scripts
  • SMGE game clients

[:]