Skip to content

Backend for Snek3D game, originally made to be played on a 3d LED Cube.

License

Notifications You must be signed in to change notification settings

frak0d/Snek3D-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Snek3D-Backend

This repo contains the backend for Snek3D game, originally made to be played on a 3d LED Cube.


Usage (pseudocode) :-

#include "SnekGame3D.hpp"

int main()
{
	SnekGame3D<uint8_t> game(12,10,16); // create a 12x10x16 cuboid world,
					    // uint8_t is enough to hold the coordinates
	
	while (true)
	{
		/*
		 * Movement chars :-
		 * x : -x axis
		 * y : -y axis
		 * z : -z axis
		 * X : +x axis
		 * Y : +y axis
		 * Z : +z axis
		 */
		char key = getControllerKeyPress();
		
		if (game.nextFrame(key)) // nextFrame() returns false on game over
		{
			// display points in game.snek deque as white
			// and game.food point as red color (like 🍎)
			
			// length_of_snake = game.snek.length()
			// current_score = game.score
			
			// game.snek is a deque of Point3D objects (has x,y,z variables)
			// so snake head position = game.snek[0]
			// x coordinate of snake head = game.snek[0].x
		}
		else
		{
			// game over
		}
		
		// sleep(0.5 seconds) to reduce snake speed
		// otherwise it's too fast to be playable
	}
}

About

Backend for Snek3D game, originally made to be played on a 3d LED Cube.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages