Giter VIP home page Giter VIP logo

badsnake_raspi's Introduction

badSnake_RasPi

A bad version of Snake utilising the sence HAT module for the RaspberryPi.


Inspiration

I made a version of snake (in Java) during my free time at my internship last summer, since I had an unexpectedly large ammount of it. I had to write it in a text editor due me not beeing allowed to install third-party software on the conpany notebook. The result was, of course, not very polished and included a some bugs, missing documentation and a very s1mple UI (just the termial, using numbers as to display the game). It looked like this:

grafik

1 is the snakes Body, 2 is the head, and 7 is the apple.

I later remembered that I had purchased a raspberryPi and senceHat module some time ago, and that the game would work nicely on it. I just had to rewrite the game in Python and utilise the SenseHat API. I dont yet know how to do ... stuff, but I know that I might have to significantly change the code and logic for it to work.

Functionality

The badsnake.py file will run on the RasPi with the Sence HAT equiped. The LED-Array will display the game and the Joystick will accept inputs. When an input is detected, the programm will calculate the next frame and display it on the LED-Array. I think Im poing to use the sense.set_pixels method to display the Frame, but since I am very much a newbie when it comes to python and using lists, il will write a function to convert an Array to a list (so I can use Arras and only convert to a list when i need to display the frame). The Snake and apple will be coloured differently.

The Sence HAT module

The Sence HAT (Hardware Attached on Top) module is an add-on for the RaspberryPi. It has an 8ร—8 RGB LED matrix, a five-button joystick and includes multible sensors.

The SenseHat API

The SenseHat API has multible functions to address the LED panel and to detect inputs from the Joystick.

Update 2022-01-10

Testing the LED matrix using the set_pixels() method:

grafik

Update 2022-29-10

The game is now in a state that I am happy with. It is now a fully functioning experience, complete with player inputs, coloured Objects and bug-free gameplay. What it does not have, however, is a timer function, so that the snake moves automatically, regardless if you use the joystick or not. I have decided not to implement this to stay true to the original version I made in Java. Due to this, the player experiences a slightly different take on the game, allowing them to plan out their moves instead of being forced to pick a direction.

Sources

https://www.raspberrypi.com/products/sense-hat/

https://pythonhosted.org/sense-hat/api/

https://www.raspberrypi.com/news/introducing-raspberry-pi-hats/

badsnake_raspi's People

Contributors

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