{"id":11314,"date":"2021-05-28T18:44:00","date_gmt":"2021-05-28T09:44:00","guid":{"rendered":"https:\/\/kusakarism.info\/?p=11314"},"modified":"2026-02-23T02:42:01","modified_gmt":"2026-02-22T17:42:01","slug":"tetris","status":"publish","type":"post","link":"https:\/\/kusakarism.info\/?p=11314","title":{"rendered":"\u672c\u6c17\u3067\u300c\u30c6\u30c8\u30ea\u30b9\u300d\u3092\u4f5c\u3063\u3066\u307f\u305f\u7d50\u679c\u30fb\u30fb\u30fb\u3002\uff0f\u3055\u3066\u3001\u4f55\u5206\u3067\u5b8c\u6210\u3057\u305f\u306e\u304b\uff1f"},"content":{"rendered":"<h2>\u96e8\u30fb\u30fb\u30fb\u3053\u3093\u306a\u65e5\u306f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u65e5\u548c\u3002<\/h2>\n<p><span style=\"font-size: 14pt; color: #ff0000;\"><strong>\u305d\u3046\u3060\uff01\u3000\u30c6\u30c8\u30ea\u30b9\u3001\u4f5c\u308d\u3046\uff01\uff01<\/strong><\/span><br \/>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u3084\u3063\u3066\u307f\u305f\u3002<\/p>\n<p>\u5358\u7d14\u306a\u30b2\u30fc\u30e0\u3060\u3002<\/p>\n<p>\u30aa\u30ec\u306e\u624b\u306b\u304b\u304b\u308c\u3070\u30fb\u30fb\u30fb\u9020\u4f5c\u3082\u306a\u3044\u30fb\u30fb\u30fb(\u6c57)\u3002<\/p>\n<p>\u3055\u3066\u3001<span style=\"color: #ff0000; font-size: 14pt;\"><strong>\u5b8c\u6210\u307e\u3067\u3069\u308c\u304f\u3089\u3044\u304b\u304b\u3063\u305f\u306e\u304b\uff1f<\/strong><\/span><\/p>\n<h2>\u3068\u308a\u3042\u3048\u305a\u306f\u3001\u30b3\u30fc\u30c9\u3060\u3051\u3067\u3082\u3002<\/h2>\n<p>\u4eca\u56de\u306e\u52d5\u753b\u306f\u3001\u30db\u30f3\u30c8\u306b\u30aa\u30f3\u30ea\u30fc\u30c1\u30e3\u30ec\u30f3\u30b8\u3060\u3002<\/p>\n<p>\u30b3\u30fc\u30c9\u306e\u89e3\u8aac\u306a\u3093\u304b\u306f\u7279\u306b\u306a\u304f\u3063\u3066\u3002<\/p>\n<p>\u305f\u3060\u305f\u3060\u3001\u66f8\u304d\u7d9a\u3051\u308b\u3002<br \/><span style=\"color: #0000ff; font-size: 8pt;\"><strong>\u3044\u3084\u3001\u60a9\u3093\u3060\u308a\u30fb\u30fb\u30fb\u66f8\u3044\u305f\u308a\u30fb\u30fb\u30fb\u3002<br \/>\u60a9\u3093\u3060\u308a\u30fb\u30fb\u30fb\u60a9\u3093\u3060\u308a\u30fb\u30fb\u30fb\u3002<\/strong><\/span><\/p>\n<p><span style=\"font-size: 14pt;\"><strong><span style=\"color: #ff0000;\">\u52d5\u753b\u306f\u30b3\u30c1\u30e9(\u2193)<\/span><br \/>\u672c\u6c17\u3067\u4f5c\u308b\u30c6\u30c8\u30ea\u30b9\u3002<\/strong><\/span><br \/><a href=\"https:\/\/youtu.be\/eXlAOtMQweE\">https:\/\/youtu.be\/kEkJc3fpFkQ<\/a><br \/><strong><span style=\"font-size: 14pt;\"><\/span><\/strong><\/p>\n<p>\u3060\u304b\u3089\u3001\u3053\u306e\u30d6\u30ed\u30b0\u3067\u89e3\u8aac\u8a18\u4e8b\u304c\u3042\u308c\u3070\u89aa\u5207\u306a\u3093\u3060\u3051\u3069\u30fb\u30fb\u30fb\u3002<\/p>\n<p>\u3042\u308a\u307e\u305b\u3093^_^;<br \/><span style=\"color: #0000ff; font-size: 8pt;\"><strong>\u52d5\u753b\u3092\u898b\u3066\u3082\u30fb\u30fb\u30fb\u3042\u308a\u307e\u305b\u3093\u3002<\/strong><\/span><\/p>\n<p>\u4eca\u5f8c\u8ffd\u52a0\u3059\u308b\u304b\u3082\u30fb\u30fb\u30fb\u672a\u5b9a\u3067\u3059\u304c\u3002<\/p>\n<p><span style=\"color: #0000ff;\"><strong>\uff3b\u8ffd\u8a18\uff3d<\/strong><\/span><br \/><span style=\"color: #0000ff;\"><strong>\u89e3\u8aac\u306e\u52d5\u753b\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002<\/strong><\/span><\/p>\n<p>\u7b2c\uff11\u8a71<br \/><a href=\"https:\/\/youtu.be\/uvvfKJ7_X9c\">https:\/\/youtu.be\/Nugqv7UojCw<\/a><br \/>\u30fb\u30c6\u30c8\u30ed\u30df\u30ce\u3092\u8868\u793a\u3057\u3066\u52d5\u304b\u3059<br \/><strong><span style=\"font-size: 14pt;\"><\/span><\/strong><\/p>\n<p>\u7b2c\uff12\u8a71<br \/><a href=\"https:\/\/youtu.be\/LwfrNsgnlyk\">https:\/\/youtu.be\/PwQr-HWc75E<\/a><br \/>\u30fb\u30a2\u30bf\u30ea\u5224\u5b9a\u3068\u30c6\u30c8\u30ed\u30df\u30ce\u3092\u56de\u8ee2\u3055\u305b\u308b<\/p>\n<p>\u7b2c\uff13\u8a71<br \/><a href=\"https:\/\/youtu.be\/g-gdYAFev7A\">https:\/\/youtu.be\/SZ6nWwMQufI<\/a><br \/>\u30fb\u6700\u5f8c\u306e\u4ed5\u4e0a\u3052\u4e00\u5217\u305d\u308d\u3063\u305f\u3089\u6d88\u3059<\/p>\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-file=\"Tetris.py\" data-lang=\"Python\"><code>#################### Rough TETRIS ####################\n\nimport tkinter as tk\nimport random\nfrom tkinter import messagebox\n\nSIZE = 30       #\u30d6\u30ed\u30c3\u30af\u306e\u30b5\u30a4\u30ba\nmoveX = 4       #\u30c6\u30c8\u30ed\u30df\u30ce\u8868\u793a\u4f4d\u7f6e\uff08\u6a2a\uff09\nmoveY = 0       #\u30c6\u30c8\u30ed\u30df\u30ce\u8868\u793a\u4f4d\u7f6e\uff08\u7e26\uff09\ntype = random.randint(0, 6)        #\u30c6\u30c8\u30ed\u30df\u30ce\u306e\u30bf\u30a4\u30d7\n\ntimer = 800     #\u30b2\u30fc\u30e0\u30b9\u30d4\u30fc\u30c9\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\nscore = 0       #\u30b9\u30b3\u30a2\n\ncolor = [&quot;magenta&quot;, &quot;blue&quot;, &quot;cyan&quot;, &quot;yellow&quot;, &quot;orange&quot;, &quot;red&quot;, &quot;green&quot;, &quot;black&quot;, &quot;white&quot;]\n\n#\u30c6\u30c8\u30ed\u30df\u30ce\u30c7\u30fc\u30bf\ntetroT = [-1, 0, 0, 0, 1, 0, 0, 1]\ntetroJ = [-1, 0, 0, 0, 1, 0, 1, 1]\ntetroI = [-1, 0, 0, 0, 1, 0, 2, 0]\ntetroO = [ 0, 0, 1, 0, 0, 1, 1, 1]\ntetroL = [-1, 0, 0, 0, 1, 0,-1, 1]\ntetroZ = [-1,-1, 0,-1, 0, 0, 1, 0]\ntetroS = [ 0, 0, 1, 0, 0, 1,-1, 1]\ntetro = [tetroT, tetroJ, tetroI, tetroO, tetroL, tetroZ, tetroS]\n\n#\u30d5\u30a3\u30fc\u30eb\u30c9\u30c7\u30fc\u30bf\nfield = []\nfor y in range(22):\n    sub = []\n    for x in range(12):\n        if x==0 or x==11 or y==21 :\n            sub.append(8)\n        else :\n            sub.append(7)\n    field.append(sub)\n\n#\u30c6\u30c8\u30ed\u30df\u30ce\u3092\u8868\u793a\u3059\u308b\u95a2\u6570\ndef drawTetris():\n    for i in range(4):\n        x = (tetro[type][i*2]+moveX)*SIZE\n        y = (tetro[type][i*2+1]+moveY)*SIZE\n        can. create_rectangle(x, y, x+SIZE, y+SIZE, fill=color[type])\n\n#\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8868\u793a\u3059\u308b\u95a2\u6570\ndef drawField():\n    for i in range(21):\n        for j in range(12):\n            outLine=0 if color[field[i+1][j]]==&quot;white&quot; else 1   #\u767d\u3044\u30d6\u30ed\u30c3\u30af\u306f\u67a0\u7121\u3057\u3067\u8868\u793a\n            can.create_rectangle(j*SIZE, i*SIZE, (j+1)*SIZE, (i+1)*SIZE, fill=color[field[i+1][j]], width=outLine)\n\n#\u30c6\u30c8\u30ed\u30df\u30ce\u3092\u52d5\u304b\u3059\u95a2\u6570\ndef keyPress(event):   \n    global moveX, moveY\n    afterX = moveX\n    afterY = moveY\n    afterTetro = []\n    afterTetro.extend(tetro[type])\n    if event.keysym==&quot;Right&quot; :      #\u53f3\u79fb\u52d5\n        afterX += 1\n    elif event.keysym==&quot;Left&quot; :     #\u5de6\u79fb\u52d5\n        afterX -= 1\n    elif event.keysym==&quot;Down&quot; :     #\u4e0b\u79fb\u52d5\n        afterY += 1\n    elif event.keysym==&quot;space&quot; :    #\u53f3\u56de\u8ee2\n        afterTetro.clear()\n        for i in range(4):\n            afterTetro.append(tetro[type][i*2+1]*(-1))\n            afterTetro.append(tetro[type][i*2])\n    judge(afterX, afterY, afterTetro)   #\u30a2\u30bf\u30ea\u5224\u5b9a\u95a2\u6570\u547c\u3073\u51fa\u3057\n\ndef judge(afterX, afterY, afterTetro):  #\u30a2\u30bf\u30ea\u5224\u5b9a\u3092\u3059\u308b\u95a2\u6570\n    global moveX, moveY\n    result = True\n    for i in range(4):\n        x = afterTetro[i*2]+afterX\n        y = afterTetro[i*2+1]+afterY\n        if field[y+1][x]!=7 :\n            result = False\n    if result==True :\n        moveX = afterX\n        moveY = afterY\n        tetro[type].clear()\n        tetro[type].extend(afterTetro)\n    return result\n\ndef dropTetris():\n    global moveX, moveY, type, timer\n    afterTetro = []\n    afterTetro.extend(tetro[type])\n    result = judge(moveX, moveY+1, afterTetro)\n    if result==False :\n        for i in range(4):\n            x = tetro[type][i*2]+moveX\n            y = tetro[type][i*2+1]+moveY\n            field[y+1][x] = type\n        deleteLine()\n        type = random.randint(0, 6)\n        moveX = 4\n        moveY = 0\n    can.after(timer, dropTetris)\n    timer -= 2                          #\u843d\u4e0b\u901f\u5ea6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\n    if timer&lt;140 :\n        timer = 180\n\ndef deleteLine():\n    global score\n    for i in range(1, 21):\n        if 7 not in field[i]:\n            for j in range(i):\n                for k in range(12):\n                    field[i-j][k] = field[i-j-1][k]\n            score += 800-timer\n    for i in range(1, 11):\n        if 7 != field[1][i]:\n            messagebox.showinfo(&quot;information&quot;, &quot;GAME OVER !&quot;)\n            exit()\n\n####################  \u30b2\u30fc\u30e0\u30eb\u30fc\u30d7  ####################    \nwin = tk.Tk()\nwin.geometry(&quot;340x630&quot;)\nwin.title(&quot;Rough TETRIS&quot;)\ncan = tk.Canvas(win, width=12*SIZE, height=21*SIZE)\ncan.place(x=-10, y=0)\nvar = tk.StringVar()\nlab = tk.Label(win, textvariable=var, fg=&quot;blue&quot;, bg=&quot;white&quot;, font=(&quot;&quot;, &quot;20&quot;))   #\u5f97\u70b9\u8868\u793a\nlab.place(x=50, y=600)\n\nwin.bind(&quot;&lt;Any-KeyPress&gt;&quot;, keyPress)    #\u30ad\u30fc\u30d7\u30ec\u30b9\u3092\u30d0\u30a4\u30f3\u30c9\n\ndef gameLoop():\n    can.delete(&quot;all&quot;)\n    var.set(score)\n    drawField()\n    drawTetris()\n    can.after(50, gameLoop)\n\ngameLoop()\ndropTetris()\n\nwin.mainloop()<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u96e8\u30fb\u30fb\u30fb\u3053\u3093\u306a\u65e5\u306f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u65e5\u548c\u3002 \u305d\u3046\u3060\uff01\u3000\u30c6\u30c8\u30ea\u30b9\u3001\u4f5c\u308d\u3046\uff01\uff01\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u3084\u3063\u3066\u307f\u305f\u3002 \u5358\u7d14\u306a\u30b2\u30fc\u30e0\u3060\u3002 \u30aa\u30ec\u306e\u624b\u306b\u304b\u304b\u308c\u3070\u30fb\u30fb\u30fb\u9020\u4f5c\u3082\u306a\u3044\u30fb\u30fb\u30fb(\u6c57)\u3002 \u3055\u3066\u3001\u5b8c\u6210\u307e\u3067\u3069\u308c\u304f\u3089\u3044\u304b\u304b\u3063\u305f\u306e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":11315,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[349,340,1],"tags":[337,304,343,338],"class_list":["post-11314","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-programming","category-diary","tag-python","tag-youtube","tag-343","tag-338"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/kusakarism.info\/index.php?rest_route=\/wp\/v2\/posts\/11314","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=11314"}],"version-history":[{"count":10,"href":"https:\/\/kusakarism.info\/index.php?rest_route=\/wp\/v2\/posts\/11314\/revisions"}],"predecessor-version":[{"id":12459,"href":"https:\/\/kusakarism.info\/index.php?rest_route=\/wp\/v2\/posts\/11314\/revisions\/12459"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kusakarism.info\/index.php?rest_route=\/wp\/v2\/media\/11315"}],"wp:attachment":[{"href":"https:\/\/kusakarism.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kusakarism.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kusakarism.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}