Giter Site home page Giter Site logo

snake-game's Introduction

Snake Game

Recreation of Nokia's popular Snake game using JFrame.

I made this app after taking my first Computer Science course in college. Since this is just the first working version, it does not contain different levels and only has an endless level.

CLASSES

  • Canvas: Contains all the computation.
  • Food: Defines the attributes of a "food" for the snake.
  • SnakeComponent: Defines the attributes of every component of the snake. This class is used to make a list of SnakeComponents that currently make up the snake.
  • Turn: Defines the x and y coordinates of every turn that the snake makes. This class is used to make a list of where the snake is going.
  • MyApp: Creates and makes the JFrame visible.

LOGIC

  • The snake is made using a list of SnakeComponents. Every SnakeComponent has its own attributes and follows the SnakeComponent in front of it.
  • The Food is generated randomly.
  • Collisions are detected when the head of the snake overlaps with the Food, itself, or with the corners.

INSTRUCTIONS

  • Press ENTER to start the game.
  • Avoid collision with walls and yourself and try to eat as much food as possible for a higher score.

snake-game's People

Contributors

sufian27 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.