<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Daniel Kalevski</title>
    <description>The latest articles on DEV Community by Daniel Kalevski (@kalevski).</description>
    <link>https://dev.to/kalevski</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F49561%2F8ac447bb-72d5-4ab9-b7d1-ee1baac6a83f.jpg</url>
      <title>DEV Community: Daniel Kalevski</title>
      <link>https://dev.to/kalevski</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kalevski"/>
    <language>en</language>
    <item>
      <title>Tutorial - Optimizing Memory Consumption in HTML5 Games</title>
      <dc:creator>Daniel Kalevski</dc:creator>
      <pubDate>Thu, 12 Jan 2023 01:35:16 +0000</pubDate>
      <link>https://dev.to/kalevski/tutorial-optimizing-memory-consumption-in-html5-games-lkb</link>
      <guid>https://dev.to/kalevski/tutorial-optimizing-memory-consumption-in-html5-games-lkb</guid>
      <description>&lt;p&gt;Welcome to my blog post about improving game performance through the use of Object pools.&lt;/p&gt;

&lt;p&gt;As a game developer, it's likely that you've had to deal with the problem of instantiating a large number of objects for a specific class, such as particles with a short lifetime that need to be destroyed. One of the challenges of this type of game logic is that JavaScript's model is based on the garbage collection pattern, which means that developers do not have direct control over allocated memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;When memory locations (variables) are marked as null, they are collected by the garbage collector and removed from memory. However, when the garbage collector needs to dispose of a lot of objects, it takes a lot of processing time, which can negatively impact the performance of the game.&lt;/p&gt;

&lt;p&gt;In that case, if you profile the memory, you will see something like what is shown in the picture below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZurcxdqT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/10467454/211951892-46ea9408-e75d-4804-9229-324a557c515b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZurcxdqT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/10467454/211951892-46ea9408-e75d-4804-9229-324a557c515b.jpg" alt="before" width="505" height="52"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;But there's a solution to this problem, and it's called the Object pools pattern.&lt;/p&gt;

&lt;p&gt;The Object pools pattern is an implementation that helps to reuse disposed objects instead of creating new ones. By reusing objects, we can reduce the number of objects that need to be created and collected by the garbage collector, which in turn improves the performance of the game.&lt;/p&gt;

&lt;p&gt;After using Object pools, you will get results like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KXTA1JjY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/10467454/211951895-162e0910-6e3c-414d-8f40-0e47a5860dca.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KXTA1JjY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/10467454/211951895-162e0910-6e3c-414d-8f40-0e47a5860dca.jpg" alt="after" width="505" height="53"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Phaser Plus Object Pools
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;CreateGameObjects&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Scene&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nx"&gt;onCreate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;myObject&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;MyObject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;// create object using pool&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;turtle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;obtain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;myObject&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;existing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;turtle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;// remove object from scene and retreive back to the pool&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;turtle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;release&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;turtle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>phaser</category>
      <category>gamedev</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Phaser+ Tutorials: Create new Phaser project in less than a minute</title>
      <dc:creator>Daniel Kalevski</dc:creator>
      <pubDate>Tue, 10 Jan 2023 22:00:04 +0000</pubDate>
      <link>https://dev.to/kalevski/phaser-tutorials-create-new-phaser-project-in-less-than-a-minute-laj</link>
      <guid>https://dev.to/kalevski/phaser-tutorials-create-new-phaser-project-in-less-than-a-minute-laj</guid>
      <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;this is my first Phaser tutorial, so I hope it will be useful for all those who plan to start a new project using Phaser.&lt;/p&gt;

&lt;p&gt;As part of a phaser-plus project I started recently, there is &lt;strong&gt;@phaser-plus/cli&lt;/strong&gt; - a command line tool for creating and developing Phaser projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Phaser?
&lt;/h2&gt;

&lt;p&gt;Phaser. is a free and open source software developed and owned by Richard Davey. You can visit their funding page and help them to make Phaser even better.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I make a project?
&lt;/h2&gt;

&lt;p&gt;Before you start creating a project, you need to have NodeJS 16+ installed on your machine. If you already have NodeJS 16+ installed, you can create a project by executing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx @phaser-plus/cli init --template=phaser my-phaser-game
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CLI Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Simple setup&lt;/li&gt;
&lt;li&gt;Hot module reload&lt;/li&gt;
&lt;li&gt;Optimized production build&lt;/li&gt;
&lt;li&gt;Support for Web workers&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gamedev</category>
      <category>tutorial</category>
      <category>html</category>
      <category>phaser</category>
    </item>
    <item>
      <title>Setting up a project to build Air Console game using PhaserJS</title>
      <dc:creator>Daniel Kalevski</dc:creator>
      <pubDate>Fri, 04 Mar 2022 14:43:22 +0000</pubDate>
      <link>https://dev.to/kalevski/setting-up-a-project-to-build-air-console-game-using-phaserjs-25n</link>
      <guid>https://dev.to/kalevski/setting-up-a-project-to-build-air-console-game-using-phaserjs-25n</guid>
      <description>&lt;p&gt;A few months ago, I started my journey developing a game for “AirConsole” using PhaserJS. At the beginning I spent a lot of time setting up my project. That inspired me to develop a command line interface (CLI) tool for simplifying the development environment for Air Console games using web technologies.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Air Console ?
&lt;/h2&gt;

&lt;p&gt;Air console is a platform focused on delivering local multiplayer experience using your TV or PC as a game console and your smartphones as controllers / gamepads. Actually the development of the game is divided in two parts, the first part is developing the actual game for the main screen and as a second part is developing the application used by gamepads (smartphones) to interact with the game.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript knowledge&lt;/li&gt;
&lt;li&gt;NodeJS (v14.0 or higher) installed on your local machine&lt;/li&gt;
&lt;li&gt;Code Editor&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Project setup
&lt;/h2&gt;

&lt;p&gt;As a first step we need to install the tool that I’ve created for this purpose. The tool is a npm executable published to npmjs.org.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g airconsole-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After successful installation, you can create your project by executing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;airconsole init my-airconsole-game
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The previous command should create a directory named my-airconsole-game.&lt;/p&gt;

&lt;p&gt;Next steps are installing the dependencies using,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install  // (inside project directory "my-airconsole-game")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;command inside the “my-airconsole-game” directory and running the project by executing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this is helpful.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>JavaScript Decorators </title>
      <dc:creator>Daniel Kalevski</dc:creator>
      <pubDate>Sun, 18 Feb 2018 02:02:51 +0000</pubDate>
      <link>https://dev.to/kalevski/javascript-decorators--3nol</link>
      <guid>https://dev.to/kalevski/javascript-decorators--3nol</guid>
      <description>&lt;p&gt;JavaScript developers. Are you using JS Decorators in your projects ? Today I write simple wrapper for better experience with decorators. Important to me is your opinion about this helper library.&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/decorator-wrapper"&gt;https://www.npmjs.com/package/decorator-wrapper&lt;/a&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>javascript</category>
      <category>es6</category>
      <category>decorators</category>
    </item>
  </channel>
</rss>
