Professional Documents
Culture Documents
Snek
Snek
Submitted By
3COE-5
Welcome to "Snek"! 🐍
"Snek" is a computer game based on the old snake game we used to play. It's made using C++ and
OpenGL, which help make the game look nice and run smoothly. In "Snek," you control a snake that
moves around a grid and eats food to get points. But be careful! If the snake runs into itself or the
edges of the game, it is game over. Each time the snake eats, it gets longer, making it harder to avoid
obstacles. "Snek" brings back the fun of the classic snake game in a modern way that is easy to enjoy.
TABLE OF CONTENTS
2
1. Introduction
"Snek" is a nostalgic journey back to the golden era of gaming, offering a modern twist on the classic
snake game we all know and love. Developed using C++ and OpenGL, this project brings the timeless
joy of guiding a snake through a grid-based world right to your desktop.
With captivating graphics and smooth gameplay mechanics, "Snek" challenges players to navigate
their snake through a maze, gobbling up food and growing longer with each bite. But beware of
colliding with yourself or the walls – one wrong move could mean game over!
Join us as we embark on an adventure filled with fun, nostalgia, and plenty of slithery action. Are you
ready to unleash your inner snake charmer? Let's dive into the world of "Snek" and see if you have
3
3. User Defined Fucntion
Function_name Parameter Passed Description
keyboard() 1. key: ASCII value of the key pressed. Handles keyboard input for
2. (x,y): x-y coordinate of the mouse controlling game actions such as
pointer when the key is pressed. starting a new game, showing
instructions, or quitting.
output() 1. (x,y): x-y coordinate of the text position Draws text on the screen at
2. string: The text to be displayed. specified coordinates, using the
specified font and size.
drawstring() 1. (x,y): x-y coordinate of the text. Draws text on the screen at
2. string: The text to be displayed. specified coordinates using the
3. font: The font to be used for rendering specified font.
the text.
4
5
Function_name Parameters passed Description
random() 1.(&_min , &_max): Reference to Generates random coordinates for
the variable to store the placing food on the game grid,
minimum/maximum value of the ensuring varied and unpredictable
random coordinate. food placement.
reshape_callback() 1. w: The new width of the window. Callback function for handling
2. h: The new height of the window. window resizing, adjusting the
viewport and projection settings
accordingly.
keyboard_callback() 1. key: The special key pressed. Callback function for handling
2. (x,y): x-y coordinate of the special keyboard keys such as arrow
mouse pointer when the key is keys for controlling the snake's
pressed. movement.
main() 1. argc: The number of command- Main function that initializes the
line arguments. GLUT environment, sets up display
2. argv: An array of command-line and keyboard callbacks, and starts
argument strings. the main event loop for processing
user input and rendering graphics.
4. Code Snippets
6
7