Skip to main content

Posts

Difference between pass by value , pass by pointer and pass by reference in c++ (really important)

so working with javascript can be quite different than working with c++. As c++ has pointer concept which is really unique and sometime really hard to understand in many c++ project for example games where you need to pass variable from one class to other or pass a variable from one function to other. i am mainly from javascript background where simple data types like number and string pass by value and complex data types like object and array passed by reference. but in c++ variables passed by three way and these are really important when u are dealing in heap or stack memory. code easy to understand https://www.onlinegdb.com/edit/HyTblnW1P 1. Pass By Value  (copy value) we hardly used this so check out my example i have a class called  class Demon {     private:         int age;     public:         Demon(){};         ~Demon(){};         void setAge(int __age)     ...

basic of javascript lesson 1

DATA TYPES IN JAVASCRIPT JAVASCRIPT MAINLY HAVE 5 TYPES OF DATA TYPES  1. STRING LIKE-       VAR USENAME="MANISH CHAUHAN"; USERNAME IS      MANISH CHAUHAN NOW 2. NUMBER      LIKE-VAR X=200; X CONTAIN 200. 3. OBJECT IS USED TO STORE COMPLEX VALUES IN JAVASCRIPT THERE ARE MULTIPLE WAYS YOU CAN CREATE A OBJECT IS JAVASCRIPT SO BELOW ARE THE EXAMPLE.      //object   var  obj ={   name : "manish" ,   age : 35 } var  obj1 = new   Object (); obj1 . name = "manish" ; obj1 . age = 22 ; var  obj2 = Object . create ( null ,{        'userName' :   {   value :   "manish" ,     writable :   true ,     enumerable :   true        },         'age' :   {   value :   35 ,     writable :   true ,...

count how many times a item repeated in a vector (c++) and return a map which track each item count

working link https://www.onlinegdb.com/edit/SJlwFiSKI code is below = /**************************************************************** *******************************************************************************/ #include <iostream> #include<vector> #include<map> using namespace std;  map<string,int>  createMap(vector<string> &vec) {     map<string,int> newMap;     for(int i=0;i<vec.size();i++)     {          const string newStr=vec.at(i);         if(newMap.find(newStr.c_str()) != newMap.end())         {              newMap[vec.at(i)]++;         }else                  {              newMap[vec.at(i)]=1;         }             }     return newMap; ...

A static class in javascript that can preload images using promises in a async manner so your main thread would not hang or slow down.

as lots of us already know that javascript is a single threaded language but in javascript you can do multiple operation in a single thread async. async meaning you can run multiple operation in parallel without disturbing main thread  which is mainly UI thread in javascript. promises is one way to do operation in async manner  learn more about promises https://javascript.info/promise-basics below is my solution to preload images in a async manner in javascript //preloading images using javascript class   Loader {      constructor ()      {        this . progressCallBack = undefined ;      }      //load all images in aysnc manner        //load multiple images    static  async  loadImages ( args )   {      //a promiseArray that...

dynamically inserting a template from a array of templates using @ViewChild and ngTemplateOutlet (angular)

some time we need to insert one template based on condition to the dom from a list of multiple list of template array. this can be easily done just using  ngTemplateOutlet you can read more about  ngTemplateOutlet https://angular.io/api/common/NgTemplateOutlet here is my solution to  pick one template from array and insert in to dom based on some condition working link is below https://stackblitz.com/edit/angular-kssdv9?file=src%2Fapp%2Fapp.component.html

1. Learning modern c++ for gaming from benefits to learning path. ( from my perspective)

Why c++ is primary language for gaming  1.  c++ is fast very fast. 2. c++ support multiple inheritance which is a very big plus points in many cases     for example     -------------- #include <iostream> #include<vector> using namespace std; struct Point {     float x;     float y; }; class Actions {     private:            Point point;     public:         Actions(){};      ~Actions(){};       void canMove(Point &_point)       {          point=_point;       };       Point getMovePosition()       {           return point;       } }; class Monster {     private:    std::vector<string> bonesArray ;     public:        Monster(){};     ...

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" : ...

Creating a word Scramble game where you can drag and drop the word and create a complete word. (drag and drop word Scramble game).

Creating a word game using  phaser game engine which is a javascript based gaming engine  where u can drag and drop world like Word Scramble Game and complete a given word. your index.html file look like below < html > < head > < script src = "src/phaser.min.js" ></ script > < script src = "src/wordGame.js" ></ script > < script src = "src/main.js" ></ script > </ head > < body > </ body > </ html > 1.    <script src="src/phaser.min.js"></script> required to run the  phaser game engine. 2. rest of the two files deals with game logics      <script src="src/wordGame.js"></script>       <script src="src/main.js"></script> you can download whole project from https://github.com/manishchauhan/wordgame/tree/master just copy and paste the project in your local server and run ...