SnakeGame

my snake game version, made in lua and Love2D to CS50 final project


๐Ÿ Snake Game V2 ๐Ÿ

My CS50 Final Project

- ๐Ÿง  About the idea of โ€‹โ€‹the game ๐Ÿง 

As i followed the games track and iโ€™m also passionate about retro games, so i decided to produce my version of the snake game. When I was in the middle of development I decided to create something more, as I am an enthusiast in the field of artificial intelligence, I went after creating the AI โ€‹โ€‹play option, however as I do not have all the knowledge about, I soon used a simpler device. What I used was a simple algorithm that observes which direction brings the character closer to the apple, giving the slight impression that the character knows what he is doing. moreover, I decided to add some things in the right game that would make it more difficult, since I removed the collisions with the tail.

- ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป About project ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป

This game has been made with Lua and Lร–VE engine.

In this project we have those archives:

  • main.lua: This archive have the instructions to make the visual part of game;
  • Decision.lua: This archive is a simple library used to make decisions in the AI play;
  • push.lua: A library to make more simple the production of the visual part of your game;
  • fonts: Inside this folder there is the font used;
  • assets: This folder has the all images of the game;
  • sounds: Inside this folder we can found the sound effects used in the game;
  • images: Used images in this md file.



- ๐Ÿ‘พ About the game ๐Ÿ‘พ

In this version of snake game we have two choices:

  1. Human Play
    • You can play normally, how in the original game.
  2. Ai play
    • the machine plays the game. In this version of the snake game I chose to remove the snakeโ€™s collision with the tail and add some obstacles, of which are:
  • Bananas: When you collide with one of them your score decreases 1 point, if you collide several times and your score is less than 0 you lose. There are a total of 11 bananas and they all remove 1 from your score.
    when you crash into a banana, your time does not restore and all bananas and apples are moved.
    </br>

    Banana appearance




    </br>

  • Apple: When you touch a apple your score increases by 1, however there are 11 apples on the map and only one increases your score the other 10 do absolutely nothing.
    when you collide with an apple your time is restored and all the apples and bananas are moved from position.
    </br>

    Apple appearance




    </br>

  • Fast 1: Fast 1 is a blue region present in 3 regions of the map, where when there is a passage over this obstacle its speed increases by 1, resulting in a speed of 2, however this obstacle can be used to gain an advantage, helping for example to arriving before 5 seconds on an apple, or it can harm, as for example end up passing the wall or hitting a banana.
    </br>

    Fast 1 appearance




    </br>

  • Fast 2: Fast 2 has the same foundation as fast 1 so that in this case it increases its speed to 3.
    </br>

    Fast 2 appearance




    </br>

when you have a 999 score the games end whit a victory message.
</br>

๐Ÿฅ‡ Win example ๐Ÿฅ‡




</br>

But case you die.
</br>

๐Ÿ’€ Died example ๐Ÿ’€



Losing colliding with wall



Losing by -1



Losing by time



- ๐ŸŽฎ Controls ๐ŸŽฎ

  • Space (works in initial screen): select the AI play;
  • Enter (works in initial screen): select human play;
  • Backspace (works in all screens): return to the initial screen;
  • Arrow keys (human play): control the direction of snake (human play case).



- ๐Ÿ”Š Sounds ๐Ÿ”Š

The sounds has been made by: crazyduckgames
You can download them in: soundpack
His opengameart profile: crazyduckgames

- ๐Ÿ–ผ๏ธ Sprites ๐Ÿ–ผ๏ธ

All sprites has been made by me, using pixilart web application.
Pixilart can be accessed in: pixilart



- ๐Ÿƒ How to run ๐Ÿƒ

Linux

PPA (Ubuntu)

1. Download and install Love2d

sudo add-apt-repository ppa:bartbes/love-stable
sudo apt-get update
sudo apt-get install love

2. Run game

git clone https://github.com/Dude-rgb/Snake-game-CS50-final-Project.git
love Snake-game-CS50-final-Project

AppImage

1. Download AppImage on love2d website

2. Add execution permission to the file

chmod +x love.AppImage

3. Run game

git clone https://github.com/Dude-rgb/Snake-game-CS50-final-Project.git
./love.AppImage Snake-game-CS50-final-Project

NOTE: the name love.AppImage is arbitrary please put the name of your archive

Windows

zip file

1. Download the zip file on love2d website

2. Get game and run

git clone https://github.com/Dude-rgb/Snake-game-CS50-final-Project.git
love.exe Snake-game-CS50-final-Project

NOTE: the name love.exe is arbitrary please put the name path of your archive

Installer

1. Download the exe file on love2d website and install

2. Create a shortcut on your desktop (or other place), go to the path where love is installed and go to send to desktop

3. Drag and drop the folder (Snake-game-CS50-final-Project) on love2d shortcut

Mac

1. Download and install love2d

2. check if love has permissions to execute

3. Get game

git clone https://github.com/Dude-rgb/Snake-game-CS50-final-Project.git

4. Drag and drop the folder (Snake-game-CS50-final-Project) on love2d app



- ๐Ÿค” How to play ๐Ÿค”

  1. First you need to select the mode of game, case you want to to play press ENTER else case you want to see the machine playing press SPACE.
  1. After choosing your game mode, if it has the human play (ENTER command) then you must use the arrow keys to change the snakeโ€™s direction.
    !ATTENTION!

When the game starts you have 3 seconds of invincibility after that the timer starts counting your 5 seconds, if you manage to get the right apple in this time your timer restarts and all apples and bananas, besides be careful also with bananas, all remove one point from your score, restore all positions of apples and bananas and finally keep your accountant by counting your time.



  1. Otherwise if you choose Ai play you simply need to watch the machine trying to win the game.
    !NOTE!

All obstacles and features that you had in Human play are present in Ai play except the control with the arrow keys





  1. While the game is running you can return to the home screen using the Backspace key or if you want to exit just use the ESC key.

Return button

And...