gravity icon indicating copy to clipboard operation
gravity copied to clipboard

Sharing code examples on how to implement design patterns using Gravity

Open untoldengine opened this issue 3 years ago • 2 comments

Hi @marcobambini

I wrote several code examples that show how to implement several design patterns using Gravity, such as:

  • Singleton Design Pattern
  • Strategy Design Pattern
  • Observer Design Pattern
  • State Design Pattern

I figured that these examples may help someone in the Gravity community, especially game devs/game engine devs. Unfortunately, I don't know anything about compilers and can't really contribute back by fixing bugs. However, I figured that writing code examples may be helpful to the community.

I'm attaching all the Design Patterns I wrote using Gravity. Please, do go over them since I may have made some mistakes. I'm not a Gravity expert yet, so I'm sure I did some mistakes. However, I did test the examples and they all worked. (I basically ported these design patterns from C++ to Gravity)

P.S. If you decide to show them on Gravity Page or any place where you feel they should be shown, I recommend showing the design patterns in the order shown below. They are ordered from easiest to implement to more complex:

  • Singleton Design Pattern
  • Strategy Design Pattern
  • Observer Design Pattern
  • State Design Pattern

DesignPatternsExamples.zip

untoldengine avatar Jun 11 '21 19:06 untoldengine

Hi @untoldengine,

Thank you for your contribution.

I have that the best way to expose your excellent work is by extension ending the official documentation. I'll try to find out the time to update it.

Thank you!

marcobambini avatar Jun 13 '21 15:06 marcobambini

I would recommend creating a repository with these in there :+1: . They look great!

RobLoach avatar Aug 07 '21 19:08 RobLoach