diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml
new file mode 100644
index 0000000..8b57f45
--- /dev/null
+++ b/.idea/google-java-format.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..6111a9a
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000..c1dd12f
Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000..40ca015
--- /dev/null
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1,2 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..6076780
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2024 Son Nguyen
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..670386b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,205 @@
+# 2048 Game in JavaFX
+
+This is a JavaFX implementation of the popular **2048 puzzle game**, where the objective is to slide tiles on a grid to combine them into a tile with the value **2048**. This implementation includes animations, styling, and responsive UI design, offering an enjoyable experience for players.
+
+## Features
+
+- **Interactive Gameplay**: Use arrow keys to move tiles (Up, Down, Left, Right).
+- **Score Tracking**: Displays current and best scores at the top of the game.
+- **Responsive UI**:
+ - Animated tile movements and merging effects.
+ - Color-coded tiles based on values for easy recognition.
+ - Modern styling with rounded borders and proper alignment.
+- **Game State Management**:
+ - Automatically adds new tiles after each move.
+ - Checks for available moves and detects game over conditions.
+- **Intelligent Animations**:
+ - Smooth scaling animations for tile appearances and merges.
+ - Dynamic color updates based on tile values.
+
+## Preview
+
+
+
+
+
+## Gameplay
+
+### Objective
+
+Combine tiles with the same value to create a tile with the value **2048** or higher. The game ends when no valid moves are left.
+
+### Controls
+
+- **Arrow Keys**:
+ - **Up**: Moves all tiles upward.
+ - **Down**: Moves all tiles downward.
+ - **Left**: Moves all tiles to the left.
+ - **Right**: Moves all tiles to the right.
+- **New Game** Button: Resets the game.
+- **Exit Game** Button: Closes the application.
+
+## How It Works
+
+### Game Mechanics
+
+1. **Sliding and Merging**:
+ - Tiles slide in the direction of the arrow key pressed.
+ - Tiles with the same value merge into one tile, doubling their value.
+ - A tile can merge only once per move.
+2. **Adding New Tiles**:
+ - After every valid move, a new tile (value `2` or `4`) appears in a random empty spot.
+3. **Game Over**:
+ - The game checks for possible moves after each action.
+ - If no moves are available (all tiles are full and non-mergeable), the game ends.
+
+
+### Code Structure
+
+#### **1. Class: `Game2048`**
+This is the main class responsible for rendering the game grid, handling user inputs, managing the board state, and applying animations.
+
+Key Components:
+- **Grid Management**:
+ - `SIZE`: Size of the grid (default is 4x4).
+ - `board`: 2D array representing the logical state of the grid.
+ - `tiles`: 2D array of `StackPane` objects representing the UI tiles.
+- **UI Elements**:
+ - `scoreLabel`: Displays the current score.
+ - `bestScoreLabel`: Displays the best score achieved.
+- **Tile Colors**:
+ - Dynamically updates colors and text based on tile values.
+- **Animations**:
+ - Smooth scaling animations for tile appearances and merges.
+
+#### 2. **Class: `Main`**
+This is the entry point for the application, where the game window is initialized and displayed.
+
+Key Components:
+- **JavaFX Setup**:
+ - Configures the game window and scene.
+ - Loads the FXML file for the game UI.
+ - Initializes the game controller (`Game2048`).
+- **Event Handling**:
+ - Registers key listeners for arrow keys.
+ - Handles button actions for New Game and Exit Game.
+- **CSS Loading**:
+ - Loads the CSS file for styling the game.
+
+#### 3. **Maven XML Configuration: `pom.xml`**
+This file contains the Maven project configuration, including dependencies for JavaFX and JUnit.
+
+Key Components:
+- **JavaFX Dependencies**:
+ - Includes JavaFX modules for controls and FXML.
+ - Configures the JavaFX plugin for running the application.
+- **JUnit Dependency**:
+ - Adds JUnit for testing the game logic.
+ - Configures the Maven Surefire plugin for running tests.
+
+### Styling
+
+The game is styled with modern aesthetics, featuring:
+- Rounded borders for tiles and buttons.
+- Background colors based on tile values.
+- Proper alignment of header (title, score, and best score).
+- Button styles with hover effects.
+
+Color Codes for Tiles:
+- `2`: Light cream (`#eee4da`)
+- `4`: Pale beige (`#ede0c8`)
+- `8`: Light orange (`#f2b179`)
+- Higher values progressively darker and more vibrant.
+
+## Installation
+
+1. **Clone the Repository**:
+ ```bash
+ git clone https://github.com/hoangsonww/Game-2048-JavaFX.git
+ cd Game-2048-JavaFX
+ ```
+
+2. **Set Up JavaFX**:
+ - Ensure that JavaFX is installed. If not, download JavaFX from the [official site](https://openjfx.io/).
+ - Configure JavaFX in your IDE:
+ - Add JavaFX libraries to your project.
+ - Set JVM arguments to include JavaFX runtime, e.g.:
+ ```bash
+ --module-path /path-to-javafx/lib --add-modules javafx.controls,javafx.fxml
+ ```
+
+3. **Run the Game**:
+ - Compile and run the `Main` class.
+ - The game window will open, and you can start playing immediately.
+
+## Usage
+
+### Running the Game
+
+1. **Start the Application**:
+ - Run the `Main` class from your IDE or terminal.
+2. **Play**:
+ - Use the arrow keys to move and merge tiles.
+ - Aim for a tile value of 2048 (or higher)!
+3. **Reset**:
+ - Click the **New Game** button to restart the game.
+4. **Exit**:
+ - Click the **Exit Game** button to close the application.
+
+## File Structure
+
+```
+src/
+├── org.example.game2048javafx/
+│ ├── Game2048.java # Main game logic and UI
+│ ├── Main.java # Entry point for the application
+│ └── resources/ # Optional resources like images or stylesheets
+└── README.md # Comprehensive documentation
+```
+
+## Known Issues
+
+1. **Game Freezing**:
+ - Ensure animations do not block the main UI thread.
+2. **Performance**:
+ - For extremely high tile values, UI updates may lag.
+
+## Contributing
+
+Feel free to contribute to this project! Open issues, submit pull requests, or suggest new features.
+
+1. **Fork the Repository**:
+ ```bash
+ git fork https://github.com/hoangsonww/Game-2048-JavaFX.git
+ ```
+
+2. **Create a New Branch**:
+ ```bash
+ git checkout -b feature/feature-branch-name
+ ```
+
+3. **Commit and Push**:
+ ```bash
+ git add .
+ git commit -m "Add your message here"
+ git push origin feature-branch-name
+ ```
+
+4. **Submit a Pull Request**:
+ - Open a pull request on GitHub describing your changes.
+
+## License
+
+This project is licensed under the [MIT License](LICENSE).
+
+## Acknowledgments
+
+- Inspired by the original 2048 game.
+- Built with love using JavaFX.
+- Author: [Son Nguyen](https://github.com/hoangsonww)
+
+Enjoy playing 2048 in JavaFX! If you encounter any issues, feel free to raise them in the repository.
+
+---
+
+**Happy Coding! 🚀**
diff --git a/img/ui.png b/img/ui.png
new file mode 100644
index 0000000..d6daa89
Binary files /dev/null and b/img/ui.png differ
diff --git a/mvnw b/mvnw
new file mode 100755
index 0000000..8a8fb22
--- /dev/null
+++ b/mvnw
@@ -0,0 +1,316 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /usr/local/etc/mavenrc ] ; then
+ . /usr/local/etc/mavenrc
+ fi
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="`/usr/libexec/java_home`"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+
+ saveddir=`pwd`
+
+ M2_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ M2_HOME=`cd "$M2_HOME" && pwd`
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --unix "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="`(cd "$M2_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="`which javac`"
+ if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ if $darwin ; then
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ else
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ fi
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="`\\unset -f command; \\command -v java`"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=`cd "$wdir/.."; pwd`
+ fi
+ # end of workaround
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' < "$1")"
+ fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found .mvn/wrapper/maven-wrapper.jar"
+ fi
+else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+ fi
+ if [ -n "$MVNW_REPOURL" ]; then
+ jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+ else
+ jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+ fi
+ while IFS="=" read key value; do
+ case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+ esac
+ done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Downloading from: $jarUrl"
+ fi
+ wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+ if $cygwin; then
+ wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
+ fi
+
+ if command -v wget > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found wget ... using wget"
+ fi
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+ else
+ wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+ fi
+ elif command -v curl > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found curl ... using curl"
+ fi
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ curl -o "$wrapperJarPath" "$jarUrl" -f
+ else
+ curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
+ fi
+
+ else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Falling back to using Java to download"
+ fi
+ javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ # For Cygwin, switch paths to Windows format before running javac
+ if $cygwin; then
+ javaClass=`cygpath --path --windows "$javaClass"`
+ fi
+ if [ -e "$javaClass" ]; then
+ if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Compiling MavenWrapperDownloader.java ..."
+ fi
+ # Compiling the Java class
+ ("$JAVA_HOME/bin/javac" "$javaClass")
+ fi
+ if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ # Running the downloader
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Running MavenWrapperDownloader.java ..."
+ fi
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+ fi
+ fi
+ fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+ echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --path --windows "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ $MAVEN_DEBUG_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" \
+ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/mvnw.cmd b/mvnw.cmd
new file mode 100644
index 0000000..1d8ab01
--- /dev/null
+++ b/mvnw.cmd
@@ -0,0 +1,188 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM https://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Found %WRAPPER_JAR%
+ )
+) else (
+ if not "%MVNW_REPOURL%" == "" (
+ SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
+ )
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ )
+
+ powershell -Command "&{"^
+ "$webclient = new-object System.Net.WebClient;"^
+ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+ "}"^
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
+ "}"
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Finished downloading %WRAPPER_JAR%
+ )
+)
+@REM End of extension
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% ^
+ %JVM_CONFIG_MAVEN_PROPS% ^
+ %MAVEN_OPTS% ^
+ %MAVEN_DEBUG_OPTS% ^
+ -classpath %WRAPPER_JAR% ^
+ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
+ %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
+
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
+
+cmd /C exit /B %ERROR_CODE%
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..d9f88fd
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,81 @@
+
+
+ 4.0.0
+
+ org.example
+ Game-2048-JavaFX
+ 1.0-SNAPSHOT
+ Game-2048-JavaFX
+
+
+ UTF-8
+ 5.10.2
+
+
+
+
+ org.openjfx
+ javafx-controls
+ 22.0.1
+
+
+ org.openjfx
+ javafx-fxml
+ 22.0.1
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit.version}
+ test
+
+
+ org.mongodb
+ mongodb-driver-sync
+ 4.9.0
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.13.0
+
+ 22
+ 22
+
+
+
+ org.openjfx
+ javafx-maven-plugin
+ 0.0.8
+
+
+
+ default-cli
+
+ org.example.game2048javafx/org.example.game2048javafx.HelloApplication
+ app
+ app
+ app
+ true
+ true
+ true
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
new file mode 100644
index 0000000..1be871b
--- /dev/null
+++ b/src/main/java/module-info.java
@@ -0,0 +1,8 @@
+module org.example.game2048javafx {
+ requires javafx.controls;
+ requires javafx.fxml;
+
+
+ opens org.example.game2048javafx to javafx.fxml;
+ exports org.example.game2048javafx;
+}
\ No newline at end of file
diff --git a/src/main/java/org/example/game2048javafx/Game2048.java b/src/main/java/org/example/game2048javafx/Game2048.java
new file mode 100644
index 0000000..92b350e
--- /dev/null
+++ b/src/main/java/org/example/game2048javafx/Game2048.java
@@ -0,0 +1,321 @@
+package org.example.game2048javafx;
+
+import javafx.animation.ScaleTransition;
+import javafx.geometry.Pos;
+import javafx.scene.control.Label;
+import javafx.scene.layout.*;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Rectangle;
+import javafx.scene.text.Font;
+import javafx.scene.text.Text;
+import javafx.util.Duration;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+public class Game2048 extends GridPane {
+ private final int SIZE = 4;
+ private final int[][] board = new int[SIZE][SIZE];
+ private final StackPane[][] tiles = new StackPane[SIZE][SIZE];
+
+ private int score = 0;
+ private int bestScore = 0;
+
+ private final Label scoreLabel = new Label("SCORE: 0");
+ private final Label bestScoreLabel = new Label("BEST: 0");
+
+ public Game2048() {
+ setHgap(10);
+ setVgap(10);
+ setAlignment(Pos.CENTER);
+ setStyle("-fx-padding: 10; -fx-background-color: #bbada0;");
+
+ Font poppinsRegular = Font.loadFont(getClass().getResourceAsStream("/fonts/Poppins-Regular.ttf"), 18);
+ Font poppinsBold = Font.loadFont(getClass().getResourceAsStream("/fonts/Poppins-Bold.ttf"), 30);
+
+ scoreLabel.setFont(poppinsRegular);
+ bestScoreLabel.setFont(poppinsRegular);
+
+ // Initialize grid tiles
+ for (int row = 0; row < SIZE; row++) {
+ for (int col = 0; col < SIZE; col++) {
+ StackPane stack = new StackPane();
+ Rectangle bg = new Rectangle(100, 100);
+ bg.setArcWidth(15);
+ bg.setArcHeight(15);
+ bg.setFill(Color.web("#cdc1b4"));
+
+ Text text = new Text();
+ text.setFont(poppinsBold);
+ text.setFill(Color.web("#776e65"));
+ stack.getChildren().addAll(bg, text);
+ tiles[row][col] = stack;
+ add(stack, col, row);
+ }
+ }
+
+ // Handle key presses
+ setOnKeyPressed(event -> {
+ boolean moved = false;
+
+ switch (event.getCode()) {
+ case UP -> moved = move("UP");
+ case DOWN -> moved = move("DOWN");
+ case LEFT -> moved = move("LEFT");
+ case RIGHT -> moved = move("RIGHT");
+ }
+
+ if (moved) {
+ addRandomTile();
+ updateUIWithAnimations();
+ checkGameOver();
+ }
+ });
+ }
+
+ // Create the header (title and scores)
+ public HBox getHeader() {
+ Font poppinsBold = Font.loadFont(getClass().getResourceAsStream("/fonts/Poppins-Bold.ttf"), 32);
+
+ // 2048 Title Box
+ Label titleLabel = new Label("2048 Game");
+ titleLabel.setFont(poppinsBold);
+ titleLabel.setStyle(
+ "-fx-font-size: 32px; " +
+ "-fx-background-color: #edc22e; " +
+ "-fx-text-fill: white; " +
+ "-fx-padding: 15; " +
+ "-fx-border-radius: 15; " +
+ "-fx-background-radius: 15;");
+ titleLabel.setAlignment(Pos.CENTER);
+ titleLabel.setMinWidth(150);
+ titleLabel.setMinHeight(60);
+
+ // Score Box
+ scoreLabel.setStyle(
+ "-fx-font-size: 18px; " +
+ "-fx-background-color: #eee4da; " +
+ "-fx-text-fill: #333333; " +
+ "-fx-padding: 10; " +
+ "-fx-border-radius: 15; " +
+ "-fx-background-radius: 15;");
+ scoreLabel.setAlignment(Pos.CENTER);
+ scoreLabel.setMinWidth(100);
+
+ // Best Score Box
+ bestScoreLabel.setStyle(
+ "-fx-font-size: 18px; " +
+ "-fx-background-color: #eee4da; " +
+ "-fx-text-fill: #333333; " +
+ "-fx-padding: 10; " +
+ "-fx-border-radius: 15; " +
+ "-fx-background-radius: 15;");
+ bestScoreLabel.setAlignment(Pos.CENTER);
+ bestScoreLabel.setMinWidth(100);
+
+ HBox header = new HBox(20, titleLabel, new Region(), scoreLabel, bestScoreLabel);
+ header.setAlignment(Pos.CENTER_LEFT);
+ header.setStyle("-fx-padding: 10;");
+ HBox.setHgrow(new Region(), Priority.ALWAYS);
+ return header;
+ }
+
+ // Create the footer (instruction label)
+ public Label getFooter() {
+ Font poppinsRegular = Font.loadFont(getClass().getResourceAsStream("/fonts/Poppins-Regular.ttf"), 16);
+
+ Label footerLabel = new Label("Join the numbers and get to the 2048 tile!");
+ footerLabel.setFont(poppinsRegular);
+ footerLabel.setStyle(
+ "-fx-font-size: 16px; " +
+ "-fx-text-fill: #776e65; " +
+ "-fx-padding: 10; " +
+ "-fx-background-radius: 15;");
+ footerLabel.setAlignment(Pos.CENTER);
+ footerLabel.setMinHeight(50);
+ footerLabel.setMaxWidth(Double.MAX_VALUE);
+ return footerLabel;
+ }
+
+ // Start the game
+ public void startGame() {
+ resetBoard();
+ addRandomTile();
+ addRandomTile();
+ updateUI();
+ }
+
+ private void resetBoard() {
+ for (int row = 0; row < SIZE; row++) {
+ for (int col = 0; col < SIZE; col++) {
+ board[row][col] = 0;
+ }
+ }
+ score = 0;
+ updateScores();
+ }
+
+ private void addRandomTile() {
+ List emptySpaces = new ArrayList<>();
+ for (int row = 0; row < SIZE; row++) {
+ for (int col = 0; col < SIZE; col++) {
+ if (board[row][col] == 0) {
+ emptySpaces.add(new int[]{row, col});
+ }
+ }
+ }
+
+ if (!emptySpaces.isEmpty()) {
+ Random rand = new Random();
+ int[] space = emptySpaces.get(rand.nextInt(emptySpaces.size()));
+ board[space[0]][space[1]] = rand.nextDouble() < 0.9 ? 2 : 4;
+ }
+ }
+
+ private void updateUI() {
+ for (int row = 0; row < SIZE; row++) {
+ for (int col = 0; col < SIZE; col++) {
+ int value = board[row][col];
+ StackPane tile = tiles[row][col];
+ Rectangle bg = (Rectangle) tile.getChildren().get(0);
+ Text text = (Text) tile.getChildren().get(1);
+
+ if (value == 0) {
+ text.setText("");
+ bg.setFill(Color.web("#cdc1b4"));
+ } else {
+ text.setText(String.valueOf(value));
+ text.setFill(value > 4 ? Color.web("#f9f6f2") : Color.web("#776e65"));
+ bg.setFill(Color.web(getTileColor(value)));
+ }
+ }
+ }
+ }
+
+ private void updateUIWithAnimations() {
+ for (int row = 0; row < SIZE; row++) {
+ for (int col = 0; col < SIZE; col++) {
+ int value = board[row][col];
+ StackPane tile = tiles[row][col];
+ Rectangle bg = (Rectangle) tile.getChildren().get(0);
+ Text text = (Text) tile.getChildren().get(1);
+
+ if (value == 0) {
+ text.setText("");
+ bg.setFill(Color.web("#cdc1b4"));
+ } else {
+ text.setText(String.valueOf(value));
+ text.setFill(value > 4 ? Color.web("#f9f6f2") : Color.web("#776e65"));
+ bg.setFill(Color.web(getTileColor(value)));
+
+ ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(200), tile);
+ scaleTransition.setFromX(0.9);
+ scaleTransition.setFromY(0.9);
+ scaleTransition.setToX(1.0);
+ scaleTransition.setToY(1.0);
+ scaleTransition.play();
+ }
+ }
+ }
+ }
+
+ private String getTileColor(int value) {
+ return switch (value) {
+ case 2 -> "#eee4da";
+ case 4 -> "#ede0c8";
+ case 8 -> "#f2b179";
+ case 16 -> "#f59563";
+ case 32 -> "#f67c5f";
+ case 64 -> "#f65e3b";
+ case 128 -> "#edcf72";
+ case 256 -> "#edcc61";
+ case 512 -> "#edc850";
+ case 1024 -> "#edc53f";
+ case 2048 -> "#edc22e";
+ default -> "#3c3a32";
+ };
+ }
+
+ private boolean move(String direction) {
+ boolean moved = false;
+
+ for (int i = 0; i < SIZE; i++) {
+ int[] line = getLine(direction, i);
+ int[] merged = mergeLine(line);
+ if (!arrayEquals(line, merged)) moved = true;
+ setLine(direction, i, merged);
+ }
+
+ return moved;
+ }
+
+ private int[] getLine(String direction, int index) {
+ int[] line = new int[SIZE];
+ for (int i = 0; i < SIZE; i++) {
+ switch (direction) {
+ case "UP" -> line[i] = board[i][index];
+ case "DOWN" -> line[i] = board[SIZE - 1 - i][index];
+ case "LEFT" -> line[i] = board[index][i];
+ case "RIGHT" -> line[i] = board[index][SIZE - 1 - i];
+ }
+ }
+ return line;
+ }
+
+ private void setLine(String direction, int index, int[] line) {
+ for (int i = 0; i < SIZE; i++) {
+ switch (direction) {
+ case "UP" -> board[i][index] = line[i];
+ case "DOWN" -> board[SIZE - 1 - i][index] = line[i];
+ case "LEFT" -> board[index][i] = line[i];
+ case "RIGHT" -> board[index][SIZE - 1 - i] = line[i];
+ }
+ }
+ }
+
+ private int[] mergeLine(int[] line) {
+ int[] merged = new int[SIZE];
+ int pos = 0;
+
+ for (int i = 0; i < SIZE; i++) {
+ if (line[i] == 0) continue;
+
+ if (pos > 0 && merged[pos - 1] == line[i]) {
+ merged[pos - 1] *= 2; // Merge tiles
+ score += merged[pos - 1];
+ } else {
+ merged[pos++] = line[i];
+ }
+ }
+
+ updateScores();
+ return merged;
+ }
+
+ private boolean arrayEquals(int[] a, int[] b) {
+ for (int i = 0; i < SIZE; i++) {
+ if (a[i] != b[i]) return false;
+ }
+ return true;
+ }
+
+ private void updateScores() {
+ scoreLabel.setText("SCORE: " + score);
+ if (score > bestScore) {
+ bestScore = score;
+ bestScoreLabel.setText("BEST: " + bestScore);
+ }
+ }
+
+ private void checkGameOver() {
+ for (int row = 0; row < SIZE; row++) {
+ for (int col = 0; col < SIZE; col++) {
+ if (board[row][col] == 0) return; // Empty space exists
+ if (row < SIZE - 1 && board[row][col] == board[row + 1][col]) return; // Mergeable vertically
+ if (col < SIZE - 1 && board[row][col] == board[row][col + 1]) return; // Mergeable horizontally
+ }
+ }
+ System.out.println("Game Over!");
+ }
+}
diff --git a/src/main/java/org/example/game2048javafx/HelloApplication.java b/src/main/java/org/example/game2048javafx/HelloApplication.java
new file mode 100644
index 0000000..e47f9f1
--- /dev/null
+++ b/src/main/java/org/example/game2048javafx/HelloApplication.java
@@ -0,0 +1,23 @@
+package org.example.game2048javafx;
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+
+import java.io.IOException;
+
+public class HelloApplication extends Application {
+ @Override
+ public void start(Stage stage) throws IOException {
+ FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
+ Scene scene = new Scene(fxmlLoader.load(), 320, 240);
+ stage.setTitle("Hello!");
+ stage.setScene(scene);
+ stage.show();
+ }
+
+ public static void main(String[] args) {
+ launch();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/example/game2048javafx/HelloController.java b/src/main/java/org/example/game2048javafx/HelloController.java
new file mode 100644
index 0000000..dd55e44
--- /dev/null
+++ b/src/main/java/org/example/game2048javafx/HelloController.java
@@ -0,0 +1,14 @@
+package org.example.game2048javafx;
+
+import javafx.fxml.FXML;
+import javafx.scene.control.Label;
+
+public class HelloController {
+ @FXML
+ private Label welcomeText;
+
+ @FXML
+ protected void onHelloButtonClick() {
+ welcomeText.setText("Welcome to JavaFX Application!");
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/example/game2048javafx/Main.java b/src/main/java/org/example/game2048javafx/Main.java
new file mode 100644
index 0000000..08667d7
--- /dev/null
+++ b/src/main/java/org/example/game2048javafx/Main.java
@@ -0,0 +1,32 @@
+package org.example.game2048javafx;
+
+import javafx.application.Application;
+import javafx.scene.Scene;
+import javafx.scene.layout.BorderPane;
+import javafx.stage.Stage;
+
+public class Main extends Application {
+ @Override
+ public void start(Stage primaryStage) {
+ Game2048 game = new Game2048();
+
+ BorderPane root = new BorderPane();
+ root.setTop(game.getHeader()); // Add header
+ root.setCenter(game); // Add game grid
+ root.setBottom(game.getFooter()); // Add footer label
+
+ Scene scene = new Scene(root, 550, 650);
+ scene.getStylesheets().add(getClass().getResource("styles.css").toExternalForm()); // Load CSS
+
+ primaryStage.setTitle("Play 2048!");
+ primaryStage.setScene(scene);
+ primaryStage.show();
+
+ game.requestFocus(); // Focus on the game grid
+ game.startGame(); // Start the game
+ }
+
+ public static void main(String[] args) {
+ launch(args);
+ }
+}
diff --git a/src/main/resources/fonts/LICENSE.md b/src/main/resources/fonts/LICENSE.md
new file mode 100644
index 0000000..4afef42
--- /dev/null
+++ b/src/main/resources/fonts/LICENSE.md
@@ -0,0 +1,159 @@
+# Creative Commons Attribution-NonCommercial 4.0 International Public License
+
+By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
+
+## Section 1 – Definitions.
+
+a. **Adapted Material** means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
+
+b. **Adapter's License** means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
+
+c. **BY-NC Compatible License** means a license listed at , approved by Creative Commons as essentially the equivalent of this Public License.
+
+d. **Copyright and Similar Rights** means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
+
+e. **Effective Technological Measures** means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
+
+f. **Exceptions and Limitations** means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
+
+g. **Licensed Material** means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
+
+h. **Licensed Rights** means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
+
+i. **Licensor** means the individual(s) or entity(ies) granting rights under this Public License.
+
+j. **NonCommercial** means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
+
+k. **Share** means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
+
+l. **Sui Generis Database Rights** means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
+
+m. **You** means the individual or entity exercising the Licensed Rights under this Public License. **Your** has a corresponding meaning.
+
+## Section 2 – Scope.
+
+### a. License grant.
+
+1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
+
+ a. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
+
+ b. produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
+
+2. **Exceptions and Limitations.** For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
+
+3. **Term.** The term of this Public License is specified in Section 6(a).
+
+4. **Media and formats; technical modifications allowed.** The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
+
+5. **Downstream recipients.**
+
+ a. **Offer from the Licensor – Licensed Material.** Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
+
+ b. **No downstream restrictions.** You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
+
+6. **No endorsement.** Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
+
+### b. Other rights.
+
+1. **Moral rights,** such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
+
+2. **Patent and trademark rights** are not licensed under this Public License.
+
+3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
+
+## Section 3 – License Conditions.
+
+Your exercise of the Licensed Rights is expressly made subject to the following conditions.
+
+### a. Attribution.
+
+1. If You Share the Licensed Material (including in modified form), You must:
+
+ a. retain the following if it is supplied by the Licensor with the Licensed Material:
+
+ i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
+
+ ii. a copyright notice;
+
+ iii. a notice that refers to this Public License;
+
+ iv. a notice that refers to the disclaimer of warranties;
+
+ v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
+
+ b. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
+
+ c. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
+
+2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
+
+3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
+
+### b. ShareAlike.
+
+1. In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
+
+ a. The Adapter's License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC Compatible License.
+
+ b. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
+
+ c. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
+
+## Section 4 – Sui Generis Database Rights.
+
+Where the Licensed Rights include Sui Gener
+
+is Database Rights that apply to Your use of the Licensed Material:
+
+a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
+
+b. if You include all or a substantial portion of the database contents in a database in which You have Copyright or Sui Generis Database Rights, then the database in which You have Copyright or Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
+
+c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
+
+## Section 5 – Disclaimer of Warranties and Limitation of Liability.
+
+a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
+
+b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
+
+c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
+
+## Section 6 – Term and Termination.
+
+a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
+
+b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
+
+1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
+
+2. upon express reinstatement by the Licensor.
+
+For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
+
+c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
+
+d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
+
+## Section 7 – Other Terms and Conditions.
+
+a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
+
+b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
+
+## Section 8 – Interpretation.
+
+a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
+
+b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
+
+c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
+
+d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
+
+---
+
+To view a copy of this license, visit the [Creative Commons Attribution-NonCommercial 4.0 International Public License](https://creativecommons.org/licenses/by-nc/4.0/).
+
+This license is based on the [Creative Commons Attribution-NonCommercial 4.0 International Public License](https://creativecommons.org/licenses/by-nc/4.0/).
diff --git a/src/main/resources/fonts/Poppins-Black.ttf b/src/main/resources/fonts/Poppins-Black.ttf
new file mode 100644
index 0000000..71c0f99
Binary files /dev/null and b/src/main/resources/fonts/Poppins-Black.ttf differ
diff --git a/src/main/resources/fonts/Poppins-BlackItalic.ttf b/src/main/resources/fonts/Poppins-BlackItalic.ttf
new file mode 100644
index 0000000..7aeb58b
Binary files /dev/null and b/src/main/resources/fonts/Poppins-BlackItalic.ttf differ
diff --git a/src/main/resources/fonts/Poppins-Bold.ttf b/src/main/resources/fonts/Poppins-Bold.ttf
new file mode 100644
index 0000000..00559ee
Binary files /dev/null and b/src/main/resources/fonts/Poppins-Bold.ttf differ
diff --git a/src/main/resources/fonts/Poppins-BoldItalic.ttf b/src/main/resources/fonts/Poppins-BoldItalic.ttf
new file mode 100644
index 0000000..e61e8e8
Binary files /dev/null and b/src/main/resources/fonts/Poppins-BoldItalic.ttf differ
diff --git a/src/main/resources/fonts/Poppins-ExtraBold.ttf b/src/main/resources/fonts/Poppins-ExtraBold.ttf
new file mode 100644
index 0000000..df70936
Binary files /dev/null and b/src/main/resources/fonts/Poppins-ExtraBold.ttf differ
diff --git a/src/main/resources/fonts/Poppins-ExtraBoldItalic.ttf b/src/main/resources/fonts/Poppins-ExtraBoldItalic.ttf
new file mode 100644
index 0000000..14d2b37
Binary files /dev/null and b/src/main/resources/fonts/Poppins-ExtraBoldItalic.ttf differ
diff --git a/src/main/resources/fonts/Poppins-ExtraLight.ttf b/src/main/resources/fonts/Poppins-ExtraLight.ttf
new file mode 100644
index 0000000..e76ec69
Binary files /dev/null and b/src/main/resources/fonts/Poppins-ExtraLight.ttf differ
diff --git a/src/main/resources/fonts/Poppins-ExtraLightItalic.ttf b/src/main/resources/fonts/Poppins-ExtraLightItalic.ttf
new file mode 100644
index 0000000..89513d9
Binary files /dev/null and b/src/main/resources/fonts/Poppins-ExtraLightItalic.ttf differ
diff --git a/src/main/resources/fonts/Poppins-Italic.ttf b/src/main/resources/fonts/Poppins-Italic.ttf
new file mode 100644
index 0000000..12b7b3c
Binary files /dev/null and b/src/main/resources/fonts/Poppins-Italic.ttf differ
diff --git a/src/main/resources/fonts/Poppins-Light.ttf b/src/main/resources/fonts/Poppins-Light.ttf
new file mode 100644
index 0000000..bc36bcc
Binary files /dev/null and b/src/main/resources/fonts/Poppins-Light.ttf differ
diff --git a/src/main/resources/fonts/Poppins-LightItalic.ttf b/src/main/resources/fonts/Poppins-LightItalic.ttf
new file mode 100644
index 0000000..9e70be6
Binary files /dev/null and b/src/main/resources/fonts/Poppins-LightItalic.ttf differ
diff --git a/src/main/resources/fonts/Poppins-Medium.ttf b/src/main/resources/fonts/Poppins-Medium.ttf
new file mode 100644
index 0000000..6bcdcc2
Binary files /dev/null and b/src/main/resources/fonts/Poppins-Medium.ttf differ
diff --git a/src/main/resources/fonts/Poppins-MediumItalic.ttf b/src/main/resources/fonts/Poppins-MediumItalic.ttf
new file mode 100644
index 0000000..be67410
Binary files /dev/null and b/src/main/resources/fonts/Poppins-MediumItalic.ttf differ
diff --git a/src/main/resources/fonts/Poppins-Regular.ttf b/src/main/resources/fonts/Poppins-Regular.ttf
new file mode 100644
index 0000000..9f0c71b
Binary files /dev/null and b/src/main/resources/fonts/Poppins-Regular.ttf differ
diff --git a/src/main/resources/fonts/Poppins-SemiBold.ttf b/src/main/resources/fonts/Poppins-SemiBold.ttf
new file mode 100644
index 0000000..74c726e
Binary files /dev/null and b/src/main/resources/fonts/Poppins-SemiBold.ttf differ
diff --git a/src/main/resources/fonts/Poppins-SemiBoldItalic.ttf b/src/main/resources/fonts/Poppins-SemiBoldItalic.ttf
new file mode 100644
index 0000000..3e6c942
Binary files /dev/null and b/src/main/resources/fonts/Poppins-SemiBoldItalic.ttf differ
diff --git a/src/main/resources/fonts/Poppins-Thin.ttf b/src/main/resources/fonts/Poppins-Thin.ttf
new file mode 100644
index 0000000..03e7366
Binary files /dev/null and b/src/main/resources/fonts/Poppins-Thin.ttf differ
diff --git a/src/main/resources/fonts/Poppins-ThinItalic.ttf b/src/main/resources/fonts/Poppins-ThinItalic.ttf
new file mode 100644
index 0000000..e26db5d
Binary files /dev/null and b/src/main/resources/fonts/Poppins-ThinItalic.ttf differ
diff --git a/src/main/resources/fonts/README.md b/src/main/resources/fonts/README.md
new file mode 100644
index 0000000..6c957c3
--- /dev/null
+++ b/src/main/resources/fonts/README.md
@@ -0,0 +1,70 @@
+# The MovieVerse - `fonts` Directory
+
+## Overview
+
+This directory contains the Poppins font family, designed by Jonny Pinhorn. Poppins is a geometric sans-serif typeface with support for both Latin and Devanagari scripts, and is known for its clean shapes and friendly curves, making it suitable for a wide range of design work.
+
+The Poppins font family is part of the Indian Type Foundry (ITF) and is available under the Open Font License (OFL), meaning it is free to use, modify, and distribute for both personal and commercial projects.
+
+The **MovieVerse platform** uses the Poppins font family for various design elements, including headings, subheadings, and body text, to create a modern and clean aesthetic.
+
+## Contents
+
+The directory includes a total of 18 TrueType Font (TTF) files, covering a comprehensive range of weights and styles:
+
+1. **Poppins-Black.ttf** - The heaviest weight of the Poppins family, suitable for impactful headlines.
+2. **Poppins-BlackItalic.ttf** - Italic version of the Poppins Black, adding emphasis and style.
+3. **Poppins-Bold.ttf** - Bold weight for strong emphasis in text.
+4. **Poppins-BoldItalic.ttf** - Italic version of the Poppins Bold.
+5. **Poppins-ExtraBold.ttf** - An extra bold weight providing a step between Bold and Black.
+6. **Poppins-ExtraBoldItalic.ttf** - Italic version of the Poppins Extra Bold.
+7. **Poppins-ExtraLight.ttf** - Much lighter than the regular weight, for a subtle elegance.
+8. **Poppins-ExtraLightItalic.ttf** - Italic version of the Poppins Extra Light.
+9. **Poppins-Italic.ttf** - A standard italic style for general emphasis.
+10. **Poppins-Light.ttf** - Lighter than the regular weight for delicate headings or text.
+11. **Poppins-LightItalic.ttf** - Italic version of the Poppins Light.
+12. **Poppins-Medium.ttf** - Medium weight that stands between regular and bold.
+13. **Poppins-MediumItalic.ttf** - Italic version of the Poppins Medium.
+14. **Poppins-Regular.ttf** - The standard weight of the Poppins family for body text.
+15. **Poppins-SemiBold.ttf** - Slightly bolder than medium, ideal for subheadings.
+16. **Poppins-SemiBoldItalic.ttf** - Italic version of the Poppins SemiBold.
+17. **Poppins-Thin.ttf** - The lightest weight, for very subtle and fine text.
+18. **Poppins-ThinItalic.ttf** - Italic version of the Poppins Thin.
+
+## Usage
+
+The Poppins font family can be used for a variety of design purposes, including web design, graphic design, print, and user interface design. To use a font, simply install the desired TTF file on your system.
+
+For the MovieVerse, the Poppins font family is used in the website design to maintain a consistent and modern look across different sections and elements. It is particularly well-suited for headings, subheadings, and other text elements that require a clean and contemporary appearance.
+
+For example:
+
+```css
+body {
+ font-family: 'Poppins', sans-serif;
+}
+```
+
+## Installation
+
+To install a font, follow the instructions based on your operating system:
+
+- **Windows**: Right-click on the font file and select 'Install'.
+- **macOS**: Double-click the font file and select 'Install Font'.
+- **Linux**: Use the font management software provided by your distribution or manually copy it to `/usr/share/fonts` (for system-wide installation) or `~/.fonts` (for user-specific installation).
+
+## Licensing
+
+The Poppins font family is licensed under the SIL Open Font License, Version 1.1. This license allows you to:
+
+- **Use** the font for personal and commercial purposes.
+- **Modify** the font for personal and commercial purposes.
+- **Distribute** the font under the same license.
+
+For the full text of the license, see the included OFL.txt file or visit [http://scripts.sil.org/OFL](http://scripts.sil.org/OFL).
+
+Usage of these fonts are also subject to the MovieVerse project license, **CC BY-NC 4.0**. For more information, refer to the [LICENSE](LICENSE.md) file.
+
+## Acknowledgements
+
+Poppins was created by Jonny Pinhorn, so we extend our gratitude to him for designing this beautiful typeface. We also thank the Indian Type Foundry for making the font available under an open license, allowing designers and developers to use it freely in their projects.
diff --git a/src/main/resources/org/example/game2048javafx/hello-view.fxml b/src/main/resources/org/example/game2048javafx/hello-view.fxml
new file mode 100644
index 0000000..9f9cd28
--- /dev/null
+++ b/src/main/resources/org/example/game2048javafx/hello-view.fxml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/org/example/game2048javafx/styles.css b/src/main/resources/org/example/game2048javafx/styles.css
new file mode 100644
index 0000000..54a617d
--- /dev/null
+++ b/src/main/resources/org/example/game2048javafx/styles.css
@@ -0,0 +1,9 @@
+.root {
+ -fx-font-family: "Arial";
+ -fx-background-color: #faf8ef;
+}
+
+.label {
+ -fx-font-weight: bold;
+ -fx-text-alignment: center;
+}