Git Product home page Git Product logo

tunnel-matrix's Introduction

Pygame Virtual LED matrix

Apologies in advance for the spaghetti code. I wrote this a long time ago when I was first learning.

That said, it was very difficult to get right and I am still proud of myself for figuring this out without help.

And don't worry, I'm fixing it...

Instructions

Uses Pygame to render the graphics.

Each file is a slightly different tunnel pattern.

First you must install dependencies:

pip install -r requirements.txt

To run the tunnel.py program:

python tunnel.py

Press space bar to start or stop movement, V to change direction, and X to add the 'X' to xfold pattern.

About

This was a program I wrote in my early days of learning programming. It was extremely difficult for me
to devise an algorithm for the pattern and even today I'm having trouble understanding exactly how I got
this all to work. My plan is to refactor this over time as the design choices I made and my variable
naming are pretty cringeworthy.

I had one major problem that I learned a lot from when making this. Time and space complexity was a
mysterious concept to me at the time of writing this. My initial strategy was building a matrix of RGB color
tuples then using Pygame to render squares of these colors. At each frame I would change each value in the
matrix and render again. I tried scaling to a 256 x 256 square it did not like that. Went from 30 FPS to
about 0.2 FPS.

Back to the drawing board...

I realized I didn't need to store a matrix in memory at all. I could simply come up with a way to
calculate the index of the colors list using the row and column index. After that is was just a matter of
applying something from back in Pre-Calculus class, graph reflections!

tunnel-matrix's People

Contributors

kaedub avatar

Watchers

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