Giter VIP home page Giter VIP logo

snake-game's Introduction

snake-game

My Snake Game Project

For this project, I used the DoublyLinkedList data structure implemented in homework. It includes the following methods:

-init(): initializes an empty list -str(): returns a string representing the list -is_empty(): returns True if list is empty, False otherwise -get_size(): returns size of list -add_first(v): adds v at head of list -add_last(v): adds v at end of list -remove_first(): removes and returns first value in list -remove_last(): removes and returns last value in list -first(): returns first value in list -last(): returns last value in list -search(v): returns index of value if found and -1 otherwise -get(i): returns value at index i

I used a function to verify that my DoublyLinkedList works.

The Game

I thought about what classes to create and what data they should have and represented the world as a grid and set the x and y scale accordingly. I also used the following starting code for the main part of my program. This ensures that keyboard presses are processed in timely fashion while also making sure the snake is moving at a reasonable speed.

    limit = 20 # number of frames to allow to pass before snake moves
    timer = 0  # timer to keep track of number of frames that passed
    while(True):
        timer += 1
        # process keyboard press here
        if timer == limit:
            timer = 0
            # draw and move snake
            # check if snake ate fruit
            # check if snake self intersects
    
        dudraw.show(40)

Screenshot 2023-07-05 084600 Screenshot 2023-07-05 084659

snake-game's People

Contributors

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