Giter Club home page Giter Club logo

ascii-snake's Introduction

Snake

Snake game implemented with a linked list, for gnu / linux (not planning to make it accesable to windows).

Needs:

ncurses mainly and a gnu based os.

How to compile

g++ game.cpp -lncurses -o [filename]
./[filename]

Controls

w -> up

s -> down

a -> left

d -> right

r-> reverse

How its implemented

Again, its implemented with a linked list. The linked list is comprised of node objects that contain a cordinate, a direction, and a pointer to the father and child node in the list. This whole list manifests the snake.

How the snake moves: each node grabs the direction from their father node and updates their position with their new direction.

How the snake reverses: each node grabs their childs direction then inverts it, then switches their parent and child node pointers. Finally the head and tail opf the snake are swapped.

Everything else is simply, basic looping throght the linked list and oop stuff.

Bugs

prob_1: apples can be place in the snake. For apple detection the head and the apple's position are only checked, so if an apple is placed in the snake the apple will not be eaten but be earased. Thus, the apple will be forever forgoten and lost.

fix_1: let the tail of the snake relocate the apple (lazy, but less comutation). Or! check the apple isn't being placed in the whole snake (computation heavy, and isn't more than 5 - 10 lines of code).

prob_2: the border gets magically earased. Why! dunno.

fix_2: have a method to check coordinates are in the border, and only place carachters when they are within the border. (doesn't fix og problem and has to be used everytime a char is placed)

Future

make a menu class with the ability to add buttons with diferent funcs (setting values, onening pages, and etc). (ambitious, but can be used for multiple applictions and might prove to be usfull for a variety of things) (80% chance I will implement this in the future, but might not be for a while (finals are about to jumpsacre me)).

add a pause / quit button (50% of implimentation, to lazy and ctrl + c works fine)

fix the speling erors in here (10% chance of me ever doing this, but be welcome to if you want too.)

Author

Mason John Hawver, freshman @ wvhs (http://wvhs.ipsd.org/Default.aspx).

ascii-snake's People

Contributors

masonjohnhawver42 avatar

Stargazers

 avatar

Watchers

James Cloos 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.