GithubHelp home page GithubHelp logo

consolesnake's Introduction

ASCII Snake In Console/Terminal Window

Description

The snake is inspired on tutorial videos from https://www.youtube.com/@NVitanovic

The changes I made are:

  • enclosed the game in a C++ class (instead of using global variables and functions)
  • added linux equivalents of _kbhit() and _getch() from <conio.h> for Linux with a healp of #if defined() macros. (The <conio.h> library is supported only on Windows)
  • Created a makefile for linux build
  • replaced raw c-style arrays with vectors
  • added new features like multiple frogs spawning, different game modes and sprint kaey
  • used my own coding style

The game has 4 modes: IMMORTAL, EASY, MEDIUM and HARD; To select one you need to specify it in the game constructor like:

SnakeGame game = { SnakeGame::GameMode::MEDIUM };

There is also 0 arg constructor which runs MEDIUM game mode.

Each game mode has its own features:

  • IMMORTAL:
    You can't be killed by hitting the wall or biting your tail. (The only way to end the game is by clicking the `X` key.) Walking into a wall will teleport the snake's head into the other side.
  • EASY:
    You can die biting your tail, but walls will still teleport you to the other side.
  • MEDIUM:
    You will die by bting your tail or hitting the wall.
  • HARD:
    You will die by biting your tail or hitting the wall. On each eaten frog the snake will go faster (till a certain point). This should make the game increasingly harder

Control snakes directions with WASD / wasd keys. You can activate sprint with the . key. (You can't control directions while sprinting) The sprint key can be changed in the code by modifying _SPRINT_KEY value. To exit game press X key.

The goal is to consume frogs spawning on the screen. The number of spawned frogs on the screen can be changed by modifying the value of _AMOUNT_OF_FROGS_SPAWNING.

You can also make the game faster or slower by modifying the START_REFRESH_RATE_MS const value.

Demo

consolesnake's People

Contributors

cxnajder avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.