bestCoderEver1111 / react-gameboy

Game is available. Play now !

Home Page:https://react-gameboy.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gameboy

React Gameboy ๐Ÿ๐ŸŽ๐ŸŽฎ

About

The main idea was to create my own game logic without using canvas or any side game library. Snake ๐Ÿ mechanics is written with help of custom written hooks. So the whole game engine is just written with pure js and react. Below you can find more information about how this whole mechanism works.

Gameboy

How it works

All logic is broken down into several hooks: useSnakeMotion, useSnakeHasFailed, useSnakeColor, useRandomFoodCoordinate, useLastControlKeyPressed. And the main hook useSnake simply combines the work of above hooks.

Then GameplayScreen component calls useSnake hook

const snakeData = useSnake();

So snakeData contains all the information needed to render the whole game snake logic in UI. The snakeData is rendered on the special ui grid.

The grid is just a matrix with a size of 144 elements:

const sizeOfMatrix: number = 144;
const matrix: Array<number> = [...Array(sizeOfMatrix)].map((el, i) => i);

Fully mobile optimized:

Mobile Gameboy

How to start locally

  1. npm install - install all dependencies
  2. npm start - start a project

Technologies used

  • React
  • Redux Toolkit
  • Typescript

About

Game is available. Play now !

https://react-gameboy.netlify.app/


Languages

Language:TypeScript 82.5%Language:CSS 13.2%Language:HTML 4.3%