{"id":6372,"date":"2020-07-08T08:41:06","date_gmt":"2020-07-08T06:41:06","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=6372"},"modified":"2020-07-08T08:41:06","modified_gmt":"2020-07-08T06:41:06","slug":"pygame-master-1","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/pygame-master-1\/","title":{"rendered":"Pygame Master 1"},"content":{"rendered":"<p>I think that the most hard stuff to start with Pygame is to&#8230; start, if you forgive the words game. In fact there are a lot non intuitive stuff to learn just to make a simple window without making it to crash, to load a sound in the right way, and image, not to talk about other stuff. Once you learned this, you can make very nice thing with pygame, so it&#8217;s a shame that you can be stopped by these silly stuff. For this reason, I am making this post where you can take care of all these basic stuffs at easy to have everything under control and without having to rewrite them everytime. So, here I will show you some stuff I learned and that I wished someone could have told me before.<\/p>\n<h2>It&#8217;s just a window with everything ready to go<\/h2>\n<p>The first thing we are going to do is to fix the window with the way to close it (with the x button and the escape key) and to initialize the code for the audio to be the best. I added also a class for the colors, it is not necessary, but I like to have everything organized in the right place with the right name, to get the full controll of all the code process. It is a personal choice, I know, you do not have to do it.<\/p>\n<pre class=\"lang:default decode:true\">import pygame\r\nimport sys\r\nfrom glob import glob\r\nimport os\r\n\r\n\r\nclass Colors:\r\n    BLACK = (0, 0, 0)\r\n    RED = (255, 0, 0)\r\n    GREEN = (0, 255, 0)\r\n    YELLOW = (255, 255, 0)\r\n    ORANGE = (128, 255, 0)\r\n    BLUE = (0, 0, 255)\r\n    GRAY = (255, 255, 255)\r\n\r\n\r\ndef mixer():\r\n    \"Initializing pygame and mixer\"\r\n    pygame.mixer.pre_init(44100, -16, 1, 512)\r\n    pygame.init()\r\n    pygame.mixer.quit()\r\n    pygame.mixer.init(22050, -16, 2, 512)\r\n    pygame.mixer.set_num_channels(32)\r\n\r\n\r\ndef load_sounds(directory=\"sounds\"):\r\n    \"store in sounds dic all the sound in the directory by their name\"\r\n    global sounds\r\n    if \"sounds\" not in os.listdir():\r\n        os.mkdir(\"sounds\")\r\n\r\n    lsounds = glob(f\"{directory}\\\\*.wav\")\r\n    # Dictionary with all sounds, keys are the name of wav\r\n    sounds = {}\r\n    for sound in lsounds:\r\n        sounds[sound.split(\"\\\\\")[1][:-4]] = pygame.mixer.Sound(f\"{sound}\")\r\n\r\ndef play(sound):\r\n    \"It plays the sounds by the name of the file without .wav\"\r\n    global sounds\r\n    try:\r\n        pygame.mixer.Sound.play(sounds[sound])\r\n    except KeyError:\r\n        print(f\"------\\nAlert!\\nfile '{sound}.wav' not found in 'sounds'\\n------\")\r\n        print(\"Check the name of the file in the sounds folder\")\r\n\r\n\r\ndef create_fonts(family=\"Arial\", size=24):\r\n    return pygame.font.SysFont(family, size)\r\n\r\n\r\ndef init(size=(400, 400), name=\"Game\"):\r\n    \"The screen and the clock\"\r\n    global screen, clock\r\n    screen = pygame.display.set_mode((400, 400))\r\n    pygame.display.set_caption(\"Game\")\r\n    clock = pygame.time.Clock()\r\n    mixer()\r\n    load_sounds()\r\n\r\n\r\ndef event_listener():\r\n    \"Intercept the user inputs\"\r\n    for event in pygame.event.get():\r\n        k = pygame.KEYDOWN\r\n        e = pygame.K_ESCAPE\r\n        escape = event.type == k and event.key == e\r\n        if event.type == pygame.QUIT or escape:\r\n            pygame.quit()\r\n            sys.exit()\r\n\r\n\r\ndef main():\r\n    \"Takes care of the process inside the main window\"\r\n    while 1:\r\n        # Intercept user inputs\r\n        event_listener()\r\n        pygame.display.update()\r\n        clock.tick(360)\r\n\r\n\r\n# ====================== Start ======\r\n''' This initialize pygame, the mixer, load the sounds\r\n'''\r\ninit(size=(400, 400), name=\"Game\")\r\nplay(\"over2\")\r\n# this opens the window\r\nmain()\r\n\r\n<\/pre>\n<p>So the while loop takes care of what is goin&#8217; on on the window. I&#8217;ve put outside the input control (event_listener()) to mantain the while loop clean and easy to manage, because it&#8217;s there that all the things starts to happen.<\/p>\n<h2><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/001-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6382\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/001-1.png\" alt=\"\" width=\"800\" height=\"600\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/001-1.png 800w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/001-1-320x240.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/001-1-768x576.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a> <a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/002-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6383\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/002-2.png\" alt=\"\" width=\"800\" height=\"600\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/002-2.png 800w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/002-2-320x240.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/002-2-768x576.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a> <a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/003.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6384\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/003.png\" alt=\"\" width=\"800\" height=\"600\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/003.png 800w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/003-320x240.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/07\/003-768x576.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/h2>\n<h2>What now?<\/h2>\n<p>In the next post we will see how to take care of the graphic part and the fonts.<\/p>\n<p>1.1 &#8211; Pong the father of Arkanoid<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"jFgUxvfDYj\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/pong-v-1-0-pygame-example\/\">Pong v. 1.0 &#8211; Pygame example<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;Pong v. 1.0 &#8211; Pygame example&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/pong-v-1-0-pygame-example\/embed\/#?secret=jFgUxvfDYj\" data-secret=\"jFgUxvfDYj\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>1.2 &#8211; Starting arkanoid&#8230; from pong<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"SJ0esLAFSq\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-lets-make-it-better\/\">Arkanoid&#8230; let&#8217;s make it better&#8230;<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;Arkanoid&#8230; let&#8217;s make it better&#8230;&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-lets-make-it-better\/embed\/#?secret=SJ0esLAFSq\" data-secret=\"SJ0esLAFSq\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>1.3 &#8211; Adding background<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"Jk01pOYbXJ\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkapygame-1-3-adding-a-background\/\">ArkaPyGame 1.3 &#8211; Adding a background<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;ArkaPyGame 1.3 &#8211; Adding a background&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkapygame-1-3-adding-a-background\/embed\/#?secret=Jk01pOYbXJ\" data-secret=\"Jk01pOYbXJ\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>1.4 &#8211; Collision detection<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"f6QdZb7bQ4\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkapygame-1-4-collision-detected\/\">ArkaPygame 1.4 &#8211; Collision detected<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;ArkaPygame 1.4 &#8211; Collision detected&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkapygame-1-4-collision-detected\/embed\/#?secret=f6QdZb7bQ4\" data-secret=\"f6QdZb7bQ4\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>1.5 &#8211; Bricks collisions<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"WfHC04cGGC\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-in-pygame-part-5\/\">Arkanoid in pygame part 5<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;Arkanoid in pygame part 5&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-in-pygame-part-5\/embed\/#?secret=WfHC04cGGC\" data-secret=\"WfHC04cGGC\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>1.6 &#8211; Still on Collisions<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"RUPVoaKX93\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-part-6-still-on-bricks-collition\/\">Arkanoid part 6 &#8211; Still on bricks collision<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;Arkanoid part 6 &#8211; Still on bricks collision&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-part-6-still-on-bricks-collition\/embed\/#?secret=RUPVoaKX93\" data-secret=\"RUPVoaKX93\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>1.7 &#8211; Fixed strange bouncing<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"p5ihYc0ykR\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-1-7-fixed-strange-bouncing\/\">Arkanoid 1.7 &#8211; Fixed strange bouncing<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;Arkanoid 1.7 &#8211; Fixed strange bouncing&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-1-7-fixed-strange-bouncing\/embed\/#?secret=p5ihYc0ykR\" data-secret=\"p5ihYc0ykR\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>1.8 &#8211; How to destroy the bricks<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"ez62WKNVzp\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-1-8-first-stage-almost-complete-destroy-bricks\/\">Arkanoid 1.8 &#8211; First stage almost complete: destroy bricks<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;Arkanoid 1.8 &#8211; First stage almost complete: destroy bricks&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-1-8-first-stage-almost-complete-destroy-bricks\/embed\/#?secret=ez62WKNVzp\" data-secret=\"ez62WKNVzp\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>1.9 &#8211; More levels<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"gjJdtcfdqU\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-1-9-ore-stages\/\">Arkanoid 1.9 &#8211; more stages<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;Arkanoid 1.9 &#8211; more stages&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-1-9-ore-stages\/embed\/#?secret=gjJdtcfdqU\" data-secret=\"gjJdtcfdqU\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>2.1 &#8211; Infinite level generator<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"swsXkH7Bhd\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-2-0-infinite-levels\/\">Arkanoid 2.0 &#8211; infinite levels<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;Arkanoid 2.0 &#8211; infinite levels&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-2-0-infinite-levels\/embed\/#?secret=swsXkH7Bhd\" data-secret=\"swsXkH7Bhd\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>2.3 &#8211; Sounds and faster frame rate tecnique<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"w4of9orsai\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkapygame-2-1-arkanoid-like-game-made-with-pygame\/\">ArkaPyGame 2.1 &#8211; Arkanoid like game made with Pygame<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;ArkaPyGame 2.1 &#8211; Arkanoid like game made with Pygame&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkapygame-2-1-arkanoid-like-game-made-with-pygame\/embed\/#?secret=w4of9orsai\" data-secret=\"w4of9orsai\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>2.5 &#8211; New nicer levels simmetric and in color and menus<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"Jhw8QkHTvy\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-pygame-2-5-new-levels-and-menu\/\">Arkanoid-Pygame 2.5 &#8211; New levels and menu<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;Arkanoid-Pygame 2.5 &#8211; New levels and menu&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-pygame-2-5-new-levels-and-menu\/embed\/#?secret=Jhw8QkHTvy\" data-secret=\"Jhw8QkHTvy\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>2.6 &#8211; Keyboard control<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"FlkpJjUPRU\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkagame-2-6-adding-keyboard-commands\/\">ArkaGame 2.6 &#8211; Adding keyboard commands<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;ArkaGame 2.6 &#8211; Adding keyboard commands&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkagame-2-6-adding-keyboard-commands\/embed\/#?secret=FlkpJjUPRU\" data-secret=\"FlkpJjUPRU\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>2.7 &#8211; Mouse exclusive control<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"SaqPXKjTR5\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-2-7-with-pygame-mouse-control\/\">Arkanoid 2.7 with Pygame &#8211; Mouse control<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;Arkanoid 2.7 with Pygame &#8211; Mouse control&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/arkanoid-2-7-with-pygame-mouse-control\/embed\/#?secret=SaqPXKjTR5\" data-secret=\"SaqPXKjTR5\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>2.xxx &#8211; Tiny version<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"LUiEfHdQtC\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/tinyarka-mini-version-of-arkanoid-with-pygame\/\">TinyArka &#8211; &#8220;Mini&#8221; version of Arkanoid with pygame<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;TinyArka &#8211; &#8220;Mini&#8221; version of Arkanoid with pygame&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/tinyarka-mini-version-of-arkanoid-with-pygame\/embed\/#?secret=LUiEfHdQtC\" data-secret=\"LUiEfHdQtC\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>5.0 &#8211; Arkagame: 5 different versions<\/p>\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"pUPvF3UNth\"><p><a href=\"https:\/\/pythonprogramming.altervista.org\/breakout-arkanoid-5-versions-in-one-pygame\/\">Breakout \/ Arkanoid &#8211; 5 versions in one (pygame)<\/a><\/p><\/blockquote>\r\n<p><iframe loading=\"lazy\" title=\"&#8220;Breakout \/ Arkanoid &#8211; 5 versions in one (pygame)&#8221; &#8212; python programming\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"https:\/\/pythonprogramming.altervista.org\/breakout-arkanoid-5-versions-in-one-pygame\/embed\/#?secret=pUPvF3UNth\" data-secret=\"pUPvF3UNth\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\r\n<p>Github repository<br \/>\r\nhttps:\/\/github.com\/formazione\/arkapygame<\/p>\n<!-- se vuoi mettere un testo scorrevole\r\n[hoops name=\"typeWriterGen\"]\r\n\r\npoi metti un id diverso per ogni testo nella stessa pagina\r\n\r\n<div id=\"div01\">\r\n<script>\r\n\r\ntypeWriterGen(\"div01\",\"Esempio di testo scorrevole\");\r\n<\/script>\r\n\r\n-->\r\n<style>\r\n.avatar {\r\n  vertical-align: middle;\r\n  width: 100px;\r\n  height: 100px;\r\n  border-radius: 50%;\r\n}\r\n<\/style>\r\n\r\n<hr>\r\n\r\n<!-- NEWSLETTER LINK -->\r\n<a href=\"https:\/\/docs.google.com\/forms\/d\/e\/1FAIpQLSf7TniIPCWHDzCSGh2dYZaCwDvi9yLKS5ovFdKuK1sdfOvwEg\/viewform\">\r\n<img decoding=\"async\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2023\/08\/image-13.png\" class=\"avatar\">\r\nSubscribe to the <b>newsletter<\/b> for updates<\/a><br>\r\n\r\n<!-- TKINTER TEMPLATE LINK -->\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/tkinter-templates\/\">\r\n<img decoding=\"async\" src=\"https:\/\/i0.wp.com\/pythonprogramming.altervista.org\/wp-content\/uploads\/2023\/07\/image-26.png\" class=\"avatar\">\r\nTkinter templates<\/a><br>\r\n\r\n<!-- MY AVATAR PUT A LINK TO YOUTUBE CHANNEL-->\r\n<iframe loading=\"lazy\" frameborder=\"0\" src=\"https:\/\/itch.io\/embed\/711828\" width=\"552\" height=\"167\"><a href=\"https:\/\/pythonprogrammi.itch.io\/pysnake\">PySnake by PythonProgrammi<\/a><\/iframe>\r\n<br>\r\n<style>\r\n.avatar {\r\n  vertical-align: middle;\r\n  width: 100px;\r\n  height: 100px;\r\n  border-radius: 50%;\r\n}\r\n<\/style>\r\n\r\n\r\n<a href=\"https:\/\/www.youtube.com\/channel\/UCzbxq5e9gLiY-je2-br1rvg\">\r\n\t<img decoding=\"async\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/10\/avatar64x64.png\" alt=\"Avatar\" class=\"avatar\">\r\n\t My youtube channel<\/a><br>\r\n\r\n<br>\r\n\r\nTwitter: <a href=\"https:\/\/twitter.com\/pythonprogrammi\">@pythonprogrammi - python_pygame<\/a>\r\n<h3>Claude's Games<\/h3>\r\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/random-daily-game-1-arkanoid\/\">Arkanoid<\/a><br>\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/platform-2d-with-pygame-made-with-claude\/\">Platform 2d<\/a><\/p> <!-- videogames made with claude -->\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/artifacts-games-day-1-memory-game\/\">1. Memory game<\/a>\r\n<h4>Videos<\/h4>\r\n<a href=\"https:\/\/youtu.be\/ciLjWWw5pLY\">Speech recognition game<\/a>\r\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":"How to master pygame starts here.\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/pygame-master-1\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":6385,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1,191],"tags":[194,4],"class_list":["post-6372","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-examples","category-pygame","tag-pygame","tag-python"],"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\/6372","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=6372"}],"version-history":[{"count":5,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/6372\/revisions"}],"predecessor-version":[{"id":6386,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/6372\/revisions\/6386"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/6385"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=6372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=6372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=6372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}