game programming patterns - web.cs.hacettepe.edu.trbgenc/courses/bco653/lectures/lect… ·...
TRANSCRIPT
GAME PROGRAMMING PATTERNS
Oğuz Kahreman
• Cleaner
• Easier to understand
• Faster
GAME PROGRAMMING PATTERNS
PROTOTYPEIvan Sutherland’s legendary Sketchpad project in 1963.
the graphical user interface (GUI) was derived from the Sketchpad as well as modern object oriented programming.
The main idea was to have master drawings which one could instantiate into many duplicates
THE PROTOTYPE DESIGN PATTERN
• To make it easier to understand, Let’s work on an example.
Hero
THE PROTOTYPE DESIGN PATTERN
Ghost
Demon Sorceror
Villians
WITHOUT PROTOTYPE
• Class: Monster
Her bir Canavar Çeşidi için Monster altında bir class oluşturalım.
Örnek: Ghost(), Demon(),Sorceror()
• Class: Spawner
Her Bir Canavar Çeşidi için Spawner altında bir class oluşturalım.
Örnek: GhostSpawner(), DemonSpawner(),SorcerorSpawner()
WITHOUT PROTOTYPE
Unless you get paid by the line of code
PROTOTYPE IN GENERAL
PROTOTYPE IN GENERAL
• One neat part about this pattern is that it doesn’t just clone the class of the prototype, it clones its state too.
• This means we could make a spawner for fast ghosts, weak ghosts, or slow ghosts just by creating an appropriate prototype ghost.
PROTOTYPE IN GENERAL
• Her Bir Canavar için ayrı «Spawn» fonksiyonu yazmaktan kurtulduk ancak Her bir Canavar tipi için Clone() işlemini yapmak zorundayız ve tabiki bunun da kendi içinde bazı zorlukları var.
Ne kadar işe yaradığı konusu
• Clone() fonksiyonunun ne kadar kaliteli kullandığına ve oluşan son ürünün okunabilirliğine
• Projenin Prototipleme yöntemine uygunluğu.
• Kullanılan programlama dilinin Prototipleme yöntemine uygunluğu.
CONCLUSION OF THE EXAMPLE?
Dil seçimi ile ilgili örnek:
• «Spawner» parametreleri type kullanılarak yapıldığından C++ gibi dillerde extradan ayar gerektirirken JAVAScript, Pyhton gibi class yapısı daha düzenli olan ve etkileşim kurabildiğimiz dillerde çok daha efektif şekilde yazılabilir.
Prototiplemeye uygunluk ile ilgili örnek:
• Karakter çeşitliliğinin fazla ancak karakterler arası farkların minör olduğu durumlar.
PROTOTYPE LANGUAGE PARADIGM
object-oriented programming
For example, to invoke a virtual method in C++, you look in the instance for the pointer to its vtable, then look up the method there.
EXAMPLE: SELF
No man is an island, but this object is.
EXAMPLE: SELF
• Beat one object into the shape you want. You can just clone the base Object built into the system and then stuff fields and methods into it.
• Prototype design pattern without having to implement clone() ourselves; it’s built into the system
Every Object Supports Prototype Design Pattern.
- But leaves the complexity onto user who gets bored and misses the opportunities that class-based languages offer.
EXAMPLE: JAVASCRIPT
• Self’ten esinlenerek oluşturulan JavaScript günümüzde en çok kullanılan dillerden birisidir.
• Object Yapısı olarak Self’e benzediği için Prototype-Based dillere benziyor.
• Ancak Cloning ile ilgili yapı içermediği için de Class-Based Dil grubuna daha çok benzemektedir.
- Programa sırasında Object yapısı sayesinde protatipleme işlemleri yapılırken, Class-Based bir dilin sunduğu avantajları da içermektedir.
PROTOTYPES FOR DATA MODELLING
Oyunların kapladığı alandaki aşırı büyümenin getirdiği bir ihtiyaç:
• Protatip Kullanımı ve Tekrar kullanılabilir bilginin delegasyonu.
• Aynı Data paketlerini tekrarlamadan kaçınma isteği.
• Güncelleme ve bakımda ki zorluklar.
GOBLINSSSS
ANY QUESTIONS?