Skip to main content

How can I become a good coder when i am using c++ or swift for my gaming or interactive projects

i will talk about coding standard which i follows in c++ or swift (ios)
for c++
  1. define a class name like thats - public myGame extends baseClass checkout class name in camel case
  2. use abstract classes whenever you go for inheritance that would help you and other coders that there are some method already declare in base class and he don’t need to be redeclared it and also your base class can access child class method through pointer .
  3. overriding in bad habit when its comes to deal with a big project instead of overriding create method with optional parameter which would help you to reduce code in your project.
  4. generic templates are best way to deal with common things like defining a template which combine string as well as float and int based on parameter type.
  5. including header file in .cpp is bad habbit try to include all header file in .hpp
  6. resuse classes are good but too much reusability is another bad habbit for example
button->mybutton->mymybutton->anotherbutton
instead of above you can do it like
button->mybutton
button->mymybutton
button->anotherButton
7. enum is best when dealing with multiple case for example
enum myDirection
{
left,
right,
up,
down.
}
if(key==myDirection.left)
{
“move left buddy”
}
8. try to use data structure when you need to add remove updated records specially linked list , doubly linked list or circular linked list.
9. inline function are fast but you need to be carefull function which is under 9 line are good for inline function.
10. use singleton where you need same operation to held in every part of application for example a http api call or getting windows height and width based on resolution or a global sound player which playing sound in every part of your application based on different action.
11. use static classes with you deal with operation which does not required a instance of class for example math.abs()
12.try to follow some standard pattern such as mvc or mvvm these pattern help you to separate your code for example mvc where Model deals with data realted stuff V realted to views and controller deals like a bridge between them. if you belongs to gaming ECS entity component system is widely used pattern for games.
13. put configuration related data in json so you don’t need to change code again and again for minor text changes.
14. dependency injection What is dependency injection? must check it once.
15 use const instead while dealing with const values in project.
16. don’t create big function that instead of it create small function with return type
17. comment your code whenever possible it would help other to understand your code and even you too sometime.
18.check out lambda
19.check out multithreading
20. spend time with data structure and searching algorithms.

Comments

Popular posts from this blog

Better Memory management with PixiJS or How to manage cpu and cpu memory in PixiJS.

PixiJS is my favorite framework when i am looking for a web games specially for mobile or desktop  PixiJS is fast blazing fast and you can get a decent FPS even on older device.   so here is my optimization techniques for PixiJs 1. manage your sprites in a better way use spritesheet to reduce the draw calls create big sprite sheet which contain multiple sprites can be draw in gpu with a single draw call. use TexturePacker  https://www.codeandweb.com/texturepacker  best tool when its comes to spritesheet 2. for floating point calculation round off calculation for example let  speed = 0.75 ; let  position = 100 ; console . log ( Math . round ( speed * position )) 3. don't create very big canvas when u need a big canvas size game just try to create a small canvas and translate it. 4. its very important one managing TextureCache in memory you can get all TextureCache list by using  Object.entries(PIXI.utils.TextureCache); so even you use ap...

adding particles Effect in pixijs using https://pixijs.io/pixi-particles-editor/

adding particle in pixijs is very easy using the below tool more information can be found below https://github.com/pixijs/pixi-particles https://pixijs.io/pixi-particles-editor/ required packages  /// < reference path = "node_modules/pixi-particles/ambient.d.ts" /> import 'pixi-particles' code of particle delcare a     global variable   private emitter ?: Emitter ; const img = PIXI . Texture . from ( "./assets/images/particle.png" ); this . emitter = new Emitter ( this ,[ img ],{ "alpha" : { "start" : 0.62 , "end" : 0.39 }, "scale" : { "start" : 0.1 , "end" : 0.9 , "minimumScaleMultiplier" : 1.25 }, "color" : { "start" : "#ffff8f" , "end" : ...