Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CONSTANTS.ipynb #2969

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 47 additions & 73 deletions 2048 GAME PROJECT/CONSTANTS.ipynb
Original file line number Diff line number Diff line change
@@ -1,74 +1,48 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"SIZE = 400\n",
"GRID_LEN = 4\n",
"GRID_PADDING = 10\n",
"\n",
"BACKGROUND_COLOR_GAME = \"#92877d\"\n",
"BACKGROUND_COLOR_CELL_EMPTY = \"#9e948a\"\n",
"\n",
"BACKGROUND_COLOR_DICT = {2: \"#eee4da\", 4: \"#ede0c8\", 8: \"#f2b179\",\n",
" 16: \"#f59563\", 32: \"#f67c5f\", 64: \"#f65e3b\",\n",
" 128: \"#edcf72\", 256: \"#edcc61\", 512: \"#edc850\",\n",
" 1024: \"#edc53f\", 2048: \"#edc22e\",\n",
"\n",
" 4096: \"#eee4da\", 8192: \"#edc22e\", 16384: \"#f2b179\",\n",
" 32768: \"#f59563\", 65536: \"#f67c5f\", }\n",
"\n",
"CELL_COLOR_DICT = {2: \"#776e65\", 4: \"#776e65\", 8: \"#f9f6f2\", 16: \"#f9f6f2\",\n",
" 32: \"#f9f6f2\", 64: \"#f9f6f2\", 128: \"#f9f6f2\",\n",
" 256: \"#f9f6f2\", 512: \"#f9f6f2\", 1024: \"#f9f6f2\",\n",
" 2048: \"#f9f6f2\",\n",
"\n",
" 4096: \"#776e65\", 8192: \"#f9f6f2\", 16384: \"#776e65\",\n",
" 32768: \"#776e65\", 65536: \"#f9f6f2\", }\n",
"\n",
"FONT = (\"Verdana\", 40, \"bold\")\n",
"\n",
"\n",
"KEY_UP_ALT = \"\\'\\\\uf700\\'\"\n",
"KEY_DOWN_ALT = \"\\'\\\\uf701\\'\"\n",
"KEY_LEFT_ALT = \"\\'\\\\uf702\\'\"\n",
"KEY_RIGHT_ALT = \"\\'\\\\uf703\\'\"\n",
"\n",
"KEY_UP = \"'w'\"\n",
"KEY_DOWN = \"'s'\"\n",
"KEY_LEFT = \"'a'\"\n",
"KEY_RIGHT = \"'d'\"\n",
"KEY_BACK = \"'b'\"\n",
"\n",
"KEY_J = \"'j'\"\n",
"KEY_K = \"'k'\"\n",
"KEY_L = \"'l'\"\n",
"KEY_H = \"'h'\""
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
# Constants for game configuration
SIZE = 400 # Size of the game window
GRID_LEN = 4 # Length of the grid (4x4)
GRID_PADDING = 10 # Padding between grid cells

# Background colors
BACKGROUND_COLOR_GAME = "#92877d"
BACKGROUND_COLOR_CELL_EMPTY = "#9e948a"

# Background color mapping for different cell values
BACKGROUND_COLOR_DICT = {
2: "#eee4da", 4: "#ede0c8", 8: "#f2b179",
16: "#f59563", 32: "#f67c5f", 64: "#f65e3b",
128: "#edcf72", 256: "#edcc61", 512: "#edc850",
1024: "#edc53f", 2048: "#edc22e",
4096: "#eee4da", 8192: "#edc22e", 16384: "#f2b179",
32768: "#f59563", 65536: "#f67c5f"
}

# Cell colors for different values
CELL_COLOR_DICT = {
2: "#776e65", 4: "#776e65", 8: "#f9f6f2", 16: "#f9f6f2",
32: "#f9f6f2", 64: "#f9f6f2", 128: "#f9f6f2",
256: "#f9f6f2", 512: "#f9f6f2", 1024: "#f9f6f2",
2048: "#f9f6f2",
4096: "#776e65", 8192: "#f9f6f2", 16384: "#776e65",
32768: "#776e65", 65536: "#f9f6f2"
}

# Font settings for displaying numbers
FONT = ("Verdana", 40, "bold")

# Key bindings for control
KEY_UP_ALT = "'\\uf700'"
KEY_DOWN_ALT = "'\\uf701'"
KEY_LEFT_ALT = "'\\uf702'"
KEY_RIGHT_ALT = "'\\uf703'"

KEY_UP = "'w'"
KEY_DOWN = "'s'"
KEY_LEFT = "'a'"
KEY_RIGHT = "'d'"
KEY_BACK = "'b'"

KEY_J = "'j'"
KEY_K = "'k'"
KEY_L = "'l'"
KEY_H = "'h'"