Skip to content

LeonardoPinheiroLacerda/SnakeGameJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to use:

Instalation

Using unpkg cnd:

    <script src="https://unpkg.com/snakegamejs-component@1.1.0/snakeGame.js"></script>

Using npm:

    npm i snakegamejs-component

All arguments on the constructor are optional

const snakeGame = new SnakeGameJS(
    {
        dimensions: {
            fieldWidth: 32,
            fieldHeight: 16,
            pixelSize: 25
        },
        colors: {
            snake: {
                body: '#54eb7c',
                outlineColor: '#FFF',
                brightnessGradient: .5
            },
            food: '#FF0000',
            background: '#b0c6e8'
        },
        outlines: {
            snake: 2,
            font: 4,
        },
        texts: {
            font: 'Arial',
            color: 'black',
            outlineColor: 'white',
            score: {
                text: 'Pontos:',
                size: 25,
                margin: 10
            },
            pause: {
                text: 'Clique para jogar',
                size: 40,
            },
            countDown: {
                size: 50,
            },
            gameover: {
                mainText: 'Perdeu!',
                pressSpaceToContinueText: 'Pressione espaço para jogar novamente',
                size: 30,
                margin: 20
            },
            win: {
                mainText: 'Você venceu!',
                pressSpaceToContinueText: 'Pressione espaço para jogar novamente',
            }
        },
        difficulty: 2,
        initialBodyLength: 3,
        bodyIncrementPerScore: 2,
        secondsToReturnAfterPause: 0,
        initialFoodQuantity: 10,
        parentElement: document.querySelector('#game'),
    }
);
//To start the game use the function init
snakeGame.init();

//To stop the game process use the function dispose

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published