diff --git a/.gitignore b/.gitignore
index fdf9154..b977e86 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,26 +1,52 @@
# Build directories
build/
cmake-build-*/
-
-# CMake files
-CMakeCache.txt
CMakeFiles/
-Makefile
+CMakeCache.txt
cmake_install.cmake
-build.ninja
-rules.ninja
-
-# Executables
-Snake
-*.exe
+Makefile
+*.cmake
# IDE files
-.idea/
.vscode/
-*.user
+.idea/
+*.swp
+*.swo
+*~
-# Testing
-Testing/
+# Compiled binaries
+Snake
+*.exe
+*.out
+*.app
-# OS files
-.DS_Store
\ No newline at end of file
+# Object files
+*.o
+*.obj
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Temporary files
+*.tmp
+*.temp
+*~
+
+# OS generated files
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
+
+# Game data
+best_score.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73cf1f3..c6e509c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,22 +1,49 @@
cmake_minimum_required(VERSION 3.10)
-project(Snake)
+project(Snake VERSION 1.0.0 LANGUAGES CXX)
-set(CMAKE_CXX_STANDARD 11)
+# Set C++ standard
+set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+# Set build type if not specified
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release)
+endif()
+
+# Compiler flags
+set(CMAKE_CXX_FLAGS "-Wall -Wextra")
+set(CMAKE_CXX_FLAGS_DEBUG "-g")
+set(CMAKE_CXX_FLAGS_RELEASE "-O3")
+
# Find SFML
find_package(SFML 2.5 COMPONENTS graphics window system REQUIRED)
-# Add executable
-add_executable(Snake
- main.cpp
- Game.cpp
- Snake.cpp
- Food.cpp
+# Source files
+file(GLOB_RECURSE SOURCES
+ "src/*.cpp"
+ "src/*.c"
)
-# Include headers
-target_include_directories(Snake PRIVATE .)
+# Create executable
+add_executable(${PROJECT_NAME} ${SOURCES})
-# Link SFML libraries
-target_link_libraries(Snake sfml-graphics sfml-window sfml-system)
+# Include directories
+target_include_directories(${PROJECT_NAME} PRIVATE include)
+
+# Link libraries
+target_link_libraries(${PROJECT_NAME}
+ sfml-graphics
+ sfml-window
+ sfml-system
+)
+
+# Copy assets to build directory
+if(EXISTS ${CMAKE_SOURCE_DIR}/assets)
+ file(COPY assets DESTINATION ${CMAKE_BINARY_DIR})
+endif()
+
+# Install rules
+install(TARGETS ${PROJECT_NAME} DESTINATION bin)
+if(EXISTS ${CMAKE_SOURCE_DIR}/assets)
+ install(DIRECTORY assets DESTINATION share/${PROJECT_NAME})
+endif()
diff --git a/LICENSE b/LICENSE
index 289cd60..8697917 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2025 Snake Game Project
+Copyright (c) 2025 DarkSnake Project
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 4a160e9..2784859 100644
--- a/README.md
+++ b/README.md
@@ -1,42 +1,49 @@
-# 🐍 Snake Game
+
+

-Classic Snake game implemented in C++ with a console interface.
+ **A modern Snake game built with C++ and SFML**
+
-## 📁 Project Structure
-- `main.cpp` — Entry point
-- `Game.*` — Game logic and rendering
-- `Snake.*` — Snake class implementation
-- `Food.*` — Food generation system
-- `Point.h` — Coordinate structure
-- `Direction.h` — Direction enumeration
-- `best_score.txt` — High score storage
-- `CMakeLists.txt` — Build configuration
+## ✨ Features
+- Modern graphics with SFML
+- WASD/Arrow key controls
+- Score tracking with best score persistence
+- Menu and pause functionality
+- Smooth collision detection
-## 🛠️ Requirements
-- C++11 or higher
+## 📋 Requirements
+- C++17+
- CMake 3.10+
-- Linux/Unix terminal
+- SFML 2.5+
-## 🎮 Features
-- Console-based graphics
-- WASD controls
-- Food generation
-- Collision detection
-- Growing snake mechanics
-- Score tracking
-- Best score persistence
-
-## 🎯 Controls
-- W — Move up
-- S — Move down
-- A — Move left
-- D — Move right
-- Q — Quit game
-
-## 📦 Build and Run
+## 🚀 Quick Start
```bash
+# Install dependencies (Ubuntu/Debian)
+sudo apt install cmake build-essential libsfml-dev
+
+# Build and run
mkdir build && cd build
-cmake ..
-make
+cmake .. && make
./Snake
```
+
+## 🎮 Controls
+- **WASD/Arrows** — Move
+- **Space** — Pause
+- **Enter** — Menu select
+- **Escape** — Menu/Quit
+
+## 📁 Structure
+```
+Snake/
+├── src/ # Source files
+├── include/ # Headers
+├── assets/ # Game assets
+└── CMakeLists.txt # Build config
+```
+
+## 🤝 Contributing
+Feel free to submit issues and pull requests!
+
+## 📄 License
+MIT License - see [LICENSE](LICENSE) file.
diff --git a/Direction.h b/include/Direction.h
similarity index 100%
rename from Direction.h
rename to include/Direction.h
diff --git a/Food.h b/include/Food.h
similarity index 100%
rename from Food.h
rename to include/Food.h
diff --git a/Game.h b/include/Game.h
similarity index 96%
rename from Game.h
rename to include/Game.h
index 43cf2d3..9b12b3d 100644
--- a/Game.h
+++ b/include/Game.h
@@ -53,7 +53,7 @@ public:
MenuButton* startBtn = nullptr,
MenuButton* exitBtn = nullptr,
MenuButton* restartBtn = nullptr,
- MenuButton* menuBtn = nullptr);
+ MenuButton* menuBtn = nullptr) const;
bool isGameOver() const { return gameOver; }
int getScore() const { return score; }
diff --git a/Point.h b/include/Point.h
similarity index 100%
rename from Point.h
rename to include/Point.h
diff --git a/Snake.h b/include/Snake.h
similarity index 100%
rename from Snake.h
rename to include/Snake.h
diff --git a/Food.cpp b/src/Food.cpp
similarity index 100%
rename from Food.cpp
rename to src/Food.cpp
diff --git a/Game.cpp b/src/Game.cpp
similarity index 98%
rename from Game.cpp
rename to src/Game.cpp
index 47f56e7..9495208 100644
--- a/Game.cpp
+++ b/src/Game.cpp
@@ -21,7 +21,7 @@ void Game::run()
{
sf::RenderWindow window(sf::VideoMode(BOARD_WIDTH * CELL_SIZE, BOARD_HEIGHT * CELL_SIZE + 60), "Snake Game");
sf::Clock clock;
- float timer = 0.0f, delay = 0.15f;
+ float timer = 0.0f;
// Menu buttons initialization
MenuButton startBtn, exitBtn, restartBtn, menuBtn;
@@ -57,7 +57,8 @@ void Game::run()
if (!paused && !gameOver && !inMenu)
{
- timer += clock.restart().asSeconds();
+ float delay = 0.15f;
+ timer += clock.restart().asSeconds();
if (timer > delay)
{
update();
@@ -213,8 +214,7 @@ void Game::processEvent(const sf::Event& event, sf::RenderWindow* window,
// Rendering with interactive menu buttons and centered text
void Game::render(sf::RenderWindow& window,
MenuButton* startBtn, MenuButton* exitBtn,
- MenuButton* restartBtn, MenuButton* menuBtn)
-{
+ MenuButton* restartBtn, MenuButton* menuBtn) const {
// Draw gradient background
sf::VertexArray background(sf::Quads, 4);
background[0].position = sf::Vector2f(0, 0);
@@ -477,11 +477,10 @@ void Game::loadBestScore()
bestScore = 0;
}
-void Game::saveBestScore()
-{
- std::ofstream out(BEST_SCORE_FILE);
- if (out)
- out << bestScore;
+void Game::saveBestScore() {
+ std::ofstream out(BEST_SCORE_FILE);
+ if (out)
+ out << bestScore;
}
void Game::reset()
diff --git a/Snake.cpp b/src/Snake.cpp
similarity index 100%
rename from Snake.cpp
rename to src/Snake.cpp
diff --git a/main.cpp b/src/main.cpp
similarity index 100%
rename from main.cpp
rename to src/main.cpp