GithubHelp home page GithubHelp logo

html-spaceship's Introduction

HTML Spaceship

This library adds a spaceship onto your web page.

To install:

npm i html-spaceship

The main file exports a run function that takes in a config object.

const config: Config = {
  keys: {
    left: 'ArrowLeft',
    right: 'ArrowRight',
    up: 'ArrowUp',
    down: 'ArrowDown',
    deactivate: 'Escape'
  },
  wrapWordsClass: 'wrap',
  removedClass: 'removed',
  theme: 'light',
  speed: 8
};

// to lazy load
(await import('html-spaceship')).default(config);

//regular import
import runSpaceship from 'html-spaceship'
runSpaceship(config)

The keys property allows you to define the keys responsible for the movement and the key you want to use to deactivate the program.

The wrapWordsClass property allows you to attach a class signifying which words are shoot-able. The program will take all the elements with the class name defined in wrapWordsClass and wrap each word in a span element with the class name "shootable-el".

The "speed" property defines how fast the spaceship moves.

The 'removedClass' serves as the class that styles elements that have been destroyed. This is the only non-optional property.

Boundaries and shootables

Define your boundaries by attaching "boundary" as a class to the elements you'd like to act as walls. Define elements that can shot at and "destroyed" by attaching the class "shootable_el".

html-spaceship's People

Contributors

nksupermarket avatar

Stargazers

 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.