{"id":11237,"date":"2021-05-11T17:59:31","date_gmt":"2021-05-11T08:59:31","guid":{"rendered":"https:\/\/kusakarism.info\/?p=11237"},"modified":"2021-07-28T20:16:37","modified_gmt":"2021-07-28T11:16:37","slug":"breakout","status":"publish","type":"post","link":"https:\/\/kusakarism.info\/?p=11237","title":{"rendered":"\u3010Python\u30111\u6642\u9593\u3067\u4f5c\u308b\u300c\u30d6\u30ed\u30c3\u30af\u304f\u305a\u3057\u300d\uff0f\u521d\u5fc3\u8005\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5b66\u7fd2\u3002"},"content":{"rendered":"<h2>\u8ab0\u306b\u3067\u3082\u3067\u304d\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0<\/h2>\n<p><span style=\"font-size: 14pt; color: #ff0000;\"><strong>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306a\u3093\u3066\u3001\u8ab0\u306b\u3060\u3063\u3066\u7c21\u5358\u306b\u3067\u304d\u308b\u3082\u306e\u306a\u3093\u3060\uff01<\/strong><\/span><br \/>\u3068\u3044\u3046\u4e8b\u5b9f\u3092\u3001\u5e83\u304f\u4e16\u306e\u4e2d\u306b\u4f1d\u3048\u305f\u3044\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5b66\u7fd2\u3067\u8eab\u306b\u3064\u304f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u601d\u8003\u306f\u3001\u4ed5\u4e8b\u306b\u30fb\u30fb\u30fb\u3044\u3084\u4eba\u751f\u306e\u3042\u3089\u3086\u308b\u554f\u984c\u89e3\u6c7a\u306b\u304d\u3063\u3068\u751f\u304d\u308b\u304b\u3089\u3002<\/p>\n<p>\u3068\u3082\u304b\u304f\u3001<span style=\"color: #ff0000; font-size: 14pt;\"><strong>\u307e\u305a\u306f\u59cb\u3081\u3066\u307f\u307e\u305b\u3093\u304b\uff1f<\/strong><\/span><\/p>\n<h2>\u7c21\u5358\u306b\u60c5\u5831\u304c\u624b\u306b\u5165\u308b\u6642\u4ee3<\/h2>\n<p>\u300c\u306f\u3058\u3081\u308b\u300d\u3068\u3044\u3063\u3066\u3082\u3001\u3044\u304d\u306a\u308a\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u3092\u63a2\u3057\u305f\u308a\u3001\u5165\u9580\u66f8\u3092\u6c42\u3081\u306b\u66f8\u5e97\u3078\u8d70\u3063\u305f\u308a\u3059\u308b\u5fc5\u8981\u306f\u306a\u304f\u3066\u30fb\u30fb\u30fb\u3002<\/p>\n<p>\u4eca\u306f<span style=\"color: #ff0000; font-size: 14pt;\"><strong>\u7121\u6599\u3067\u305f\u3044\u304c\u3044\u306e\u60c5\u5831\u304c\u624b\u306b\u5165\u308b<\/strong><\/span>\u3042\u308a\u304c\u305f\u3044\u6642\u4ee3\u3002<\/p>\n<p>\u30d1\u30bd\u30b3\u30f3\u304c\u3042\u308c\u3070\u3001\u53d6\u308a\u6562\u3048\u305a\u305d\u308c\u3060\u3051\u3067\uff2f\uff2b\u3067\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001\u30dc\u30af\u304c\u30aa\u30b9\u30b9\u30e1\u3059\u308b\u5b66\u7fd2\u6cd5\u306f<span style=\"font-size: 14pt;\"><strong><span style=\"color: #ff0000;\"><a href=\"https:\/\/www.youtube.com\/channel\/UCD71DyUyR3pDdvbqqsIRMbw\">\u300c\u30dc\u30af\u306eYouTube\u52d5\u753b\u300d<\/a><\/span><\/strong><\/span>\u3092\u89b3\u308b\u3053\u3068(\u2267\u25c7\u2266)<br \/><strong><span style=\"color: #0000ff; font-size: 8pt;\">(\u305c\u3072\u305c\u3072\u30fb\u30fb\u30fb)<\/span><\/strong><\/p>\n<p>\u77e5\u8b58\u3092\u5438\u53ce\u30fb\u30fb\u30fb\u3067\u306f\u306a\u304f\u3001\u5b9f\u969b\u306b\u6307\u3092\u52d5\u304b\u3057\u3066\u4f53\u9a13\u3059\u308b\u3053\u3068\u304c\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u7fd2\u5f97\u3059\u308b\u8fd1\u9053\u3002<\/p>\n<p>\u9a19\u3055\u308c\u305f\u3068\u601d\u3063\u3066\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<br \/><span style=\"font-size: 14pt; color: #ff0000;\"><strong>\u4e00\u9031\u9593\u304b\u3089\u5341\u65e5\u304f\u3089\u3044\u3067\u300c\u30d6\u30ed\u30c3\u30af\u304f\u305a\u3057\u300d\u7a0b\u5ea6\u306f\u4f5c\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059<\/strong><\/span>\u3088\u3002<\/p>\n<h2>\u7c21\u6613\u7248\u30d6\u30ed\u30c3\u30af\u5d29\u3057\u3092\u4f5c\u308b<\/h2>\n<p>\u4eca\u56de\u306e\u8a00\u8a9e\u306f\u300cPython\u300d\u3002<br \/>\u30dc\u30af\u304cYouTube\u3067\u516c\u958b\u3057\u3066\u3044\u308b<span style=\"color: #ff0000; font-size: 14pt;\"><strong><a href=\"https:\/\/www.youtube.com\/channel\/UCD71DyUyR3pDdvbqqsIRMbw\">\u300c\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u300d<\/a><\/strong><\/span>\u306e\u5165\u9580\u52d5\u753b\u3002<br \/>\u30d6\u30ed\u30c3\u30af\u5d29\u3057\u306f\u300cPython\u7b2c\uff17\u8a71\u300d\uff5e\u300c\u7b2c\uff19\u8a71\u300d\u306e\u5168\uff13\u56de\u3067\u5b8c\u7d50\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/><span style=\"font-size: 8pt;\"><strong><span style=\"color: #0000ff;\">\u5b8c\u5168\u306b\u672a\u7d4c\u9a13\u306e\u65b9\u3067\u3082\u3001\u7b2c\u4e00\u8a71\u304b\u3089\u9032\u3081\u3066\u3082\u3089\u3048\u305f\u3089\u3001\uff11\uff10\u65e5\u7a0b\u5ea6\u3067\u4f5c\u308c\u307e\u3059\u3002<\/span><\/strong><\/span><span style=\"font-size: 8pt;\"><strong><span style=\"color: #0000ff;\">\u30d6\u30ed\u30c3\u30af\u5d29\u3057(\uffe3\u25bd\uffe3)<\/span><\/strong><\/span><\/p>\n<p>\u3061\u306a\u307f\u306b\u30fb\u30fb\u30fb<br \/><span style=\"font-size: 14pt;\"><strong>\u7b2c\u4e00\u56de\uff1a\u30dc\u30fc\u30eb\u3092\u52d5\u304b\u3059\u3002<\/strong><\/span><br \/><a href=\"https:\/\/youtu.be\/kEkJc3fpFkQ\">https:\/\/youtu.be\/kEkJc3fpFkQ<\/a><br \/><strong><span style=\"font-size: 14pt;\">\u7b2c\u4e8c\u56de\uff1a\u30e9\u30b1\u30c3\u30c8\u3092\u4f5c\u308b\u3002<\/span><\/strong><br \/><a href=\"https:\/\/youtu.be\/V6tsDbgbICU\">https:\/\/youtu.be\/V6tsDbgbICU<\/a><br \/><span style=\"font-size: 14pt;\"><strong>\u7b2c\u4e09\u56de\uff1a\u30d6\u30ed\u30c3\u30af\u306e\u8868\u793a\u3068\u4ed5\u4e0a\u3052\u3002<\/strong><\/span><br \/><a href=\"https:\/\/youtu.be\/IuBoihkrLi8\">https:\/\/youtu.be\/IuBoihkrLi8<\/a><\/p>\n<p>\u3068\u3053\u308d\u3067\u300c\u7c21\u6613\u7248\u300d\u3066\u3001\u4f55\u304c\u7c21\u6613\u306a\u306e\u304b\u3068\u8a00\u3046\u3068\u3001\u6b21\u306e\u3088\u3046\u306a\u51e6\u7406\u3092\u624b\u629c\u304d\u3057\u3066\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #ff0000;\">\u30fb\u30dc\u30fc\u30eb\u306e\u30b9\u30d4\u30fc\u30c9\u306f\u5909\u5316\u3057\u306a\u3044\u3002<\/span><br \/><span style=\"color: #ff0000;\">\u30fb\u30dc\u30fc\u30eb\u306e\u8df3\u306d\u8fd4\u308b\u89d2\u5ea6\u3082\u4e00\u5b9a\u3002<\/span><br \/><span style=\"color: #ff0000;\">\u30fb\u30e9\u30b1\u30c3\u30c8\u306f\u4e0a\u8fba\u3067\u306e\u307f\u30dc\u30fc\u30eb\u30d2\u30c3\u30c8\u306e\u5224\u5b9a\u3002<\/span><br \/><span style=\"color: #ff0000;\">\u30fb\u30d6\u30ed\u30c3\u30af\u306f\u4e0b\u8fba\u3067\u306e\u307f\u30dc\u30fc\u30eb\u30d2\u30c3\u30c8\u306e\u5224\u5b9a\u3002<\/span><\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u521d\u5b66\u8005\u306b\u306f\u3061\u3087\u3046\u3069\u826f\u3044\u30ec\u30d9\u30eb\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u30b3\u30fc\u30c9\u306f\uff11\uff10\uff10\u884c\u7a0b\u5ea6\u3002<br \/><span style=\"font-size: 8pt;\"><strong><span style=\"color: #0000ff;\">(\u307e\u3001\u3053\u3093\u306a\u3082\u3093\u3060\u3088\u306d\u3002)<\/span><\/strong><\/span><\/p>\n<p>\u65e2\u306b\u3042\u308b\u7a0b\u5ea6\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30ad\u30eb\u304c\u3042\u308b\u65b9\u306e\u5f79\u306b\u7acb\u3064\u3088\u3046\u306a\u30e2\u30ce\u306f\u6b63\u76f4\u306a\u3044\u3051\u308c\u3069\u3001<span style=\"font-size: 18pt; color: #000000;\"><strong>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u5b66\u3073\u59cb\u3081\u305f\u3070\u304b\u308a\u3067<span style=\"color: #ff0000;\">\u300c\u30d6\u30ed\u30c3\u30af\u5d29\u3057\u306a\u3093\u3066\u81ea\u5206\u306b\u4f5c\u308c\u308b\u306f\u305a\u304c\u306a\u3044\uff01\u300d<\/span>\u306a\u3093\u3066\u601d\u3063\u3066\u3044\u308b\u65b9\u306f\u3001\u662f\u975e\u52d5\u753b\u3092\u898b\u3066\u304f\u3060\u3055\u3044\u3002<\/strong><\/span><\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306a\u3093\u3066\u30fb\u30fb\u30fb\u30db\u30f3\u30c8\u306b\u7c21\u5358\u306a\u3082\u306e\u306a\u306e\u3060\u3068\u3001\u4e00\u4eba\u3067\u3082\u591a\u304f\u306e\u65b9\u306b\u611f\u3058\u3066\u9802\u3051\u305f\u3089\u3001\u3053\u3093\u306a\u306b\u5b09\u3057\u3044\u3053\u3068\u306f\u306a\u3044\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306f\u53c2\u8003\u8cc7\u6599\u3068\u3057\u3066\u3002<\/p>\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-file=\"BreakOut.py\" data-lang=\"Python\"><code>############################\n#####   \u30d6\u30ed\u30c3\u30af\u5d29\u3057    #####\n############################\n\nimport tkinter as tk\nfrom tkinter import messagebox\n\n#\u30a6\u30a4\u30f3\u30c9\u30a6\nwin = tk.Tk()\nwin.title(&quot;\u30d6\u30ed\u30c3\u30af\u5d29\u3057&quot;)\nwin.geometry(&quot;425x625&quot;)\nwin.resizable(False, False)\n\n#\u30ad\u30e3\u30f3\u30d0\u30b9\ncan = tk.Canvas(bg=&quot;black&quot;, width=400, height=600)\ncan.place(x=10, y=10)\n\n#\u30b2\u30fc\u30e0\u30aa\u30fc\u30d0\u30fc\ndef gameOver():\n    messagebox.showinfo(&quot;Information&quot;, &quot;GAME OVER!&quot;)\n    exit()\n\n#\u30b2\u30fc\u30e0\u30af\u30ea\u30a2\ndef gameClear():\n    messagebox.showinfo(&quot;Information&quot;, &quot;CONGRATULATIONS!!!!&quot;)\n    exit()\n\n#\u30dc\u30fc\u30eb\nball_x = 50; ball_y = 500; bx = 5; by = -5\ndef drawBall():\n    global ball_x, ball_y, bx, by\n    can.create_oval(ball_x, ball_y, ball_x+20, ball_y+20, fill=&quot;white&quot;)\n    if ball_x&lt;=0 or ball_x&gt;=385 :\n        bx *= -1\n    if ball_y&lt;=0 :\n        by *= -1\n    if ball_y&gt;=603 :\n        gameOver()\n    if ball_y&gt;=560 and ball_x&gt;=rack_x-10 and ball_x&lt;=rack_x+50 :\n        by *= -1\n    ball_x += bx; ball_y += by\n\n#\u30e9\u30b1\u30c3\u30c8\nrack_x =170; keyPress_R = False; keyPress_L = False\ndef rightKeyPress(event):\n    global keyPress_R\n    keyPress_R = True\ndef rightKeyRelease(event):\n    global keyPress_R\n    keyPress_R = False\ndef leftKeyPress(event):\n    global keyPress_L\n    keyPress_L = True\ndef leftKeyRelease(event):\n    global keyPress_L\n    keyPress_L = False\nwin.bind(&quot;&lt;KeyPress-Right&gt;&quot;, rightKeyPress)\nwin.bind(&quot;&lt;KeyRelease-Right&gt;&quot;, rightKeyRelease)\nwin.bind(&quot;&lt;KeyPress-Left&gt;&quot;, leftKeyPress)\nwin.bind(&quot;&lt;KeyRelease-Left&gt;&quot;, leftKeyRelease)\ndef drawRacket():\n    global rack_x\n    can.create_rectangle(rack_x, 580, rack_x+60, 595, fill=&quot;white&quot;)\n    if keyPress_R==True and rack_x&lt;=350:\n        rack_x += 5\n    if keyPress_L==True and rack_x&gt;=-10:\n        rack_x -= 5\n\n#\u30d6\u30ed\u30c3\u30af\nblock = []\nfor x in range(5) :\n    for y in range(4) :\n        block.append({&quot;x&quot;:x*80+5, &quot;y&quot;:y*40+10, &quot;st&quot;:1})\ndef drawBlock() :\n    global ball_x, ball_y, by\n    block_count = 0\n    for i in range(len(block)):\n        x = block[i][&quot;x&quot;]\n        y = block[i][&quot;y&quot;]\n        st = block[i][&quot;st&quot;]\n        if ball_y&lt;=y+30 and ball_x&gt;=x-10 and ball_x&lt;=x+60 and st==1 :\n            by *= -1\n            block[i][&quot;st&quot;] = 0\n        if st==1 :\n            can.create_rectangle(x, y, x+70, y+30, fill=&quot;white&quot;)\n            block_count += 1\n    if block_count == 0:\n        gameClear()        \n\n#\u8868\u793a\u30eb\u30fc\u30d7\ndef gameLoop():\n    can.delete(&quot;all&quot;)\n    drawBall()\n    drawRacket()\n    drawBlock()\n    win.after(15, gameLoop)\n\ngameLoop()\n\n#\u30a6\u30a4\u30f3\u30c9\u30a6\u30eb\u30fc\u30d7\nwin.mainloop()<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8ab0\u306b\u3067\u3082\u3067\u304d\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306a\u3093\u3066\u3001\u8ab0\u306b\u3060\u3063\u3066\u7c21\u5358\u306b\u3067\u304d\u308b\u3082\u306e\u306a\u3093\u3060\uff01\u3068\u3044\u3046\u4e8b\u5b9f\u3092\u3001\u5e83\u304f\u4e16\u306e\u4e2d\u306b\u4f1d\u3048\u305f\u3044\u3002 \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5b66\u7fd2\u3067\u8eab\u306b\u3064\u304f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u601d\u8003\u306f\u3001\u4ed5\u4e8b\u306b\u30fb\u30fb\u30fb\u3044\u3084\u4eba\u751f\u306e\u3042\u3089 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":11299,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[349,340,1],"tags":[337,304,339,338],"class_list":["post-11237","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-programming","category-diary","tag-python","tag-youtube","tag-339","tag-338"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/kusakarism.info\/index.php?rest_route=\/wp\/v2\/posts\/11237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kusakarism.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kusakarism.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kusakarism.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kusakarism.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11237"}],"version-history":[{"count":30,"href":"https:\/\/kusakarism.info\/index.php?rest_route=\/wp\/v2\/posts\/11237\/revisions"}],"predecessor-version":[{"id":11308,"href":"https:\/\/kusakarism.info\/index.php?rest_route=\/wp\/v2\/posts\/11237\/revisions\/11308"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kusakarism.info\/index.php?rest_route=\/wp\/v2\/media\/11299"}],"wp:attachment":[{"href":"https:\/\/kusakarism.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kusakarism.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kusakarism.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}