BalioFVFX / Kotlin-Snake

Terminal based Snake Game Written In Kotlin using the Lanterna Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kotlin Snake ๐Ÿ

Preview

Technologies

The Kotlin programming language and the Lanterna library which is used for printing on the terminal.


Introduction

The board consists of:

  • Bricks ('#') ๐Ÿงฑ
  • Grass (' ') ๐ŸŸฉ
  • Apple ('o') ๐ŸŽ
  • Pear ('d') ๐Ÿ

The snake is walking on top of the board and is represented by the ('*') character. Also the snake's head has a green color ๐Ÿ


In details...

The Brick, Grass, Apple and the Pear are classes that inherit the SolidEntity class so every one of them has a collideWith(snake). The Brick takes 100 health points from the snake while the Grass takes 0 health points.

Each food has it's very own effect. For example when the apple is eaten the snake tail increases but when the pear is eaten the snake direction changes.

In order to play the game you only need to provide a 2D array with solid entities (which can be created with the LevelParser) to the Game class. The Game class will create the snake at appropriate position and after that the game starts! ๐Ÿ’ฅ


Designin your own levels

Game level is any .txt file which follows the following criterias:

  1. The first line represents the width (Integer)
  2. The second line represents the height (Integer)
  3. The game field must be surrounded by walls, you can place additional walls inside the field by your design.

Example:

30
10
##############################
#                            #
#    ######                  #
#         #              #   #
#         #              #   #
#                        #   #
#                            #
#                            #
#                            #
##############################

How to play

  1. Download the project then put your level inside the root directory of the project. ๐Ÿ“ฉ
  2. Compile ๐Ÿ“Š
  3. Enter the file name with it's file extension type (or use the provided level1.txt) ๐Ÿ“
  4. Play ๐ŸŽฎ

About

Terminal based Snake Game Written In Kotlin using the Lanterna Library


Languages

Language:Kotlin 100.0%