Demo entry 6687317

2048

   

Submitted by anonymous on Dec 28, 2017 at 02:34
Language: Python. Code size: 1.2 kB.

    # 向左移动所有方块
    if l_Button.clicked(q):
        for i in range(4):
            for j in range(4):
                if field_list[i][j] != 0:
                    while (j > 0) and field_list[i][j - 1] == 0:
                        field_list[i][j].diy_move(-1, 0)
                        field_list[i][j - 1], field_list[i][j] = field_list[i][
                            j], field_list[i][j - 1]
                        j -= 1
                        a = 0
                    while (j > 0) and (field_list[i][j - 1] != 0) and (field_list[i][j] != 0) and \
                          (field_list[i][j].t == field_list[i][j - 1].t):
                        field_list[i][j].diy_move(-1, 0)
                        field_list[i][j].f1.undraw()
                        field_list[i][j].f2.undraw()
                        field_list[i][j] = 0
                        field_list[i][j - 1].f1.setText(
                            field_list[i][j - 1].t * 2)
                        field_list[i][j - 1].t *= 2
                        field_list[i][j - 1].colorchange()
                        total += field_list[i][j - 1].t
                        a = 0
                    tot.setText(total)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).