Snake

Globa RPG Snake

snake

View on GitHubRaylib engine


Building a snake with RPG elements and experimenting with what feels right

This is a port of my original Snake game but rewritten in C++ with all the OOP paradigms. This game is easily extensible. Key structures are:

  • GamaManager: a Mediator object that connects and tells how other objects are connected;
  • Player, FoodManager: Proxies that connect to concrete objects and manage their states.
  • Map: A bridge that mostly manages textures, but because there’s not much going on there, it’s also responsible for Camera logic.

This project uses CMake to generate a Makefile. It downloads Raylib automatically and builds the project. Simply navigate to this directory and run

    mkdir build && cd build
    cmake -S ../ -B .
    make

That should create an executable. That’s it.


Work in progress

Icons from Freepik

https://twitter.com/Cethyel

Blog

Patch 1

GIF

  • Textures for background and foreground
  • 2 types of fruits
  • Zoom in/out
  • Camera follows player but clamps to edges when near walls
  • Project is divided into smaller files

Patch 2

GIF

  • Smoother update timing
  • Circles insted of squares
  • Snakes follows mouse pointer
  • No cells
  • Different color body parts
  • Render from tail to head e.g. head will be on top

Patch 3

GIF GIF

  • Sushi collectible that boosts a snake
  • Pizza collectible that cuts a tail in half
  • Move a snake with right/left keys. Space to boost

Patch 4

GIF

  • Map is a scaled down Europe (1 tile ~ 8km)
  • Snake grow in size (not only in length), turn angle decreases with size; boost speed increases
  • Only tiles that are close to the player are rendred
  • The information about tiles is stored as unsigned chars
  • Minor optimization fixes

Patch 5

  • Ported to C++
  • Implemented common OOP paradigms
  • Food objects pool is shrinked and follows player
  • CMake file (Classes.h is linked as a library. To add new files, add them in CMakeLists in /src and re run cmake)
  • More Camera tracking options

TODO

  • image bg outside the map
  • find good grass texture png files
  • different pickups:
    • regular plus point
    • bonus 10 point
    • many items at once
    • liited food (+ point, -tail)
    • boosts the speed
    • make bonus food animated
  • make a head differen color and on top of a body
  • different color body parts
  • make a snake accelerate
  • maps is split into 3 zones
  • a dropoff location where you can cut your snake but get bonus points
  • add sfx & music
  • make walls and shoot points to burst them or enemies
  • split project structure into different files + headers
  • add options to choose from 3-5 different snake swith different speed and maybe later stats
  • animations
  • textures for snake
  • easings for snake tail and camera
  • diagonal movement
  • arrow on top of a player that will be registering move buttons and show the final directions where it will turn.
  • get rid off cells
  • circles instead of squares
  • move snake with a mouse pointer
  • control moves with left/right, movement is constant
  • OR limit the turn angle
  • custom mouse pointer
  • make snake a dynamic array insted of static
  • health system: if you are continiously colliding with a terrain or enemies, you start to shrink back and loose your health score and body mass, but not actual score. (more global damages will be presented later)
  • if you spin in a circle, you gain the acceleration, after exiting it you gain a boost to your speed that decays
  • Render tiles that are close to the player
  • Increse radius and decrease turn angle with counterTail
  • Make a map tiled (Part 1)
  • Make a minimap
  • Switch to C++
  • Implement OOP features
  • Write CmakeFile
  • Food pool follows player