<?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: Arnav Puri</title>
    <description>The latest articles on DEV Community by Arnav Puri (@arnavpuri).</description>
    <link>https://dev.to/arnavpuri</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%2F272280%2F4a906ef7-bd13-42cc-801c-957bc33c9ca4.jpeg</url>
      <title>DEV Community: Arnav Puri</title>
      <link>https://dev.to/arnavpuri</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arnavpuri"/>
    <language>en</language>
    <item>
      <title>2048 Game 🕹 using Flutter - Animations added</title>
      <dc:creator>Arnav Puri</dc:creator>
      <pubDate>Thu, 12 Mar 2020 14:29:07 +0000</pubDate>
      <link>https://dev.to/arnavpuri/2048-game-using-flutter-animations-added-37lh</link>
      <guid>https://dev.to/arnavpuri/2048-game-using-flutter-animations-added-37lh</guid>
      <description>&lt;p&gt;I am building classical 2048 game using Flutter and here is the link to &lt;a href="https://dev.to/arnavpuri/2048-game-using-flutter-work-in-progress-1bal"&gt;previous post&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ArnavPuri/game_2048_flutter"&gt;Repository Link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this post, I want to share that I have added slide animations. It wasn't very easy to do so. &lt;/p&gt;

&lt;p&gt;The single-cell is a stateful widget and it always stores old value. So old value slides out and new value slides in.&lt;/p&gt;

&lt;p&gt;I am using a single animation controller which is being used by all the cells (16 total).&lt;/p&gt;

&lt;p&gt;Every time there is a swipe I make the controller go forward.&lt;/p&gt;

&lt;p&gt;Also for keeping track of swipe direction, I am using enums which makes it easier and faster to manage.&lt;/p&gt;

&lt;p&gt;It can still be refactored a lot. &lt;/p&gt;

&lt;p&gt;Next up is undo feature and show the 'game over' or 'you win' dialog&lt;/p&gt;

</description>
      <category>dart</category>
    </item>
    <item>
      <title>2048 Game 🕹 using Flutter - Work in Progress 🚧</title>
      <dc:creator>Arnav Puri</dc:creator>
      <pubDate>Tue, 25 Feb 2020 13:32:28 +0000</pubDate>
      <link>https://dev.to/arnavpuri/2048-game-using-flutter-work-in-progress-1bal</link>
      <guid>https://dev.to/arnavpuri/2048-game-using-flutter-work-in-progress-1bal</guid>
      <description>&lt;h1&gt;
  
  
  Building classic 2048 game from Scratch
&lt;/h1&gt;

&lt;p&gt;While browsing through algorithms to practice I came across a challenge which was to implement 'swipe left' on a given list of numbers.&lt;/p&gt;

&lt;p&gt;So for instance, if you have a row like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var numbers = [2, 0, 2, 4, 4, 8]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and if you call &lt;code&gt;leftSwipe(numbers)&lt;/code&gt; it should return&lt;/p&gt;

&lt;p&gt;&lt;code&gt;[4, 8, 8, 0, 0, 0]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I implemented it and thought of taking it to the next level and implement whole game logic.&lt;/p&gt;

&lt;p&gt;So for the 2048 game, there are basically two components, (Which app doesn't have these two components 🤷🏻‍♂️)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logic&lt;/li&gt;
&lt;li&gt;UI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I implemented logic in pure #Dart&lt;br&gt;
It basically has these components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Left, Right, Up and Down swipe&lt;/li&gt;
&lt;li&gt;Add 2 randomly at empty spaces (0 in the list)&lt;/li&gt;
&lt;li&gt;Check if the board is full (no zeroes left)&lt;/li&gt;
&lt;li&gt;Check if the user has won (if 2048 is present)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can go ahead and have a look at the code for these &lt;a href="https://github.com/ArnavPuri/game_2048_flutter/blob/master/lib/board_controller.dart"&gt;steps here&lt;/a&gt;. I know, I know, I can refactor it. I will do it later. Eventually. Promise.&lt;/p&gt;

&lt;p&gt;I have got the basic UI working which also you can check out on &lt;a href="https://github.com/ArnavPuri/game_2048_flutter"&gt;Github here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Things to add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Game Over and You Win notification 🎯&lt;/li&gt;
&lt;li&gt;Undo feature (It's not cheating if it is a feature) 😜&lt;/li&gt;
&lt;li&gt;Animations 🤩&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As of now, this is how app looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G9gR8voF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iknfx8q2b9qfioojnajf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G9gR8voF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iknfx8q2b9qfioojnajf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to give stars to the repo, fork it, or send me some bitcoins. &lt;/p&gt;

&lt;p&gt;Let me know what you think and if you would like future progress updates 😉&lt;/p&gt;

</description>
      <category>dart</category>
      <category>flutter</category>
      <category>app</category>
      <category>learntocode</category>
    </item>
  </channel>
</rss>
