Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
2048
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Thomas Bianco
2048
Commits
1faf1cea
Commit
1faf1cea
authored
6 years ago
by
Thomas Bianco
Browse files
Options
Downloads
Patches
Plain Diff
grille initiale
parent
9f9aa5e6
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.idea/inspectionProfiles/Project_Default.xml
+2
-0
2 additions, 0 deletions
.idea/inspectionProfiles/Project_Default.xml
game2048/display_grid.py
+22
-10
22 additions, 10 deletions
game2048/display_grid.py
with
24 additions
and
10 deletions
.idea/inspectionProfiles/Project_Default.xml
+
2
−
0
View file @
1faf1cea
...
...
@@ -14,6 +14,8 @@
<option
value=
"E501"
/>
<option
value=
"W29"
/>
<option
value=
"E501"
/>
<option
value=
"W29"
/>
<option
value=
"E501"
/>
</list>
</option>
</inspection_tool>
...
...
This diff is collapsed.
Click to expand it.
game2048/display_grid.py
+
22
−
10
View file @
1faf1cea
import
tkinter
as
tk
from
tkinter
import
*
from
run_2048
import
*
THEMES
=
{
"
0
"
:
{
"
name
"
:
"
Default
"
,
0
:
""
,
2
:
"
2
"
,
4
:
"
4
"
,
8
:
"
8
"
,
16
:
"
16
"
,
32
:
"
32
"
,
64
:
"
64
"
,
128
:
"
128
"
,
256
:
"
256
"
,
512
:
"
512
"
,
1024
:
"
1024
"
,
2048
:
"
2048
"
,
4096
:
"
4096
"
,
8192
:
"
8192
"
},
"
1
"
:
{
"
name
"
:
"
Chemistry
"
,
0
:
""
,
2
:
"
H
"
,
4
:
"
He
"
,
8
:
"
Li
"
,
16
:
"
Be
"
,
32
:
"
B
"
,
64
:
"
C
"
,
128
:
"
N
"
,
256
:
"
O
"
,
512
:
"
F
"
,
1024
:
"
Ne
"
,
2048
:
"
Na
"
,
4096
:
"
Mg
"
,
8192
:
"
Al
"
},
"
2
"
:
{
"
name
"
:
"
Alphabet
"
,
0
:
""
,
2
:
"
A
"
,
4
:
"
B
"
,
8
:
"
C
"
,
16
:
"
D
"
,
32
:
"
E
"
,
64
:
"
F
"
,
128
:
"
G
"
,
256
:
"
H
"
,
512
:
"
I
"
,
1024
:
"
J
"
,
2048
:
"
K
"
,
4096
:
"
L
"
,
8192
:
"
M
"
}}
TILES_BG_COLOR
=
{
0
:
"
#9e948a
"
,
2
:
"
#eee4da
"
,
4
:
"
#ede0c8
"
,
8
:
"
#f1b078
"
,
\
16
:
"
#eb8c52
"
,
32
:
"
#f67c5f
"
,
64
:
"
#f65e3b
"
,
\
128
:
"
#edcf72
"
,
256
:
"
#edcc61
"
,
512
:
"
#edc850
"
,
\
...
...
@@ -14,24 +16,34 @@ TILES_FG_COLOR = {0: "#776e65", 2: "#776e65", 4: "#776e65", 8: "#f9f6f2", \
TILES_FONT
=
{
"
Verdana
"
,
40
,
"
bold
"
}
def
main_run
():
def
graphical_grid_init
():
root
=
tk
.
Tk
()
window
=
tk
.
Toplevel
()
grid_game
=
init_game
()
root
=
Tk
()
background
=
Frame
(
root
)
grid_size
=
4
background
=
tk
.
Frame
(
root
)
theme
=
THEMES
[
"
0
"
]
graphical_grid
=
[]
labels
=
[]
game_grid
=
init_game
(
grid_size
)
for
i
in
range
(
grid_size
):
graphical_grid
.
append
([])
labels
.
append
([])
for
j
in
range
(
grid_size
):
graphical_grid
[
i
].
append
(
tk
.
Frame
(
master
=
background
,
bd
=
2
,
relief
=
"
r
aised
"
,
bg
=
TILES_BG_COLOR
[
0
],
height
=
100
,
width
=
10
0
))
graphical_grid
[
i
].
append
(
Label
(
master
=
background
,
bd
=
1
,
relief
=
"
r
idge
"
,
bg
=
TILES_BG_COLOR
[
0
],
text
=
""
,
height
=
5
,
width
=
10
))
graphical_grid
[
i
][
j
].
grid
(
column
=
i
,
row
=
j
)
graphical_grid
=
graphical_update
(
graphical_grid
,
game_grid
,
grid_size
,
theme
)
background
.
pack
()
root
.
mainloop
()
graphical_grid_init
()
def
graphical_update
(
graphical_grid
,
game_grid
,
grid_size
,
theme
):
for
i
in
range
(
grid_size
):
for
j
in
range
(
grid_size
):
graphical_grid
[
i
][
j
].
config
(
bg
=
TILES_BG_COLOR
[
game_grid
[
i
][
j
]],
fg
=
TILES_FG_COLOR
[
game_grid
[
i
][
j
]],
text
=
theme
[
game_grid
[
i
][
j
]])
return
graphical_grid
main_run
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment