<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>game Arsip - Farazinux</title>
	<atom:link href="https://farazinux.com/tag/game/feed/" rel="self" type="application/rss+xml" />
	<link>https://farazinux.com/tag/game/</link>
	<description>Belajar Bareng, Sukses Bareng</description>
	<lastBuildDate>Sat, 08 Feb 2025 23:32:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://farazinux.com/wp-content/uploads/2022/04/icon-farazinux-2-150x150.png</url>
	<title>game Arsip - Farazinux</title>
	<link>https://farazinux.com/tag/game/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Pop!_OS: Distro Linux Unggulan untuk Gamers, Fitur Menarik dan Kemudahan Penggunaan</title>
		<link>https://farazinux.com/pop_os-distro-linux-unggulan-untuk-gamers-fitur-menarik-dan-kemudahan-penggunaan/</link>
					<comments>https://farazinux.com/pop_os-distro-linux-unggulan-untuk-gamers-fitur-menarik-dan-kemudahan-penggunaan/#respond</comments>
		
		<dc:creator><![CDATA[iPunx]]></dc:creator>
		<pubDate>Sat, 08 Feb 2025 23:32:23 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[OS]]></category>
		<guid isPermaLink="false">https://farazinux.com/?p=6775</guid>

					<description><![CDATA[<p>Sering pula kita berpikir apakah ada distro linux yang dapat digunakan untuk para gamers? Karena Linux lebih terkenal bagi para developer aplikasi, jaringan dan server. Namun, karena Linux adalah sistem operasi OpenSource yang dikembangkan oleh berbagai kalangan. Sehingga Linux dapat berkembang dalam berbagai model, salah satunya adalah Pop!_OS. Pop!_OS adalah sistem operasi berbasis Linux yang [&#8230;]</p>
<p>Artikel <a href="https://farazinux.com/pop_os-distro-linux-unggulan-untuk-gamers-fitur-menarik-dan-kemudahan-penggunaan/">Pop!_OS: Distro Linux Unggulan untuk Gamers, Fitur Menarik dan Kemudahan Penggunaan</a> pertama kali tampil pada <a href="https://farazinux.com">Farazinux</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Sering pula kita berpikir apakah ada distro linux yang dapat digunakan untuk para gamers? Karena Linux lebih terkenal bagi para developer aplikasi, jaringan dan server. Namun, karena Linux adalah sistem operasi OpenSource yang dikembangkan oleh berbagai kalangan. Sehingga Linux dapat berkembang dalam berbagai model, salah satunya adalah Pop!_OS.</p>



<p>Pop!_OS adalah sistem operasi berbasis <a href="https://farazinux.com/category/linux">Linux</a> yang dikembangkan dan dikelola oleh System76, sebuah vendor hardware ternama. Selain diinstal secara default pada perangkat System76, Pop!_OS juga bisa diunduh secara gratis oleh pengguna umum. Distro ini menawarkan berbagai fitur menarik yang membuatnya menjadi pilihan menarik, terutama bagi para gamer.</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="berbasis-ubuntu-lts-dengan-antarmuka-kustom">Berbasis Ubuntu LTS dengan Antarmuka Kustom</h3>



<p>Pop!_OS dibangun di atas fondasi <a href="https://farazinux.com/tag/ubuntu">Ubuntu LTS</a> (saat ini versi 22.04) dan dilengkapi dengan antarmuka pengguna kustom bernama Pop Shell, yang berjalan di atas GNOME. Meskipun ada banyak distro Linux lain yang ditujukan untuk gaming, Pop!_OS menonjol karena menyediakan semua fitur yang dibutuhkan gamer secara lengkap.</p>



<p>Salah satu keunggulannya adalah dukungan penuh untuk hybrid graphics. Pengembang Pop!_OS memastikan bahwa fitur ini berfungsi dengan sempurna, memungkinkan pengguna untuk memilih GPU yang digunakan saat menjalankan game langsung dari menu konteks. Selain itu, pengguna juga dapat dengan mudah beralih antara mode hemat baterai dan performa tinggi sesuai kebutuhan.</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="dukungan-untuk-hardware-nvidia-dan-raspberry-pi">Dukungan untuk Hardware Nvidia dan Raspberry Pi</h3>



<p>Pop!_OS menawarkan beberapa versi yang disesuaikan dengan kebutuhan pengguna. Selain edisi standar, tersedia versi khusus untuk pengguna yang menggunakan hardware Nvidia, yang sudah dilengkapi dengan driver proprietary untuk memaksimalkan kinerja. Tidak hanya itu, Pop!_OS juga memiliki versi yang kompatibel dengan Raspberry Pi 4, memperluas jangkauan penggunaannya.</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="keamanan-dan-kemudahan-instalasi-aplikasi">Keamanan dan Kemudahan Instalasi Aplikasi</h3>



<p>Salah satu fitur keamanan unggulan Pop!_OS adalah enkripsi instalasi yang diaktifkan secara default. Meskipun distro ini hadir dengan aplikasi bawaan yang minimal, pengguna dapat dengan mudah menambahkan aplikasi lain melalui Pop!_Shop, toko aplikasi kustom yang intuitif. Pop!_Shop tidak hanya menyediakan aplikasi desktop biasa, tetapi juga platform gaming populer seperti Steam, Lutris, dan GameHub.</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="kenapa-pop_os-cocok-untuk-gamers">Kenapa Pop!_OS Cocok untuk Gamers?</h3>



<p>Pop!_OS dirancang untuk memenuhi kebutuhan gamers dengan menyediakan fitur-fitur yang memudahkan pengelolaan hardware dan software. Dukungan hybrid graphics, driver Nvidia yang terintegrasi, serta kemudahan instalasi aplikasi gaming membuatnya menjadi distro Linux yang layak dipertimbangkan.</p>



<p>Dengan kombinasi performa, keamanan, dan kemudahan penggunaan, Pop!_OS tidak hanya cocok untuk gamers, tetapi juga untuk pengguna umum yang menginginkan sistem operasi Linux yang andal dan modern.</p>



<p>Anda dapat mengunduh atau download Linux Pop!_OS, distro linux untuk gamers dari web resminya. Atau klik pada tombol download di bawah ini.</p>



<div class="wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-16018d1d wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://pop.system76.com/">Download Pop!_OS</a></div>
</div>
<p>Artikel <a href="https://farazinux.com/pop_os-distro-linux-unggulan-untuk-gamers-fitur-menarik-dan-kemudahan-penggunaan/">Pop!_OS: Distro Linux Unggulan untuk Gamers, Fitur Menarik dan Kemudahan Penggunaan</a> pertama kali tampil pada <a href="https://farazinux.com">Farazinux</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://farazinux.com/pop_os-distro-linux-unggulan-untuk-gamers-fitur-menarik-dan-kemudahan-penggunaan/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Sourcecode Game HTML Javascript &#124; Tetris Menumpuk Bata</title>
		<link>https://farazinux.com/sourcecode-game-html-javascript-tetris-menumpuk-bata/</link>
					<comments>https://farazinux.com/sourcecode-game-html-javascript-tetris-menumpuk-bata/#respond</comments>
		
		<dc:creator><![CDATA[iPunx]]></dc:creator>
		<pubDate>Tue, 06 Aug 2024 09:51:57 +0000</pubDate>
				<category><![CDATA[Pemrograman]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sourcecode]]></category>
		<guid isPermaLink="false">https://farazinux.com/?p=6332</guid>

					<description><![CDATA[<p>Sourcecode Game HTML Javascript yang farazinux.com kali ini bagikan adalah source code game tetris. Sebuah game jadul alias kuno atau lawas namun tetap sangat mengasikkan untuk dimainkan dalam rangka mengusir gabut dan rasa bosan. Game tetris adalah game lawas dan sangat populer. Cara bermainnya adalah anda akan diberikan batu bata dengan beberapa bentuk yang sangat [&#8230;]</p>
<p>Artikel <a href="https://farazinux.com/sourcecode-game-html-javascript-tetris-menumpuk-bata/">Sourcecode Game HTML Javascript | Tetris Menumpuk Bata</a> pertama kali tampil pada <a href="https://farazinux.com">Farazinux</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Sourcecode Game HTML Javascript yang farazinux.com kali ini bagikan adalah <a href="https://farazinux.com/tag/sourcecode">source code</a> game tetris. Sebuah game jadul alias kuno atau lawas namun tetap sangat mengasikkan untuk dimainkan dalam rangka mengusir gabut dan rasa bosan.</p>



<p><a href="https://farazinux.com/tag/game">Game</a> tetris adalah game lawas dan sangat populer. Cara bermainnya adalah anda akan diberikan batu bata dengan beberapa bentuk yang sangat khas. Tugas anda adalah menumpuk kotak atau batu bata tersebut dengan rapi, sehingga membentuk barisan batu bata yang tidak berlobang.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="main-game-tetris-html-javascript">Main Game Tetris HTML Javascript</h2>



<p>Berikut ini adalah game tetris yang dibuat dengan html dan javascript. Untuk memainkannya silahkan tekan tombol spasi pada keyboard anda. Sedangkan untuk berhenti sejenak anda dapat menekan tombol esc pada keyboard.</p>



<p>Beberapa tombol yang diperlukan untuk memainkan game Tetris ini adalah tombol spasi, esc dan tombol panah atas, bawah, kanan dan kiri keyboard. Adapun kegunaan masing-masing tombol tersebut adalah sebagai berikut:</p>



<ul class="wp-block-list">
<li>Tombol spasi untuk memulai aplikasi game tetris.</li>



<li>Tombol esc untuk menjeda atau berhenti dari game tetris.</li>



<li>Tombol panah ke atas untuk merotasi bentuk blok yang sedang berjalan.</li>



<li>Tombol panah ke bawah untuk mempercepat blok turun ke bawah.</li>



<li>Tombol panah ke kanan untuk menggeser blok yang sedang berjalan ke arah kanan.</li>



<li>Tombol panah ke kiri untuk menggeser blok yang sedang berjalan ke arah kiri.</li>
</ul>



<p>Untuk lebih jelasnya silahkan mainkan aplikasi game tetris berbasis html dan javascript di bawah ini.</p>



<iframe src="https://sc.farazinux.com/html_css/tetris/index.html" width="100%" height="600px"></iframe>



<div class="wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-16018d1d wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-red-background-color has-background wp-element-button" href="https://sc.farazinux.com/html_css/tetris/index.html">Main Langsung</a></div>
</div>



<h2 class="wp-block-heading" class="wp-block-heading" id="sourcecode-game-tetris">Sourcecode Game Tetris</h2>



<p>Game tetris ini hanya menggunakan dua file yaitu html dan javascript. Untuk sourcecode game tetris berbasis html dan javascript ini silahkan perhatikan sourcecode berikut ini:</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="1-file-html-index-hmtl">1. File html (index.hmtl)</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="html" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;!DOCTYPE html>
&lt;html>

&lt;head>
  &lt;title>Numpuk Boto Farazinux&lt;/title>
  &lt;style>
    body {
      font-family: Helvetica, sans-serif;
    }

    #tetris {
      margin: 1em auto;
      padding: 1em;
      border: 4px solid black;
      border-radius: 10px;
      background-color: #F8F8F8;
    }

    #stats {
      display: inline-block;
      vertical-align: top;
    }

    #canvas {
      display: inline-block;
      vertical-align: top;
      background: url(texture.jpg);
      box-shadow: 10px 10px 10px #999;
      border: 2px solid #333;
    }

    #menu {
      display: inline-block;
      vertical-align: top;
      position: relative;
    }

    #menu p {
      margin: 0.5em 0;
      text-align: center;
    }

    #menu p a {
      text-decoration: none;
      color: black;
    }

    #upcoming {
      display: block;
      margin: 0 auto;
      background-color: #E0E0E0;
    }

    #score {
      color: red;
      font-weight: bold;
      vertical-align: middle;
    }

    #rows {
      color: blue;
      font-weight: bold;
      vertical-align: middle;
    }

    #stats {
      position: absolute;
      bottom: 0em;
      right: 1em;
    }

    @media screen and (min-width: 0px) and (min-height: 0px) {
      #tetris {
        font-size: 0.75em;
        width: 250px;
      }

      #menu {
        width: 100px;
        height: 200px;
      }

      #upcoming {
        width: 50px;
        height: 50px;
      }

      #canvas {
        width: 100px;
        height: 200px;
      }
    }

    /* 10px chunks */
    @media screen and (min-width: 400px) and (min-height: 400px) {
      #tetris {
        font-size: 1.00em;
        width: 350px;
      }

      #menu {
        width: 150px;
        height: 300px;
      }

      #upcoming {
        width: 75px;
        height: 75px;
      }

      #canvas {
        width: 150px;
        height: 300px;
      }
    }

    /* 15px chunks */
    @media screen and (min-width: 500px) and (min-height: 500px) {
      #tetris {
        font-size: 1.25em;
        width: 450px;
      }

      #menu {
        width: 200px;
        height: 400px;
      }

      #upcoming {
        width: 100px;
        height: 100px;
      }

      #canvas {
        width: 200px;
        height: 400px;
      }
    }

    /* 20px chunks */
    @media screen and (min-width: 600px) and (min-height: 600px) {
      #tetris {
        font-size: 1.50em;
        width: 550px;
      }

      #menu {
        width: 250px;
        height: 500px;
      }

      #upcoming {
        width: 125px;
        height: 125px;
      }

      #canvas {
        width: 250px;
        height: 500px;
      }
    }

    /* 25px chunks */
    @media screen and (min-width: 700px) and (min-height: 700px) {
      #tetris {
        font-size: 1.75em;
        width: 650px;
      }

      #menu {
        width: 300px;
        height: 600px;
      }

      #upcoming {
        width: 150px;
        height: 150px;
      }

      #canvas {
        width: 300px;
        height: 600px;
      }
    }

    /* 30px chunks */
    @media screen and (min-width: 800px) and (min-height: 800px) {
      #tetris {
        font-size: 2.00em;
        width: 750px;
      }

      #menu {
        width: 350px;
        height: 700px;
      }

      #upcoming {
        width: 175px;
        height: 175px;
      }

      #canvas {
        width: 350px;
        height: 700px;
      }
    }

    /* 35px chunks */
    @media screen and (min-width: 900px) and (min-height: 900px) {
      #tetris {
        font-size: 2.25em;
        width: 850px;
      }

      #menu {
        width: 400px;
        height: 800px;
      }

      #upcoming {
        width: 200px;
        height: 200px;
      }

      #canvas {
        width: 400px;
        height: 800px;
      }
    }

    /* 40px chunks */
  &lt;/style>
&lt;/head>

&lt;body>

  &lt;div id="tetris">
    &lt;div id="menu">
      &lt;p id="start">&lt;a href="javascript:play();">Untuk Main Pencet Spasi, untuk jeda pencet Esc.&lt;/a>&lt;/p>
      &lt;p>&lt;canvas id="upcoming">&lt;/canvas>&lt;/p>
      &lt;p>score &lt;span id="score">00000&lt;/span>&lt;/p>
      &lt;p>rows &lt;span id="rows">0&lt;/span>&lt;/p>
      &lt;p>Untuk donasi atau Nyawer &lt;a href="https://saweria.co/ipunx">&lt;span id="score">Klik di sini&lt;/span>&lt;/a>
      &lt;/p>
    &lt;/div>
    &lt;canvas id="canvas">
      Sorry, this example cannot be run because your browser does not support the &amp;lt;canvas&amp;gt; element
    &lt;/canvas>
  &lt;/div>

  &lt;script src="stats.js">&lt;/script>
  &lt;script>

    //-------------------------------------------------------------------------
    // base helper methods
    //-------------------------------------------------------------------------

    function get(id) { return document.getElementById(id); }
    function hide(id) { get(id).style.visibility = 'hidden'; }
    function show(id) { get(id).style.visibility = null; }
    function html(id, html) { get(id).innerHTML = html; }

    function timestamp() { return new Date().getTime(); }
    function random(min, max) { return (min + (Math.random() * (max - min))); }
    function randomChoice(choices) { return choices[Math.round(random(0, choices.length - 1))]; }

    if (!window.requestAnimationFrame) { // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
      window.requestAnimationFrame = window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.oRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        function (callback, element) {
          window.setTimeout(callback, 1000 / 60);
        }
    }

    //-------------------------------------------------------------------------
    // game constants
    //-------------------------------------------------------------------------

    var KEY = { ESC: 27, SPACE: 32, LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40 },
      DIR = { UP: 0, RIGHT: 1, DOWN: 2, LEFT: 3, MIN: 0, MAX: 3 },
      stats = new Stats(),
      canvas = get('canvas'),
      ctx = canvas.getContext('2d'),
      ucanvas = get('upcoming'),
      uctx = ucanvas.getContext('2d'),
      speed = { start: 0.6, decrement: 0.005, min: 0.1 }, // how long before piece drops by 1 row (seconds)
      nx = 10, // width of tetris court (in blocks)
      ny = 20, // height of tetris court (in blocks)
      nu = 5;  // width/height of upcoming preview (in blocks)

    //-------------------------------------------------------------------------
    // game variables (initialized during reset)
    //-------------------------------------------------------------------------

    var dx, dy,        // pixel size of a single tetris block
      blocks,        // 2 dimensional array (nx*ny) representing tetris court - either empty block or occupied by a 'piece'
      actions,       // queue of user actions (inputs)
      playing,       // true|false - game is in progress
      dt,            // time since starting this game
      current,       // the current piece
      next,          // the next piece
      score,         // the current score
      vscore,        // the currently displayed score (it catches up to score in small chunks - like a spinning slot machine)
      rows,          // number of completed rows in the current game
      step;          // how long before current piece drops by 1 row

    //-------------------------------------------------------------------------
    // tetris pieces
    //
    // blocks: each element represents a rotation of the piece (0, 90, 180, 270)
    //         each element is a 16 bit integer where the 16 bits represent
    //         a 4x4 set of blocks, e.g. j.blocks[0] = 0x44C0
    //
    //             0100 = 0x4 &lt;&lt; 3 = 0x4000
    //             0100 = 0x4 &lt;&lt; 2 = 0x0400
    //             1100 = 0xC &lt;&lt; 1 = 0x00C0
    //             0000 = 0x0 &lt;&lt; 0 = 0x0000
    //                               ------
    //                               0x44C0
    //
    //-------------------------------------------------------------------------

    var i = { size: 4, blocks: [0x0F00, 0x2222, 0x00F0, 0x4444], color: 'cyan' };
    var j = { size: 3, blocks: [0x44C0, 0x8E00, 0x6440, 0x0E20], color: 'blue' };
    var l = { size: 3, blocks: [0x4460, 0x0E80, 0xC440, 0x2E00], color: 'orange' };
    var o = { size: 2, blocks: [0xCC00, 0xCC00, 0xCC00, 0xCC00], color: 'yellow' };
    var s = { size: 3, blocks: [0x06C0, 0x8C40, 0x6C00, 0x4620], color: 'green' };
    var t = { size: 3, blocks: [0x0E40, 0x4C40, 0x4E00, 0x4640], color: 'purple' };
    var z = { size: 3, blocks: [0x0C60, 0x4C80, 0xC600, 0x2640], color: 'red' };

    //------------------------------------------------
    // do the bit manipulation and iterate through each
    // occupied block (x,y) for a given piece
    //------------------------------------------------
    function eachblock(type, x, y, dir, fn) {
      var bit, result, row = 0, col = 0, blocks = type.blocks[dir];
      for (bit = 0x8000; bit > 0; bit = bit >> 1) {
        if (blocks &amp; bit) {
          fn(x + col, y + row);
        }
        if (++col === 4) {
          col = 0;
          ++row;
        }
      }
    }

    //-----------------------------------------------------
    // check if a piece can fit into a position in the grid
    //-----------------------------------------------------
    function occupied(type, x, y, dir) {
      var result = false
      eachblock(type, x, y, dir, function (x, y) {
        if ((x &lt; 0) || (x >= nx) || (y &lt; 0) || (y >= ny) || getBlock(x, y))
          result = true;
      });
      return result;
    }

    function unoccupied(type, x, y, dir) {
      return !occupied(type, x, y, dir);
    }

    //-----------------------------------------
    // start with 4 instances of each piece and
    // pick randomly until the 'bag is empty'
    //-----------------------------------------
    var pieces = [];
    function randomPiece() {
      if (pieces.length == 0)
        pieces = [i, i, i, i, j, j, j, j, l, l, l, l, o, o, o, o, s, s, s, s, t, t, t, t, z, z, z, z];
      var type = pieces.splice(random(0, pieces.length - 1), 1)[0];
      return { type: type, dir: DIR.UP, x: Math.round(random(0, nx - type.size)), y: 0 };
    }


    //-------------------------------------------------------------------------
    // GAME LOOP
    //-------------------------------------------------------------------------

    function run() {

      showStats(); // initialize FPS counter
      addEvents(); // attach keydown and resize events

      var last = now = timestamp();
      function frame() {
        now = timestamp();
        update(Math.min(1, (now - last) / 1000.0)); // using requestAnimationFrame have to be able to handle large delta's caused when it 'hibernates' in a background or non-visible tab
        draw();
        stats.update();
        last = now;
        requestAnimationFrame(frame, canvas);
      }

      resize(); // setup all our sizing information
      reset();  // reset the per-game variables
      frame();  // start the first frame

    }

    function showStats() {
      stats.domElement.id = 'stats';
      get('menu').appendChild(stats.domElement);
    }

    function addEvents() {
      document.addEventListener('keydown', keydown, false);
      window.addEventListener('resize', resize, false);
    }

    function resize(event) {
      canvas.width = canvas.clientWidth;  // set canvas logical size equal to its physical size
      canvas.height = canvas.clientHeight; // (ditto)
      ucanvas.width = ucanvas.clientWidth;
      ucanvas.height = ucanvas.clientHeight;
      dx = canvas.width / nx; // pixel size of a single tetris block
      dy = canvas.height / ny; // (ditto)
      invalidate();
      invalidateNext();
    }

    function keydown(ev) {
      var handled = false;
      if (playing) {
        switch (ev.keyCode) {
          case KEY.LEFT: actions.push(DIR.LEFT); handled = true; break;
          case KEY.RIGHT: actions.push(DIR.RIGHT); handled = true; break;
          case KEY.UP: actions.push(DIR.UP); handled = true; break;
          case KEY.DOWN: actions.push(DIR.DOWN); handled = true; break;
          case KEY.ESC: lose(); handled = true; break;
        }
      }
      else if (ev.keyCode == KEY.SPACE) {
        play();
        handled = true;
      }
      if (handled)
        ev.preventDefault(); // prevent arrow keys from scrolling the page (supported in IE9+ and all other browsers)
    }

    //-------------------------------------------------------------------------
    // GAME LOGIC
    //-------------------------------------------------------------------------

    function play() { hide('start'); reset(); playing = true; }
    function lose() { show('start'); setVisualScore(); playing = false; }

    function setVisualScore(n) { vscore = n || score; invalidateScore(); }
    function setScore(n) { score = n; setVisualScore(n); }
    function addScore(n) { score = score + n; }
    function clearScore() { setScore(0); }
    function clearRows() { setRows(0); }
    function setRows(n) { rows = n; step = Math.max(speed.min, speed.start - (speed.decrement * rows)); invalidateRows(); }
    function addRows(n) { setRows(rows + n); }
    function getBlock(x, y) { return (blocks &amp;&amp; blocks[x] ? blocks[x][y] : null); }
    function setBlock(x, y, type) { blocks[x] = blocks[x] || []; blocks[x][y] = type; invalidate(); }
    function clearBlocks() { blocks = []; invalidate(); }
    function clearActions() { actions = []; }
    function setCurrentPiece(piece) { current = piece || randomPiece(); invalidate(); }
    function setNextPiece(piece) { next = piece || randomPiece(); invalidateNext(); }

    function reset() {
      dt = 0;
      clearActions();
      clearBlocks();
      clearRows();
      clearScore();
      setCurrentPiece(next);
      setNextPiece();
    }

    function update(idt) {
      if (playing) {
        if (vscore &lt; score)
          setVisualScore(vscore + 1);
        handle(actions.shift());
        dt = dt + idt;
        if (dt > step) {
          dt = dt - step;
          drop();
        }
      }
    }

    function handle(action) {
      switch (action) {
        case DIR.LEFT: move(DIR.LEFT); break;
        case DIR.RIGHT: move(DIR.RIGHT); break;
        case DIR.UP: rotate(); break;
        case DIR.DOWN: drop(); break;
      }
    }

    function move(dir) {
      var x = current.x, y = current.y;
      switch (dir) {
        case DIR.RIGHT: x = x + 1; break;
        case DIR.LEFT: x = x - 1; break;
        case DIR.DOWN: y = y + 1; break;
      }
      if (unoccupied(current.type, x, y, current.dir)) {
        current.x = x;
        current.y = y;
        invalidate();
        return true;
      }
      else {
        return false;
      }
    }

    function rotate() {
      var newdir = (current.dir == DIR.MAX ? DIR.MIN : current.dir + 1);
      if (unoccupied(current.type, current.x, current.y, newdir)) {
        current.dir = newdir;
        invalidate();
      }
    }

    function drop() {
      if (!move(DIR.DOWN)) {
        addScore(10);
        dropPiece();
        removeLines();
        setCurrentPiece(next);
        setNextPiece(randomPiece());
        clearActions();
        if (occupied(current.type, current.x, current.y, current.dir)) {
          lose();
        }
      }
    }

    function dropPiece() {
      eachblock(current.type, current.x, current.y, current.dir, function (x, y) {
        setBlock(x, y, current.type);
      });
    }

    function removeLines() {
      var x, y, complete, n = 0;
      for (y = ny; y > 0; --y) {
        complete = true;
        for (x = 0; x &lt; nx; ++x) {
          if (!getBlock(x, y))
            complete = false;
        }
        if (complete) {
          removeLine(y);
          y = y + 1; // recheck same line
          n++;
        }
      }
      if (n > 0) {
        addRows(n);
        addScore(100 * Math.pow(2, n - 1)); // 1: 100, 2: 200, 3: 400, 4: 800
      }
    }

    function removeLine(n) {
      var x, y;
      for (y = n; y >= 0; --y) {
        for (x = 0; x &lt; nx; ++x)
          setBlock(x, y, (y == 0) ? null : getBlock(x, y - 1));
      }
    }

    //-------------------------------------------------------------------------
    // RENDERING
    //-------------------------------------------------------------------------

    var invalid = {};

    function invalidate() { invalid.court = true; }
    function invalidateNext() { invalid.next = true; }
    function invalidateScore() { invalid.score = true; }
    function invalidateRows() { invalid.rows = true; }

    function draw() {
      ctx.save();
      ctx.lineWidth = 1;
      ctx.translate(0.5, 0.5); // for crisp 1px black lines
      drawCourt();
      drawNext();
      drawScore();
      drawRows();
      ctx.restore();
    }

    function drawCourt() {
      if (invalid.court) {
        ctx.clearRect(0, 0, canvas.width, canvas.height);
        if (playing)
          drawPiece(ctx, current.type, current.x, current.y, current.dir);
        var x, y, block;
        for (y = 0; y &lt; ny; y++) {
          for (x = 0; x &lt; nx; x++) {
            if (block = getBlock(x, y))
              drawBlock(ctx, x, y, block.color);
          }
        }
        ctx.strokeRect(0, 0, nx * dx - 1, ny * dy - 1); // court boundary
        invalid.court = false;
      }
    }

    function drawNext() {
      if (invalid.next) {
        var padding = (nu - next.type.size) / 2; // half-arsed attempt at centering next piece display
        uctx.save();
        uctx.translate(0.5, 0.5);
        uctx.clearRect(0, 0, nu * dx, nu * dy);
        drawPiece(uctx, next.type, padding, padding, next.dir);
        uctx.strokeStyle = 'black';
        uctx.strokeRect(0, 0, nu * dx - 1, nu * dy - 1);
        uctx.restore();
        invalid.next = false;
      }
    }

    function drawScore() {
      if (invalid.score) {
        html('score', ("00000" + Math.floor(vscore)).slice(-5));
        invalid.score = false;
      }
    }

    function drawRows() {
      if (invalid.rows) {
        html('rows', rows);
        invalid.rows = false;
      }
    }

    function drawPiece(ctx, type, x, y, dir) {
      eachblock(type, x, y, dir, function (x, y) {
        drawBlock(ctx, x, y, type.color);
      });
    }

    function drawBlock(ctx, x, y, color) {
      ctx.fillStyle = color;
      ctx.fillRect(x * dx, y * dy, dx, dy);
      ctx.strokeRect(x * dx, y * dy, dx, dy)
    }

    //-------------------------------------------------------------------------
    // FINALLY, lets run the game
    //-------------------------------------------------------------------------

    run();

  &lt;/script>

&lt;/body>

&lt;/html></pre>



<h3 class="wp-block-heading" class="wp-block-heading" id="2-file-javascript-stats-js">2. File javascript (stats.js)</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">// stats.js r6 - http://github.com/mrdoob/stats.js
var Stats=function(){function s(a,g,d){var f,c,e;for(c=0;c&lt;30;c++)for(f=0;f&lt;73;f++)e=(f+c*74)*4,a[e]=a[e+4],a[e+1]=a[e+5],a[e+2]=a[e+6];for(c=0;c&lt;30;c++)e=(73+c*74)*4,c&lt;g?(a[e]=b[d].bg.r,a[e+1]=b[d].bg.g,a[e+2]=b[d].bg.b):(a[e]=b[d].fg.r,a[e+1]=b[d].fg.g,a[e+2]=b[d].fg.b)}var r=0,t=2,g,u=0,j=(new Date).getTime(),F=j,v=j,l=0,w=1E3,x=0,k,d,a,m,y,n=0,z=1E3,A=0,f,c,o,B,p=0,C=1E3,D=0,h,i,q,E,b={fps:{bg:{r:16,g:16,b:48},fg:{r:0,g:255,b:255}},ms:{bg:{r:16,g:48,b:16},fg:{r:0,g:255,b:0}},mb:{bg:{r:48,g:16,
b:26},fg:{r:255,g:0,b:128}}};g=document.createElement("div");g.style.cursor="pointer";g.style.width="80px";g.style.opacity="0.9";g.style.zIndex="10001";g.addEventListener("click",function(){r++;r==t&amp;&amp;(r=0);k.style.display="none";f.style.display="none";h.style.display="none";switch(r){case 0:k.style.display="block";break;case 1:f.style.display="block";break;case 2:h.style.display="block"}},!1);k=document.createElement("div");k.style.backgroundColor="rgb("+Math.floor(b.fps.bg.r/2)+","+Math.floor(b.fps.bg.g/
2)+","+Math.floor(b.fps.bg.b/2)+")";k.style.padding="2px 0px 3px 0px";g.appendChild(k);d=document.createElement("div");d.style.fontFamily="Helvetica, Arial, sans-serif";d.style.textAlign="left";d.style.fontSize="9px";d.style.color="rgb("+b.fps.fg.r+","+b.fps.fg.g+","+b.fps.fg.b+")";d.style.margin="0px 0px 1px 3px";d.innerHTML='&lt;span style="font-weight:bold">FPS&lt;/span>';k.appendChild(d);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";k.appendChild(a);
m=a.getContext("2d");m.fillStyle="rgb("+b.fps.bg.r+","+b.fps.bg.g+","+b.fps.bg.b+")";m.fillRect(0,0,a.width,a.height);y=m.getImageData(0,0,a.width,a.height);f=document.createElement("div");f.style.backgroundColor="rgb("+Math.floor(b.ms.bg.r/2)+","+Math.floor(b.ms.bg.g/2)+","+Math.floor(b.ms.bg.b/2)+")";f.style.padding="2px 0px 3px 0px";f.style.display="none";g.appendChild(f);c=document.createElement("div");c.style.fontFamily="Helvetica, Arial, sans-serif";c.style.textAlign="left";c.style.fontSize=
"9px";c.style.color="rgb("+b.ms.fg.r+","+b.ms.fg.g+","+b.ms.fg.b+")";c.style.margin="0px 0px 1px 3px";c.innerHTML='&lt;span style="font-weight:bold">MS&lt;/span>';f.appendChild(c);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";f.appendChild(a);o=a.getContext("2d");o.fillStyle="rgb("+b.ms.bg.r+","+b.ms.bg.g+","+b.ms.bg.b+")";o.fillRect(0,0,a.width,a.height);B=o.getImageData(0,0,a.width,a.height);try{performance&amp;&amp;performance.memory&amp;&amp;performance.memory.totalJSHeapSize&amp;&amp;
(t=3)}catch(G){}h=document.createElement("div");h.style.backgroundColor="rgb("+Math.floor(b.mb.bg.r/2)+","+Math.floor(b.mb.bg.g/2)+","+Math.floor(b.mb.bg.b/2)+")";h.style.padding="2px 0px 3px 0px";h.style.display="none";g.appendChild(h);i=document.createElement("div");i.style.fontFamily="Helvetica, Arial, sans-serif";i.style.textAlign="left";i.style.fontSize="9px";i.style.color="rgb("+b.mb.fg.r+","+b.mb.fg.g+","+b.mb.fg.b+")";i.style.margin="0px 0px 1px 3px";i.innerHTML='&lt;span style="font-weight:bold">MB&lt;/span>';
h.appendChild(i);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";h.appendChild(a);q=a.getContext("2d");q.fillStyle="#301010";q.fillRect(0,0,a.width,a.height);E=q.getImageData(0,0,a.width,a.height);return{domElement:g,update:function(){u++;j=(new Date).getTime();n=j-F;z=Math.min(z,n);A=Math.max(A,n);s(B.data,Math.min(30,30-n/200*30),"ms");c.innerHTML='&lt;span style="font-weight:bold">'+n+" MS&lt;/span> ("+z+"-"+A+")";o.putImageData(B,0,0);F=j;if(j>
v+1E3){l=Math.round(u*1E3/(j-v));w=Math.min(w,l);x=Math.max(x,l);s(y.data,Math.min(30,30-l/100*30),"fps");d.innerHTML='&lt;span style="font-weight:bold">'+l+" FPS&lt;/span> ("+w+"-"+x+")";m.putImageData(y,0,0);if(t==3)p=performance.memory.usedJSHeapSize*9.54E-7,C=Math.min(C,p),D=Math.max(D,p),s(E.data,Math.min(30,30-p/2),"mb"),i.innerHTML='&lt;span style="font-weight:bold">'+Math.round(p)+" MB&lt;/span> ("+Math.round(C)+"-"+Math.round(D)+")",q.putImageData(E,0,0);v=j;u=0}}}};</pre>



<h2 class="wp-block-heading" class="wp-block-heading" id="download-sourcecode-game-tetris-html-dan-javascript">Download Sourcecode Game Tetris HTML dan JavaScript</h2>



<p>Game tetris ini dapat anda unduh lengkap file nya dalam bentuk zip. Silahkan ekstrak dan jalankan di web browser kesayangan anda. Atau anda juga dapat langsung memainkannya dengan klik tombol main.</p>



<div class="wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-16018d1d wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-red-background-color has-background wp-element-button" href="https://sc.farazinux.com/html_css/tetris/index.html">Main Game</a></div>



<div class="wp-block-button"><a class="wp-block-button__link has-vivid-purple-background-color has-background wp-element-button" href="https://farazinux.com/wp-content/uploads/2024/08/tetris.zip">Downoad</a></div>
</div>



<p>Demikianlah game tetris ini kami bagikan untuk anda semua. Happy gaming dan happy coding ya.</p>
<p>Artikel <a href="https://farazinux.com/sourcecode-game-html-javascript-tetris-menumpuk-bata/">Sourcecode Game HTML Javascript | Tetris Menumpuk Bata</a> pertama kali tampil pada <a href="https://farazinux.com">Farazinux</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://farazinux.com/sourcecode-game-html-javascript-tetris-menumpuk-bata/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Source Code Game Matematika dengan HTML, CSS dan Javascript</title>
		<link>https://farazinux.com/source-code-game-matematika-dengan-html-css-dan-javascript/</link>
					<comments>https://farazinux.com/source-code-game-matematika-dengan-html-css-dan-javascript/#respond</comments>
		
		<dc:creator><![CDATA[iPunx]]></dc:creator>
		<pubDate>Thu, 16 Feb 2023 09:10:10 +0000</pubDate>
				<category><![CDATA[Pemrograman]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sourcecode]]></category>
		<guid isPermaLink="false">https://farazinux.com/?p=3664</guid>

					<description><![CDATA[<p>Source code game matematika &#8211; Belajar matematika sering menjadi momok yang menakutkan. Namun, bagaimana apabila belajar matematika dengan game? Tentu akan lebih menarik dan menyenangkan untuk anak-anak kita. Lebih seru lagi kalau kita buat sendiri game matematika. Bagaimana caranya? Kali ini akan kami bagikan source code game matematika dengan menggunakan html, css dan javascript. Sehingga [&#8230;]</p>
<p>Artikel <a href="https://farazinux.com/source-code-game-matematika-dengan-html-css-dan-javascript/">Source Code Game Matematika dengan HTML, CSS dan Javascript</a> pertama kali tampil pada <a href="https://farazinux.com">Farazinux</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>Source code game matematika</strong> &#8211; Belajar matematika sering menjadi momok yang menakutkan. Namun, bagaimana apabila belajar matematika dengan game? Tentu akan lebih menarik dan menyenangkan untuk anak-anak kita.</p>



<p>Lebih seru lagi kalau kita buat sendiri game matematika. Bagaimana caranya? Kali ini akan kami bagikan source code game matematika dengan menggunakan html, css dan javascript. Sehingga game matematika ini dapat kita buka dengan mudah hanya dengan aplikasi web browser seperti Chrome, Mozila, Opera, Microsoft Edge atau aplikasi web browser lainnya.</p>



<p>Di bawah ini adalah source code membuat aplikasi game matematika sederhana untuk anak-anak. Pastinya anda tinggal copy paste script html, css dan javascript di bawah ini.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="source-code-game">Source Code Game</h2>



<p>Langkah pertama adalah persiapkan terlebih dahulu folder yang akan menampung tiga file. Ketiga file yang disiapkan dalam satu folder yang sama adalah index.html, style.css dan script.js.</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="1-html">1. HTML</h3>



<p>HTML (<em>Hypertext Markup Language</em>) adalah bahasa markup yang digunakan untuk membuat struktur dan konten dari halaman web. Fungsi utama <a href="https://farazinux.com/tag/html">HTML</a> adalah untuk menyediakan tag atau tanda yang mendefinisikan bagaimana sebuah dokumen web akan ditampilkan di browser.</p>



<p>Setelah kita memahami fungsi dari html, maka copy dan pastekan script di bawah ini pada file index.html yang telah kita buat seperti langkah di atas. Jangan lupa klik save untuk menyimpan script yang sudah kita pastekan.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="html" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;!DOCTYPE html>
&lt;html>
  &lt;head>
    &lt;meta charset="UTF-8">
    &lt;title>Game Matematika untuk Anak-Anak&lt;/title>
    &lt;link rel="stylesheet" href="style.css">
  &lt;/head>
  &lt;body>
    &lt;h1>Game Matematika untuk Anak-Anak&lt;/h1>
    &lt;div id="question">&lt;/div>
    &lt;form>
      &lt;input type="number" id="answer">
      &lt;button type="submit">Jawab&lt;/button>
    &lt;/form>
    &lt;div id="result">&lt;/div>
    &lt;button id="next">Selanjutnya&lt;/button>
    &lt;script src="script.js">&lt;/script>
  &lt;/body>
&lt;/html>
</pre>



<h3 class="wp-block-heading" class="wp-block-heading" id="2-css">2. CSS</h3>



<p>CSS (<em>Cascading Style Sheets</em>) adalah bahasa stylesheet yang digunakan untuk mengatur tampilan dan tata letak halaman web yang dibuat menggunakan HTML. Fungsi utama CSS adalah untuk memisahkan presentasi tampilan halaman web dari struktur dan konten halaman.</p>



<p>Dari penjelasan fungsi css di atas, maka kita memahami bahwa agar tampilan game matematika ini lebih menarik maka kita tambahkan file style.css. Silahkan adan copy dan pastekan script css di bawah ini pada file style.css.</p>



<p>Setelah kita pastekan, kemudian save (simpan) file tersebut. Anda dapat pula memodifikasi css di bawah agar lebih sesuai dengan selera anda masing-masing.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="css" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#question {
  font-size: 24px;
  margin-bottom: 20px;
}

#answer {
  font-size: 24px;
  width: 100px;
}

#result {
  font-size: 24px;
  margin-top: 20px;
}

#next {
  font-size: 24px;
  display: none;
}
</pre>



<h3 class="wp-block-heading" class="wp-block-heading" id="3-javascript">3. JavaScript</h3>



<p>JavaScript adalah bahasa pemrograman yang digunakan untuk membuat interaksi dan efek dinamis pada halaman web. Fungsi utama JavaScript adalah untuk memberikan interaksi pengguna pada halaman web dan meningkatkan pengalaman pengguna.</p>



<p>Nah, logic atau kendali dari aplikasi game matematika sederhana ini ada pada file script.js. Karena file javascript ini adalah pengendali dari aplikasi game matematika yang akan kita buat.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">let question = document.getElementById("question");
let answer = document.getElementById("answer");
let result = document.getElementById("result");
let next = document.getElementById("next");

let num1, num2, op, correctAnswer;

generateQuestion();

document.addEventListener("submit", function(event) {
  event.preventDefault();
  
  if (parseInt(answer.value) == correctAnswer) {
    result.innerHTML = "Jawaban benar!";
    next.style.display = "inline";
  } else {
    result.innerHTML = "Jawaban salah. Coba lagi!";
  }
});

document.addEventListener("click", function(event) {
  if (event.target.id == "next") {
    generateQuestion();
    answer.value = "";
    result.innerHTML = "";
    next.style.display = "none";
  }
});

function generateQuestion() {
  num1 = Math.floor(Math.random() * 10) + 1;
  num2 = Math.floor(Math.random() * 10) + 1;
  op = Math.floor(Math.random() * 2);
  
  if (op == 0) {
    question.innerHTML = num1 + " + " + num2 + " = ?";
    correctAnswer = num1 + num2;
  } else {
    question.innerHTML = num1 + " - " + num2 + " = ?";
    correctAnswer = num1 - num2;
  }
}
</pre>



<h2 class="wp-block-heading" class="wp-block-heading" id="disclaimer">Disclaimer</h2>



<p>Game matematika yang <a href="https://farazinux.com">farazinux.com</a> bagikan ini masih sangat sederhana. Silahkan anda modifikasi lebih lanjut untuk lebih seru dan menariknya permainan game matematika ini. Selamat mencoba dan happy coding.</p>
<p>Artikel <a href="https://farazinux.com/source-code-game-matematika-dengan-html-css-dan-javascript/">Source Code Game Matematika dengan HTML, CSS dan Javascript</a> pertama kali tampil pada <a href="https://farazinux.com">Farazinux</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://farazinux.com/source-code-game-matematika-dengan-html-css-dan-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
