{"id":286968,"date":"2017-05-28T23:15:02","date_gmt":"2017-05-28T19:15:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=286968"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=286968","title":{"rendered":"\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u044b\u0448\u044c\u044e \u043a\u0430\u043a \u0432 Agar.io \u043d\u0430 Phaser.js"},"content":{"rendered":"<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0425\u0430\u0431\u0440! \u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0446\u0435\u043b\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433 \u0438\u0433\u0440\u044b <a href=\"http:\/\/agar.io\">Agar.io<\/a>. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0442\u0435\u0440\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438 \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u0441\u0435\u0431\u0435 \u0436\u0438\u0437\u043d\u044c \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0449\u0435 \u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0433\u0440\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0434\u0432\u0438\u0436\u043e\u043a \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0433\u0440.<\/p>\n<p>  \u041c\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 <a href=\"http:\/\/phaser.io\">phaser.js<\/a>, \u0442\u0430\u043a \u043a\u0430\u043a, \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043f\u043e \u043d\u0435\u043c\u0443 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u0438 \u043e\u043d \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <a href=\"http:\/\/www.pixijs.com\/\">Pixi.js<\/a>.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u044b\u0448\u044c\u044e. \u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: <br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 300px; position: relative;\"><iframe src=\"https:\/\/codepen.io\/Dmitry_Rudenko\/embed\/preview\/XRGeXz?height=300&amp;slug-hash=XRGeXz&amp;default-tabs=js,result&amp;host=https:\/\/codepen.io&amp;embed-version=2\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u0418\u0442\u0430\u043a, \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435: <\/p>\n<pre><code class=\"javascript\">var width = window.innerWidth; \/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0448\u0438\u0440\u0438\u043d\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b var height = window.innerHeight; \/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u044b\u0441\u043e\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b  var game = new Phaser.Game(width, height, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); \/\/\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c canvas \u043d\u0430 phaser, \u0441 \u0432\u044b\u0441\u043e\u0442\u043e\u0439 \u0438 \u0448\u0438\u0440\u0438\u043d\u043e\u0439 \u044d\u043a\u0440\u0430\u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. var player; \/\/ \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0430\u044f \u0437\u0430 \u0442\u0430\u043a\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u0430\u043a \u044e\u043d\u0438\u0442. var bg; \/\/\u0444\u043e\u043d \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0435\u0442\u043a\u0430 <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f preload() \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0430\u044f \u0437\u0430 \u043f\u0440\u0435\u0434\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0432\u0441\u0435\u0445 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0443 \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0442\u043a\u0430:<\/p>\n<pre><code class=\"javascript\">function preload() {     game.load.image('background', 'img\/grid.png'); }<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f create() \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0448\u0435 \u0445\u043e\u043b\u0441\u0442 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043d\u0430 \u043d\u0435\u043c: <\/p>\n<pre><code class=\"javascript\">function create() {     game.time.advancedTiming = true;      game.time.desiredFps = 60; \/\/\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e fps     game.time.slowMotion = 2.0; \/\/\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0435 \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 0, \u0443 \u043d\u0430\u0441 2, \u0447\u0442\u043e\u0431\u044b \u044e\u043d\u0438\u0442 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0440\u0435\u0437\u0432\u043e \u043c\u0435\u0442\u0430\u043b\u0441\u044f \u043f\u043e \u043f\u043e\u043b\u044e     bg = game.add.tileSprite(0, 0, 8000, 8000, 'background'); \/ \u0444\u043e\u043d \u0441\u0435\u0442\u043a\u0430     game.world.setBounds(0, 0, 8000, 8000); \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u043a\u0430\u0440\u0442\u044b     game.stage.backgroundColor = &quot;#000&quot;; \/\/ \u0446\u0432\u0435\u0442 \u0444\u043e\u043d\u0430     var bmd = generateCircle('red', 20); \/ \u0440\u0438\u0441\u0443\u0435\u043c \u043a\u0440\u0443\u0433 \u0441\u0430\u043c\u043e\u043f\u0438\u0441\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0434\u0438\u0430\u043c\u0435\u0442\u0440\u043e\u043c 20px     player = game.add.sprite(game.world.centerX, game.world.centerY, bmd); \/\/\u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044e\u043d\u0438\u0442\u0430     game.physics.enable(player, Phaser.Physics.ARCADE); \/\/ \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0432\u0438\u0436\u043e\u043a ARCADE(\u043e\u043d \u0432\u0441\u0442\u0440\u043e\u0435\u043d \u0432 phaser.js)          game.camera.follow(player);   \/\/\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0436\u0435\u043d\u0438\u0435 \u043a\u0430\u043c\u0435\u0440\u044b \u0437\u0430 \u0438\u0433\u0440\u043e\u043a\u043e\u043c } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 upload() \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0438 \u043c\u044b\u0448\u044c\u044e:<\/p>\n<pre><code class=\"javascript\">function update() {     game.input.addMoveCallback(function(){         game.physics.arcade.moveToPointer(player, 400); \/\/\u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 ARCADE \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043b\u0435\u0436\u0435\u043d\u0438\u044f \u044e\u043d\u0438\u0442\u0430 \u0437\u0430 \u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c     }); }<\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f render() \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438: <\/p>\n<pre><code class=\"javascript\">function render() {     game.debug.cameraInfo(game.camera, 32, 32);  \/\/\u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u043d\u0444\u0443 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439 \u043a\u0430\u043c\u0435\u0440\u044b } <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0438\u0441\u0443\u044e\u0449\u0430\u044f \u043a\u0440\u0443\u0433:<\/p>\n<pre><code class=\"javascript\">function generateCircle(color, size){          var bitmapSize = size * 2         var bmd = this.game.add.bitmapData(bitmapSize, bitmapSize);         bmd.ctx.fillStyle = color;         bmd.ctx.beginPath();         bmd.ctx.arc(size, size, size, 0, Math.PI*2, true);         bmd.ctx.closePath();         bmd.ctx.fill();         return bmd;     } <\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435, \u0443 \u043d\u0430\u0441 \u0433\u043e\u0442\u043e\u0432\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u0432 agar.io. \u0415\u0449\u0451 \u0440\u0430\u0437 <a href=\"https:\/\/codepen.io\/Dmitry_Rudenko\/full\/XRGeXz\/\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a> \u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>  \u0422\u0430\u043c \u043f\u043e\u043a\u0430 \u043d\u0435\u0442 \u0433\u0440\u0430\u043d\u0438\u0446 \u043a\u0430\u0440\u0442\u044b \u0438 \u0433\u0440\u0430\u043d\u0443\u043b \u043f\u043e\u0435\u0434\u0430\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0433\u0440\u043e\u043a \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e \u0445\u043e\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0433\u0440\u0443 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u043d\u0430 node.js.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/329652\/\"> https:\/\/habrahabr.ru\/post\/329652\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0425\u0430\u0431\u0440! \u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0446\u0435\u043b\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433 \u0438\u0433\u0440\u044b <a href=\"http:\/\/agar.io\">Agar.io<\/a>. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0442\u0435\u0440\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438 \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u0441\u0435\u0431\u0435 \u0436\u0438\u0437\u043d\u044c \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0449\u0435 \u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0433\u0440\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0434\u0432\u0438\u0436\u043e\u043a \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0433\u0440.<\/p>\n<p>  \u041c\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 <a href=\"http:\/\/phaser.io\">phaser.js<\/a>, \u0442\u0430\u043a \u043a\u0430\u043a, \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043f\u043e \u043d\u0435\u043c\u0443 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u0438 \u043e\u043d \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <a href=\"http:\/\/www.pixijs.com\/\">Pixi.js<\/a>.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u044b\u0448\u044c\u044e. \u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-286968","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286968"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286968\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}