Code Monkey home page Code Monkey logo

matrixproject's Introduction

MatrixProject

This is the final Matrix Game. I used a breadboard, a joystick and a button to develop a retro game controller. To the Arduino Uno I connected an LCD Screen too where it should display the menu of the future game.

Implementation Ideas

I tought the menu as a DFA. I created a matrix of movements like the transition function. START GAME state is connected to the GAMEPLAY state, SETTINGS state is connected to the Username state which is related as well with Difficulty state and so on.

The game should store those info somewhere and I prepared it to be written on Arduino UNO's EEPROM. I defined a struct for the system's info(eg. matrix brightness) and a struct for player's info(his 3 letters name and his score). The EEPROM should be updated with the system info and the highscores of 3 best players only when it was changed because we should avoid excesivly excessively writing on this type of memory.

The refresh time of the LCD display is 250ms which means the refresh frequency rate is 4Hz.

One move UP or DOWN of the joystick can iterate only to the next state, even if the user is holding it. The exception is made at username, you cand iterate trough all characters just by holding it UP or DOWN because it's faster to choose your name. In the first place I used one move one iteration for the username too but it was too slow.

Link Video 1

Snake Logic

I used a 8x8 matrix of 1 and 0 to keep in memory the states of each of the matrix leds. For the logic of the snake there is one deque list to store every position of the snake's points that form the actual snake. At every step one point is cut from the tail and one is added on the head. The head is generated carefully, in order to fit the snake's direction.

Generating food for snake is done by pseudo-random values that must not spawn under our character.

The refresh time of the game is 600ms. When score 5 is hit, every time it eats a generated food the difficulty increases by 25. The difficulty of the game consists of decreasing the refresh time of the game by the value of difficulty (refresh_time - difficulty).

e.g. Score 5 => refresh_time = 600 - 0,

Score 6 => refresh_time = 600 - 25,

Score 7 => refresh_time = 600 - 50 and so on until difficulty value hits 225.

This project uses an opensource c++ implementation of Deque: Repository link

Link Video Gameplay

45

WhatsApp Image 2022-12-06 at 13 34 54

matrixproject's People

Contributors

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