Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/moroboxai/moroboxai-player-react

Embeddable player for running MoroboxAI games in React
https://github.com/moroboxai/moroboxai-player-react

artificial-intelligence library moroboxai react reactjs sandbox typescript

Last synced: about 2 months ago
JSON representation

Embeddable player for running MoroboxAI games in React

Awesome Lists containing this project

README

        

# moroboxai-player-react

[![NPM version](https://img.shields.io/npm/v/moroboxai-player-react.svg)](https://www.npmjs.com/package/moroboxai-player-react)
![Node.js CI](https://github.com/moroboxai/moroboxai-player-react/workflows/Node.js%20CI/badge.svg)
[![gitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/moroboxai/moroboxai-player-react/blob/master/LICENSE)
[![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/moroboxai/moroboxai-player-react.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/moroboxai/moroboxai-player-react/context:javascript)
[![Total Alerts](https://img.shields.io/lgtm/alerts/g/moroboxai/moroboxai-player-react.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/moroboxai/moroboxai-player-react/alerts)

Embeddable player for running [MoroboxAI](https://github.com/moroboxai) games in [React](https://reactjs.org/).

## Installation

Using npm:

```bash
npm install moroboxai-player-react --save
```

Or:

```bash
git clone https://github.com/moroboxai/moroboxai-player-react.git
cd moroboxai-player-react
npm i
npm run build
```

## Usage

Setup a simple React app with:

```bash
npx create-react-app my-app --template typescript
```

Add `moroboxai-player-react` as a dependency:

```bash
cd my-app
npm install moroboxai-player-react --save
```

Replace `src/App.tsx` with:

```javascript
import "./App.css";
import Player from "moroboxai-player-react";

function App() {
return (






);
}

export default App;
```

Build and start a local server to see the result:

```bash
npm run build
npm run start
```

## Props

| Name | Type | Default | Description |
| :-------- | :------ | :------ | :--------------------------------------------------------------------------------------------------- |
| url | string | | URL of the game |
| splashart | string | | URL of the placeholder image displayed before the game is loaded |
| width | number | | Width of the `div` element |
| height | number | | Height of the `div` element |
| resizable | boolean | true | If the game can resize the player |
| className | string | | Class name for the `div` container |
| autoPlay | boolean | false | Auto play the game after the player is initialized |
| speed | number | 1 | Speed of the game |
| onReady | func | noop | **Signature: function() => void**
Function called when the game is loaded and ready |
| onMount | func | noop | **Signature: function(player: IPlayer) => void**
Function called when the component is mounted |

## License

This content is released under the [MIT](http://opensource.org/licenses/MIT) License.