Skip to content

About

I practice c++ and sdl3 and vulkan with Ai cloud , as I practice to do project

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snake — Vulkan

A Snake game using SDL3 + Vulkan 1.3 + CMake, featuring:

  • Fire shader (FBM noise, additive blending) bursts at the food position when the snake eats
  • Soft drop shadows under every snake segment and the food
  • Smooth snake taper — head is bright lime, tail fades to dark green
  • Pulsing food circle with specular highlight and glow ring
  • Zero vertex buffers — geometry is generated directly in the vertex shader

Requirements

Tool Min version
CMake 3.20
C++ compiler C++17 (GCC 11, Clang 14, MSVC 2022)
Vulkan SDK 1.3.x — includes glslc
GPU driver Vulkan 1.3 with dynamicRendering + synchronization2

Install the Vulkan SDK from https://vulkan.lunarg.com/ and make sure glslc is on your PATH (or set VULKAN_SDK env variable).

All C++ dependencies (SDL3, fmt, vk-bootstrap, VulkanMemoryAllocator, glm) are fetched automatically by CMake via FetchContent — no manual installs.


Build

git clone <this-repo>
cd snake-vulkan

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel

cd /build
./SnakeVulkan          # Linux / macOS
cd build\Release  #Windows
.\SnakeVulkan.exe  # Windows

Debug build (validation layers enabled)

cmake -B build-dbg -DCMAKE_BUILD_TYPE=Debug
cmake --build build-dbg
cd ./build-dbg
./SnakeVulkan

Controls

Key Action
W / ↑ Up
S / ↓ Down
A / ← Left
D / → Right
R Restart
Esc Quit

Project layout

snake-vulkan/
├── CMakeLists.txt
├── shaders/
│   ├── quad.vert       GLSL vertex  — generates a quad from vertex index
│   └── quad.frag       GLSL fragment — 4 modes: solid / fire / shadow / circle
└── src/
    ├── Types.hpp       PushConstants, DrawMode, palette constants
    ├── Game.hpp / .cpp Pure game logic (no Vulkan)
    ├── VulkanContext.hpp / .cpp
    │                   Instance · physical device · logical device · swapchain
    │                   (vk-bootstrap) · VMA allocator · frame sync objects
    ├── Renderer.hpp / .cpp
    │                   Two pipelines (alpha-blend / additive) · draw calls ·
    │                   NDC coordinate helpers · dynamic rendering (VK 1.3)
    └── main.cpp        SDL3 window · event loop · game + renderer glue


About

I practice c++ and sdl3 and vulkan with Ai cloud , as I practice to do project

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages