Skip to content

artic2702/Snake_game_in_cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

🐍 Snake Game (C++ Console)

A simple classic Snake game built using C++ for the Windows console. The snake moves using keyboard input, eats fruit to grow longer, and the game ends when it hits a wall or itself.

🎮 Controls

Key Action
W Move Up
A Move Left
S Move Down
D Move Right
X Exit Game

⚙️ Features

  • Console-based UI
  • Snake grows when eating fruit
  • Score tracking
  • Wall collision detection
  • Self-collision detection
  • Adjustable game speed

🛠 Requirements

  • Windows OS

  • C++ Compiler (g++, MSVC, etc.)

  • Headers used:

    • <iostream>
    • <conio.h>
    • <cstdlib>
    • <ctime>
    • <windows.h>

▶️ How to Run

Compile:

g++ snake_game.cpp -o snake_game

Run:

snake_game

⏱ Speed Control

In main() function:

Sleep(300);  // Increase for slower game
Value Speed
100 Fast
200 Normal
300 Slow
400 Very Slow

📁 Project Structure

snake-game/
├── snake_game.cpp
├── .gitignore
└── README.md

Built as a learning project to practice:

  • C++
  • Game logic
  • Keyboard input
  • Git & GitHub usage

Enjoy the game! 🎉

About

First game project and game i ever made myself

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages