{"id":203082,"date":"2013-12-21T21:00:02","date_gmt":"2013-12-21T17:00:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=203082"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=203082","title":{"rendered":"<span class=\"post_title\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0438\u0437\u0443\u0447\u0430\u0442\u044c Love2d<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/1c1\/0aa\/f56\/1c10aaf5655a3c0070f7c21414c242f4.png\"\/><br \/>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c <a href=\"http:\/\/habrahabr.ru\/post\/202540\/\">\u043f\u043e\u0441\u0442\u0435<\/a> \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043a\u0430\u043a \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438, \u0432\u0440\u043e\u0434\u0435 \u043a\u0430\u043a, \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443 \u0432 love2d. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u043c\u0435\u0439\u043a\u0443, \u0432\u0441\u0435\u043c, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<a name=\"habracut\"><\/a> \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Sublime Text 2, \u043a\u0430\u043a \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u043b\u044f love \u044f \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437, \u043d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0431\u0430\u0433, \u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0440\u0438 \u043b\u0438\u0448\u043d\u0438\u0445 \u0441\u0442\u0440\u043e\u043a\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e: \u0420\u044f\u0434\u043e\u043c \u0441 main.lua, \u0432 \u043a\u043e\u0440\u043d\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e conf.lua. \u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0438\u0433\u0440\u044b. \u0412 \u043d\u0435\u043c \u043f\u0438\u0448\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"lua\">function love.conf(t)--\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 love \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0430\u0440\u0442\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f     io.stdout:setvbuf(&quot;no&quot;)--\u0418\u0437-\u0437\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 Sublime Text, \u0442\u043e\u0447\u043d\u0435\u0435 \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043a\u0438 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e,                             --\u0438\u043d\u0430\u0447\u0435 \u0432\u0441\u0435 \u0447\u0442\u043e \u043c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e print(str) \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0438\u0433\u0440\u044b. end <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"http:\/\/www.love2d.org\/wiki\/Config_Files_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9)\">\u0437\u0434\u0435\u0441\u044c<\/a>, \u0438 <a href=\"http:\/\/www.love2d.org\/wiki\/conf\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h5>\u041d\u0443 \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0434<\/h5>\n<p>  \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:  <\/p>\n<pre><code class=\"lua\">local apple, snake, direction, width, height, delay  function love.load() \twidth = love.graphics.getWidth() \/ 10\t\t\t--\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 \u043e\u043a\u043d\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \tprint(&quot;Width &quot; .. width)          \t\t\t\t--\u0434\u0435\u0431\u0430\u0433 \u0432\u044b\u0432\u043e\u0434 \theight = love.graphics.getHeight() \/10\t\t\t--\u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043d\u043e \u0441 \u0432\u044b\u0441\u043e\u0442\u043e\u0439 \tprint(&quot;Height &quot; .. height) \tapple = { x = math.random() % width;\t\t\t--\u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u044f\u0431\u043b\u043e\u043a\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 \t\t\t  y = math.random() % height; } \t\t        --\u0438 Y.. \tsnake = { } \t\t\t\t\t\t--\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u0437\u043c\u0435\u0439\u043a\u0438 \tfor i = 1, 10 do \t\t\t\t\t\t--\u043f\u0435\u0440\u0432\u044b\u0435 10 \u043a\u043b\u0435\u0442\u043e\u043a \u043d\u0430\u0434\u043e \u0441 \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \t\tpoint = { x = 10;\t\t\t\t\t--\u0438 \u0441\u043d\u043e\u0432\u0430 X.. \t\t\t\t  y = 10 + i; }\t\t\t\t\t--\u0438 Y.. \t\ttable.insert(snake, point)\t\t\t\t--\u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \tend \tdirection = &quot;up&quot;\t\t\t\t\t\t--\u0437\u043c\u0435\u0439\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043a\u0443\u0434\u0430-\u0442\u043e \u043f\u043e\u043b\u0437\u0442\u0438 \tdelay = 0\t\t\t\t\t\t\t--\u0437\u043c\u0435\u0439\u043a\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043d\u0435\u0440\u0432\u043d\u043e\u0439 end <\/code><\/pre>\n<p>  \u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u0432\u0441\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043b, \u0434\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u0445\u043e\u0442\u044c \u0440\u0430\u0437 \u043f\u0438\u0441\u0430\u043b \u0437\u043c\u0435\u0439\u043a\u0443 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0432\u0441\u0435.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0437\u043c\u0435\u0439\u043a\u0443 (\u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u0431\u0435\u0437 \u044f\u0431\u043b\u043e\u043a\u0430);  <\/p>\n<pre><code class=\"lua\">function love.draw() \tlove.graphics.setBackgroundColor(0, 0, 0)\t\t        --\u0447\u0438\u0441\u0442\u0438\u043c \u044d\u043a\u0440\u0430\u043d \tfor k, v in pairs(snake) do \t\t\t        --\u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u0436\u0434\u0443\u044e \u043a\u043b\u0435\u0442\u043a\u0443 \t\tlove.graphics.rectangle(&quot;fill&quot;, v.x * 10, v.y * 10, 10, 10) \tend end <\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e:<br \/>  1) \u0410 \u043a\u0430\u043a\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u043c\u0435\u0439\u043a\u0430<br \/>  2) (\u041c\u0435\u043d\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439) \u0427\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f love.graphics.rectangle?<\/p>\n<p>  \u041e\u0442\u0432\u0435\u0442\u044b:<\/p>\n<p>  1) \u041e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u043b\u044b\u043c, \u044d\u0442\u043e\u0442 \u0446\u0432\u0435\u0442 \u0441\u0442\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0438\u0448\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c love.draw(). \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u044d\u0442\u043e\u0442 \u0446\u0432\u0435\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u0432\u043e\u0442 \u043c\u0435\u0442\u043e\u0434\u043e\u043c:  <\/p>\n<pre><code class=\"lua\">love.graphics.setColor(0, 0, 255)\t\t\t\t--\u0437\u043c\u0435\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u043d\u0435\u0439 <\/code><\/pre>\n<p>  \u0423 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u043d\u043e \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0439 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u2014 \u044d\u0442\u043e \u0430\u043b\u044c\u0444\u0430 \u0446\u0432\u0435\u0442\u0430. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u043e\u0442 <a href=\"https:\/\/love2d.org\/wiki\/love.graphics.setColor\">\u0437\u0434\u0435\u0441\u044c<\/a>.<br \/>  2) \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0438\u0441\u0443\u0435\u0442 \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0446\u0432\u0435\u0442\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c <a href=\"https:\/\/love2d.org\/wiki\/love.graphics.setColor\">\u044d\u0442\u043e\u0439<\/a> \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u2014 \u0440\u0435\u0436\u0438\u043c \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u00abfine\u00bb \u0438\u043b\u0438 \u00abline\u00bb. \u0412\u0442\u043e\u0440\u043e\u0439 \u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0427\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0439 \u0438 \u043f\u044f\u0442\u044b\u0439 \u2014 \u0440\u0430\u0437\u043c\u0435\u0440\u044b, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0432\u043e\u0442 <a href=\"https:\/\/love2d.org\/wiki\/love.graphics.rectangle\">\u0442\u0443\u0442<\/a>.<\/p>\n<h6>\u041c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c<\/h6>\n<p>  \u0423\u0440\u0430! \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u043f\u043e\u0434\u0432\u0438\u0436\u043d\u0430\u044f \u0437\u043c\u0435\u0439\u043a\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 <s>\u043f\u043e\u0442\u044b\u043a\u0430\u0435\u043c \u0435\u0435<\/s> \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u043e, \u043d\u0430\u043f\u0438\u0448\u0435\u043c Update \u0444\u0443\u043d\u043a\u0446\u0438\u044e:  <\/p>\n<pre><code class=\"lua\">function love.update(dt) \tif delay % 2 == 0 then\t\t\t\t\t\t--\u043b\u0435\u0447\u0438\u043c \u043d\u0435\u0440\u0432\u044b \t\ttable.remove(snake, table.getn(snake)) \t\t\t\t--\u0443\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u043e  \t\tif direction == &quot;up&quot; then\t\t\t\t\t--\u043d\u0443 \u0442\u0443\u0442 \u0432\u0440\u043e\u0434\u0435 \u0432\u0441\u0435 \u044f\u0441\u043d\u043e, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \t\t\ttable.insert(snake, 1, { x = snake[1].x; \t\t\t\t\t\t\t\t\t y = (snake[1].y - 1) % height; }) \t\telseif direction == &quot;down&quot; then \t\t\ttable.insert(snake, 1, { x = snake[1].x; \t\t\t\t\t\t\t\t\t y = (snake[1].y + 1) % height; }) \t\telseif direction == &quot;left&quot; then \t\t\ttable.insert(snake, 1, { x = (snake[1].x - 1) % width; \t\t\t\t\t\t\t\t\t y = snake[1].y; }) \t\telse \t\t\ttable.insert(snake, 1, { x = (snake[1].x + 1) % width; \t\t\t\t\t\t\t\t\t y = snake[1].y; }) \t\tend \tend \tdelay = delay + 1 end <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u0430\u044f \u0437\u043c\u0435\u0439\u043a\u0430, \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043d\u0435 \u0442\u043e, \u0447\u0435\u0433\u043e \u043c\u044b \u0434\u043e\u0431\u0438\u0432\u0430\u0435\u043c\u0441\u044f, \u0442\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u043b\u0430\u0441\u0442\u0438:  <\/p>\n<pre><code class=\"lua\">function love.keypressed(key)\t\t\t\t\t\t--\u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430\u0436\u0430\u0442\u0430 \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t--\u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0440\u0435\u043c\u043d\u043e, \u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \tif key == &quot;up&quot; then \t\tdirection = &quot;up&quot; \telseif key == &quot;down&quot; then \t\tdirection = &quot;down&quot; \telseif key == &quot;left&quot; then \t\tdirection = &quot;left&quot; \telseif key == &quot;right&quot; then \t\tdirection = &quot;right&quot; \telseif key == &quot;escape&quot; then \t\tlove.event.quit() \tend end <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u043c, \u043d\u043e \u0433\u0434\u0435 \u0446\u0435\u043b\u044c? \u0414\u043e\u0431\u0430\u0432\u0438\u043c-\u0436\u0435 \u044f\u0431\u043b\u043e\u043a:<br \/>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044f\u0431\u043b\u043e\u043a\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c, \u043d\u043e \u043c\u044b \u0435\u0433\u043e \u043d\u0435 \u0440\u0438\u0441\u0443\u0435\u043c, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u0432 love.draw():  <\/p>\n<pre><code class=\"lua\">love.graphics.setColor(255, 255, 0)\t\t\t\t\t--\u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0433\u043e\u043b\u0434 love.graphics.rectangle(&quot;fill&quot;, apple.x * 10, apple.y * 10, 10, 10) <\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0440\u043e\u0441\u0442\u0438:  <\/p>\n<pre><code class=\"lua\">if delay % 2 == 0 then\t\t\t\t\t\t\t--\u043b\u0435\u0447\u0438\u043c \u043d\u0435\u0440\u0432\u044b \tif apple.x == snake[1].x and \t\tapple.y == snake[1].y then \t\tapple = { x = math.random(width);\t\t                --\u0432\u043e\u0442 \u0438 \u043f\u043e\u0435\u043b\u0438, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 \t\t\t\t  y = math.random(height); } \t                        --\u0438 Y.. \telse \t\t\t\t\t\t\t\t--\u043d\u0435 \u0441\u0440\u0430\u0437\u0443 \u044f\u0441\u043d\u043e, \u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \t\ttable.remove(snake, table.getn(snake)) \t\t\t\t--\u0443\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \tend  \tif direction == &quot;up&quot; then\t\t\t\t\t\t--\u043d\u0443 \u0442\u0443\u0442 \u0432\u0440\u043e\u0434\u0435 \u0432\u0441\u0435 \u044f\u0441\u043d\u043e, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \t\ttable.insert(snake, 1, { x = snake[1].x; \t\t\t\t\t\t\t\t y = (snake[1].y - 1) % height; }) \telseif direction == &quot;down&quot; then \t\ttable.insert(snake, 1, { x = snake[1].x; \t\t\t\t\t\t\t\t y = (snake[1].y + 1) % height; }) \telseif direction == &quot;left&quot; then \t\ttable.insert(snake, 1, { x = (snake[1].x - 1) % width; \t\t\t\t\t\t\t\t y = snake[1].y; }) \telse \t\ttable.insert(snake, 1, { x = (snake[1].x + 1) % width; \t\t\t\t\t\t\t\t y = snake[1].y; }) \tend end delay = delay + 1 <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0437\u0430\u0435\u043c, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c, \u043f\u043e\u0435\u0434\u0430\u0435\u043c, \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e!<\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435.<br \/>  <a href=\"http:\/\/www.mediafire.com\/download\/2gnuohui01rljlm\/snake(2).rar\">\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438, \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0430\u0434\u0434\u043e\u043d\u043e\u043c\u043e\u043c.<\/a><\/p>\n<p>  \u0411\u0443\u0434\u0443 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d \u0437\u0430 \u043b\u044e\u0431\u044b\u0435 \u043e\u0442\u0437\u044b\u0432\u044b (:    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/203082\/\"> http:\/\/habrahabr.ru\/post\/203082\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/1c1\/0aa\/f56\/1c10aaf5655a3c0070f7c21414c242f4.png\"\/><br \/>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c <a href=\"http:\/\/habrahabr.ru\/post\/202540\/\">\u043f\u043e\u0441\u0442\u0435<\/a> \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043a\u0430\u043a \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438, \u0432\u0440\u043e\u0434\u0435 \u043a\u0430\u043a, \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443 \u0432 love2d. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u043c\u0435\u0439\u043a\u0443, \u0432\u0441\u0435\u043c, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\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-203082","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/203082","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=203082"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/203082\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=203082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=203082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=203082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}