{"id":4088,"date":"2019-11-02T08:19:23","date_gmt":"2019-11-02T07:19:23","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=4088"},"modified":"2019-11-02T16:46:11","modified_gmt":"2019-11-02T15:46:11","slug":"python-and-classic-arcade-games-pong","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/python-and-classic-arcade-games-pong\/","title":{"rendered":"Python and classic arcade games: Pong"},"content":{"rendered":"<h2>Let&#8217;s start<\/h2>\n<p>In this post you will find the whole code to make a game with Python, finally. You will find also a live coding video here (go check below).<\/p>\n<p>Let&#8217;s examine the different parts of the code.<\/p>\n<p>But, first, let&#8217;s take a look to the screen of the game:<\/p>\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/11\/pong.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4090\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/11\/pong.png\" alt=\"\" width=\"502\" height=\"532\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/11\/pong.png 502w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/11\/pong-320x339.png 320w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/a><\/p>\n<h2>Part 1: Import Pygame<\/h2>\n<p>You need pygame. I suggest you to use python 3.7 at the moment, because pygame does not works for python 3.8 (we&#8217;re at november 2019&#8230; it will work soon, so if you read this later, try to make it with 3.8, 3.9 or&#8230; 4.0!).<\/p>\n<pre class=\"lang:default decode:true\">import pygame<\/pre>\n<h2>Part 2: The global variables<\/h2>\n<p>Nothing fancy here, just variables for colors and for the positions of:<\/p>\n<ul>\n<li>player 1 (x1, y1)<\/li>\n<li>player 2 (x2, y2)<\/li>\n<li>the ball (xb, yb)<\/li>\n<\/ul>\n<p>This are useful for:<\/p>\n<ul>\n<li>moving the &#8220;sprites&#8221;<\/li>\n<li>intercept the collision among ball and sprites<\/li>\n<li>intercept when the ball goes out of the screen<\/li>\n<li>intercept when the &#8216;bar&#8217; toucht the limit of the screen<\/li>\n<\/ul>\n<p>So&#8230; they are simple variables, but make the game work.<\/p>\n<p>P.S.: there are the 2 variables for the score too and the direction of the ball (left or right, up or down&#8230; this are useful for bouncing the ball on the walls or on the sprite bars).<\/p>\n<pre class=\"lang:default decode:true \">BLACK = (0, 0, 0)\r\nRED = (255, 0, 0)\r\nGREEN = (0, 255, 0)\r\n# Coordinates p1, p2 and ball\r\nx1 = 490\r\ny1 = 250\r\nx2 = 0\r\ny2 = 250\r\nxb = 300\r\nyb = 300\r\n\r\ndbo = 'left'\r\ndbv = 'down'\r\n\r\nscorep1 = 0\r\nscorep2 = 0<\/pre>\n<h2>Part 3: Initialization of pygame and screen<\/h2>\n<p>This is for the frame rate and the screen size and the title of the screen (that will have score in it).<\/p>\n<pre class=\"lang:default decode:true\">clock = pygame.time.Clock()\r\nscreen = pygame.display.set_mode((500, 500))\r\npygame.display.set_caption(\"My game\" + \"Score player 1: \" + str(scorep1) + \" - Score player 2: \" + str(scorep2))\r\n\r\npygame.init()<\/pre>\n<h2>Part 4: Draw the ball&#8230; it&#8217;s a circle<\/h2>\n<pre class=\"lang:default decode:true \">def ball():\r\n\t\"Draw the ball\"\r\n\tglobal xb, yb\r\n\tpygame.draw.ellipse(screen, GREEN, (xb, yb, 10, 10))<\/pre>\n<p>The position of the ball uses global variables that we defined above (part 2).<\/p>\n<h2>Part 5: draw sprite 1 and 2<\/h2>\n<pre class=\"lang:default decode:true \">def sprite1(x,y):\r\n\t\"Draw Player 1\"\r\n\tpygame.draw.rect(screen, RED, (x, y, 10, 50))\r\n\r\ndef sprite2(x,y):\r\n\t\"Draw Player 2\"\r\n\tpygame.draw.rect(screen, GREEN, (x, y, 10, 50))<\/pre>\n<p>This are the bars (a couples of rectangles)<\/p>\n<h2>Move the ball please<\/h2>\n<p>The ball start moving from left and right (going up or down) and if finds a wall it bounces.<\/p>\n<pre class=\"lang:default decode:true \">def move_ball(x,y):\r\n\t\"The ball moves\"\r\n\tglobal xb, yb, dbo, dbv\r\n\tif dbo == \"left\":\r\n\t\txb -= 10\r\n\tif dbv == 'down':\r\n\t\tyb += 10\r\n\t\tif yb &gt; 490:\r\n\t\t\tdbv = 'up'\r\n\tif dbv == 'up':\r\n\t\tyb -= 10\r\n\t\tif yb &lt; 10:\r\n\t\t\tdbv = 'down'\r\n\tif dbo == \"right\":\r\n\t\txb += 10<\/pre>\n<h2>What if&#8230; collision?<\/h2>\n<p>If the ball meets a bar bounce back, else&#8230; it restart and give score to the player.<\/p>\n<pre class=\"lang:default decode:true \">def collision():\r\n\tglobal x1, y1 # the player 1 x and y (on the right)\r\n\tglobal x2, y2 # the player 2 x and y (on the left)\r\n\tglobal xb, yb # the ball x and y\r\n\tglobal dbo\r\n\tglobal scorep1, scorep2\r\n\tif dbo == \"left\":\r\n\t\tif xb &lt; 10:\r\n\t\t\tif yb &gt;= y2 and  yb &lt; y2 + 50:\r\n\t\t\t\tdbo = \"right\"\r\n\t\t\telse:\r\n\t\t\t\tpygame.draw.ellipse(screen, BLACK, (xb, yb, 10, 10))\r\n\t\t\t\tpygame.display.update()\r\n\t\t\t\txb, yb = 300, 300\r\n\t\t\t\tscorep2 += 10\r\n\t\t\t\tpygame.display.set_caption(\"My game\" + \"Score player 1: \" + str(scorep1) + \" - Score player 2: \" + str(scorep2))\r\n\telse:\r\n\t\tif xb &gt; 480:\r\n\t\t\tif yb &gt;= y1 and  yb &lt; y1 + 50:\r\n\t\t\t\tdbo = \"left\"\t\t\r\n\t\t\telse:\r\n\t\t\t\tpygame.draw.ellipse(screen, BLACK, (xb, yb, 10, 10))\r\n\t\t\t\tpygame.display.update()\r\n\t\t\t\txb, yb = 300, 300\r\n\t\t\t\tscorep1 += 10\r\n\t\t\t\tpygame.display.set_caption(\"My game\" + \"Score player 1: \" + str(scorep1) + \" - Score player 2: \" + str(scorep2))<\/pre>\n<h2>How to move the bars<\/h2>\n<p>The bar moves with a and z and k and m for player 1 and 2 respectively.<\/p>\n<pre class=\"lang:default decode:true \">def move1():\r\n\tglobal y2\r\n\tif y2 &lt;= 450:\r\n\t\tif keys[pygame.K_z]:\r\n\t\t\ty2 += 20\r\n\tif y2 &gt; 0:\r\n\t\tif keys[pygame.K_a]:\r\n\t\t\ty2 -= 20\r\n\r\ndef move2():\r\n\tglobal y1\r\n\tif y1 &lt;= 450:\r\n\t\tif keys[pygame.K_m]:\r\n\t\t\ty1 += 20\r\n\tif y1 &gt; 0:\r\n\t\tif keys[pygame.K_k]:\r\n\t\t\ty1 -= 20<\/pre>\n<h2>Finally: the loop that makes the game and ball go round<\/h2>\n<p>This is the infinite loop that moves the objects, update the screen, looks for collision and ends the game when you press the quit button of the window.<\/p>\n<pre class=\"lang:default decode:true\">loop = 1\r\nwhile loop:\r\n\tkeys = pygame.key.get_pressed()\r\n\tfor event in pygame.event.get():\r\n\t\tif event.type == pygame.QUIT:\r\n\t\t\tloop = 0\r\n\tmove1()\r\n\tmove2()\r\n\tmove_ball(xb, yb)\r\n\tball()\r\n\tsprite1(x1,y1)\r\n\tsprite2(x2,y2)\r\n\tcollision()\r\n\tpygame.display.update()\r\n\tscreen.fill((0, 0, 0))\r\n\tclock.tick(30)\r\n\r\n\r\n\r\npygame.quit()<\/pre>\n<p>Now, that we examined the parts of the game, go and watch the video with the live coding. At the end you will find the whole code.<\/p>\n<h2>The full live coding video about Pong with Python<\/h2>\n<p>So, this is the full live coding of the video, made&#8230; live. You will find some pauses in the video. The first 35 minutes are without audio. The last part is with audio.<\/p>\n<p><iframe loading=\"lazy\" title=\"Python Game: Pong with Pygame Full Live code (in part with no audio)\" width=\"747\" height=\"420\" src=\"https:\/\/www.youtube.com\/embed\/dgexGW4yvAE?feature=oembed&amp;enablejsapi=1\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2>The Whole code of Pong v. 1.0<\/h2>\n<pre class=\"lang:default decode:true\"># pong!\r\nimport pygame\r\n\r\n\r\nBLACK = (0, 0, 0)\r\nRED = (255, 0, 0)\r\nGREEN = (0, 255, 0)\r\n# Coordinates p1, p2 and ball\r\nx1 = 490\r\ny1 = 250\r\nx2 = 0\r\ny2 = 250\r\nxb = 300\r\nyb = 300\r\n\r\ndbo = 'left'\r\ndbv = 'down'\r\n\r\nscorep1 = 0\r\nscorep2 = 0\r\n\r\nclock = pygame.time.Clock()\r\nscreen = pygame.display.set_mode((500, 500))\r\npygame.display.set_caption(\"My game\" + \"Score player 1: \" + str(scorep1) + \" - Score player 2: \" + str(scorep2))\r\n\r\npygame.init()\r\n\r\ndef ball():\r\n\t\"Draw the ball\"\r\n\tglobal xb, yb\r\n\tpygame.draw.ellipse(screen, GREEN, (xb, yb, 10, 10))\r\n\r\ndef sprite1(x,y):\r\n\t\"Draw Player 1\"\r\n\tpygame.draw.rect(screen, RED, (x, y, 10, 50))\r\n\r\ndef sprite2(x,y):\r\n\t\"Draw Player 2\"\r\n\tpygame.draw.rect(screen, GREEN, (x, y, 10, 50))\r\n\r\ndef move_ball(x,y):\r\n\t\"The ball moves\"\r\n\tglobal xb, yb, dbo, dbv\r\n\tif dbo == \"left\":\r\n\t\txb -= 10\r\n\tif dbv == 'down':\r\n\t\tyb += 10\r\n\t\tif yb &gt; 490:\r\n\t\t\tdbv = 'up'\r\n\tif dbv == 'up':\r\n\t\tyb -= 10\r\n\t\tif yb &lt; 10:\r\n\t\t\tdbv = 'down'\r\n\tif dbo == \"right\":\r\n\t\txb += 10\r\n\t\r\ndef collision():\r\n\tglobal x1, y1 # the player 1 x and y (on the right)\r\n\tglobal x2, y2 # the player 2 x and y (on the left)\r\n\tglobal xb, yb # the ball x and y\r\n\tglobal dbo\r\n\tglobal scorep1, scorep2\r\n\tif dbo == \"left\":\r\n\t\tif xb &lt; 10:\r\n\t\t\tif yb &gt;= y2 and  yb &lt; y2 + 50:\r\n\t\t\t\tdbo = \"right\"\r\n\t\t\telse:\r\n\t\t\t\tpygame.draw.ellipse(screen, BLACK, (xb, yb, 10, 10))\r\n\t\t\t\tpygame.display.update()\r\n\t\t\t\txb, yb = 300, 300\r\n\t\t\t\tscorep2 += 10\r\n\t\t\t\tpygame.display.set_caption(\"My game\" + \"Score player 1: \" + str(scorep1) + \" - Score player 2: \" + str(scorep2))\r\n\telse:\r\n\t\tif xb &gt; 480:\r\n\t\t\tif yb &gt;= y1 and  yb &lt; y1 + 50:\r\n\t\t\t\tdbo = \"left\"\t\t\r\n\t\t\telse:\r\n\t\t\t\tpygame.draw.ellipse(screen, BLACK, (xb, yb, 10, 10))\r\n\t\t\t\tpygame.display.update()\r\n\t\t\t\txb, yb = 300, 300\r\n\t\t\t\tscorep1 += 10\r\n\t\t\t\tpygame.display.set_caption(\"My game\" + \"Score player 1: \" + str(scorep1) + \" - Score player 2: \" + str(scorep2))\r\n\r\n\r\n\r\ndef move1():\r\n\tglobal y2\r\n\tif y2 &lt;= 450:\r\n\t\tif keys[pygame.K_z]:\r\n\t\t\ty2 += 20\r\n\tif y2 &gt; 0:\r\n\t\tif keys[pygame.K_a]:\r\n\t\t\ty2 -= 20\r\n\r\ndef move2():\r\n\tglobal y1\r\n\tif y1 &lt;= 450:\r\n\t\tif keys[pygame.K_m]:\r\n\t\t\ty1 += 20\r\n\tif y1 &gt; 0:\r\n\t\tif keys[pygame.K_k]:\r\n\t\t\ty1 -= 20\r\n\r\nloop = 1\r\nwhile loop:\r\n\tkeys = pygame.key.get_pressed()\r\n\tfor event in pygame.event.get():\r\n\t\tif event.type == pygame.QUIT:\r\n\t\t\tloop = 0\r\n\tmove1()\r\n\tmove2()\r\n\tmove_ball(xb, yb)\r\n\tball()\r\n\tsprite1(x1,y1)\r\n\tsprite2(x2,y2)\r\n\tcollision()\r\n\tpygame.display.update()\r\n\tscreen.fill((0, 0, 0))\r\n\tclock.tick(30)\r\n\r\n\r\n\r\npygame.quit()<\/pre>\n<h2>Next version: using the mouse to move the bars<\/h2>\n<div style=\"width: 747px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-4088-1\" width=\"747\" height=\"420\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/11\/newpong2.mp4?_=1\" \/><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/11\/newpong2.mp4\">https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/11\/newpong2.mp4<\/a><\/video><\/div>\n<h3>Pygame's Platform Game<\/h3>\r\n\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-5-sounds-and-mixer\/\"><img decoding=\"async\" src=\"https:\/\/i1.wp.com\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/01\/climbercover.png?w=557&ssl=1\"\/ width=\"50%\"><\/a>\r\n<script>\r\nvar title = \"Platform Pygame\";\r\n\t\tvar links = [\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-animation-of-a-sprite-v-1-3\/\",\"Animation 1.3\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-sprite-animation-v-2-better-coding-test-it-checking-fps-on-the-screen\/\",\"Animation 1.2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-how-to-display-the-frame-rate-fps-on-the-screen\/\",\"Display Frame rate\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-sprite-animation-update\/\",\"Animation 1.1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platformer-1\/\",\"Pygame Platform Game 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-platform-game-2\/\",\"Pygame Platform 2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-3-recap-cheatsheet\/\",\"Pygame PLatform 3 - recap and some Cheat Sheet\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-4-background-and-stuffs\/\",\"Pygame Platform 4 - Background & organizing code\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-5-sounds-and-mixer\/\",\"Pygame Platform 5 - Sounds\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/platform-game-in-detail-part-1\/\",\"Game in detail part 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/map-maker-1-2\/\", \"Map maker 1.2\"]\r\n\t\t];\r\n\t\t<\/script>\r\n<script>\r\n\t\r\nif (typeof next2 != \"undefined\"){let next2 = 0;}\r\n\t\r\nnext2 = 0;\r\n\thtml = \"\";\/\/<b style='color:coral;font-size:1.2em'>Other posts about \" + title + \"<\/b><br>\";\r\nfor (address of links) \r\n{\r\n\r\n\tif (next2 == 1){\r\n\t\thtml += \"<div style='background:coral'>\";\r\n\t\thtml += \"Next link => <a href='\" + address[0] + \"'>\" + address[1] + \"<\/a>\";\r\n\t\thtml += \"<\/div><br>\";\r\n\t\tnext2 = 0;\r\n\t}\r\n\tif (address[0] == document.URL) {\r\n\t\tnext2 = 1;\r\n\t}\r\n}\r\n\r\nif (typeof next != \"undefined\") {let next = 0;}\r\nif (typeof addressStart != \"undefined\") {let addressStart = \"\";}\r\nnext = 0;\r\naddressStart = \"<a href='\";\r\nfor (address of links) {\r\n\tif (next == 1){\r\n\t\thtml += \">>>\" + addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t\tnext = 0;\r\n\t}\r\n\telse if (addressStart + address[0] != document.URL)\r\n\t{\r\n\t\thtml += addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\tnext = 1;\r\n\t\tnext_address = address[0]\r\n\t\tnext_title = address[1]\r\n\t\thtml += \"<span style='color:gray'>\" + address[1] + \"<\/span><br>\";\r\n\t}\r\n\r\n}\r\n\r\n\thtml += `<span style=\"font-size:8px\">Powered by <a href=\"https:\/\/pythonprogramming.altervista.org\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2673\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png\" alt=\"\" width=\"70\" height=\"25\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png 156w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2-150x56.png 150w\" sizes=\"auto, (max-width: 70px) 100vw, 70px\" \/>pythonprogramming.altervista.org<\/a><\/span>`\r\n\thtml = \"<div style='background:yellow'>\" + html + \"<\/div>\";\r\n\tdocument.write(html)\r\n<\/script>\r\n\r\n<h3>Other Pygame's posts<\/h3>\r\n\r\n<script>\r\nvar title = \"Pygame's Posts\"\r\nvar links = [\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platformer-1\/\",\"Platform game 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/make-a-platform-game-with-pygame-dafluffypotato\/\",\"DaFluffyPotato Platform Tutorials\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-and-classic-arcade-games-pong\/\",\"Pong Game Full\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-draws-in-colors-app-to-draw-with-pygame\/\",\"PyGameGIF 2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-draw-app-with-animation\/\",\"PyGameGIF 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pydraw-2-0-app-to-draw-gif\/\",\"PyDraw 2.0\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-drawing-2\/\",\"Draw with Pygame\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/animation-with-pygame\",\"Sprite animation 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/animation-on-pygame-2-free-characters-and-more-actions\/\",\"Sprite animation 2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/starting-with-pygame\/\",\"Starting movements with Pygame\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-3-move-sprite\/\", \"Move a Sprite\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-4-fonts\/\",\"Text and Fonts\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-animate-a-sprite\/\", \"Animate a sprite\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-and-mouse-events\/\",\"Mouse events\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pgp-aka-pygamepresentation-project\/\",\"Pygame presentation\"],\r\n\t[\"https:\/\/pythonprogramming.altervista.org\/moving-the-player-in-pygame-with-key-get_pressed\/\",\"How to use key.get_pressed()\"]\r\n]\r\n<\/script>\r\n\r\n\r\n<script>\r\n\t\r\nif (typeof next2 != \"undefined\"){let next2 = 0;}\r\n\t\r\nnext2 = 0;\r\n\thtml = \"\";\/\/<b style='color:coral;font-size:1.2em'>Other posts about \" + title + \"<\/b><br>\";\r\nfor (address of links) \r\n{\r\n\r\n\tif (next2 == 1){\r\n\t\thtml += \"<div style='background:coral'>\";\r\n\t\thtml += \"Next link => <a href='\" + address[0] + \"'>\" + address[1] + \"<\/a>\";\r\n\t\thtml += \"<\/div><br>\";\r\n\t\tnext2 = 0;\r\n\t}\r\n\tif (address[0] == document.URL) {\r\n\t\tnext2 = 1;\r\n\t}\r\n}\r\n\r\nif (typeof next != \"undefined\") {let next = 0;}\r\nif (typeof addressStart != \"undefined\") {let addressStart = \"\";}\r\nnext = 0;\r\naddressStart = \"<a href='\";\r\nfor (address of links) {\r\n\tif (next == 1){\r\n\t\thtml += \">>>\" + addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t\tnext = 0;\r\n\t}\r\n\telse if (addressStart + address[0] != document.URL)\r\n\t{\r\n\t\thtml += addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\tnext = 1;\r\n\t\tnext_address = address[0]\r\n\t\tnext_title = address[1]\r\n\t\thtml += \"<span style='color:gray'>\" + address[1] + \"<\/span><br>\";\r\n\t}\r\n\r\n}\r\n\r\n\thtml += `<span style=\"font-size:8px\">Powered by <a href=\"https:\/\/pythonprogramming.altervista.org\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2673\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png\" alt=\"\" width=\"70\" height=\"25\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png 156w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2-150x56.png 150w\" sizes=\"auto, (max-width: 70px) 100vw, 70px\" \/>pythonprogramming.altervista.org<\/a><\/span>`\r\n\thtml = \"<div style='background:yellow'>\" + html + \"<\/div>\";\r\n\tdocument.write(html)\r\n<\/script>\n","protected":false},"excerpt":{"rendered":"Live coding and code of pong classic video game with pygame and python\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/python-and-classic-arcade-games-pong\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":4091,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[527,1,564,154,191,483,113,263],"tags":[158,617,618,616,194,4,53,195],"class_list":["post-4088","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-animation","category-examples","category-free-apps","category-games","category-pygame","category-python","category-python-3-7","category-videogames","tag-games","tag-live-code","tag-live-coding","tag-pong","tag-pygame","tag-python","tag-video","tag-videogames"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":true,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=4088"}],"version-history":[{"count":5,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4088\/revisions"}],"predecessor-version":[{"id":4097,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4088\/revisions\/4097"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/4091"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=4088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=4088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=4088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}