Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit e38809e

Browse files
committed
its a start
0 parents  commit e38809e

29 files changed

+617
-0
lines changed

.babelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["es2015", "react", "stage-0"],
3+
"plugins": ["transform-flow-strip-types"]
4+
}

.eslintignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/demo/**
2+
/dist/**
3+
/interfaces/**
4+
/lib/**
5+
/node_modules/**
6+
/public/**
7+
/umd/**

.eslintrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"extends": "formidable/configurations/es6-react"
2+
"parser": "babel-eslint"
3+
"env":
4+
"browser": true
5+
"rules":
6+
"no-magic-numbers": 0
7+
"no-invalid-this": 0
8+
"react/sort-comp": 0
9+
"comma-dangle": [2, "always-multiline"]
10+
"jsx-quotes": [2, "prefer-double"]
11+
"quotes": [2, "single",{"allowTemplateLiterals": true}]

.flowconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[libs]
2+
interfaces
3+
4+
[ignore]
5+
.*/dist/.*
6+
.*/lib/.*
7+
.*/umd/.*
8+
.*/demo/.*
9+
.*/node_modules/flow-bin/.*
10+
11+
[include]
12+
src
13+
14+
[options]
15+
esproposal.class_static_fields=enable
16+
esproposal.class_instance_fields=enable

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
npm-debug.log
3+
lib
4+
umd

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src
2+
dist

LICENSE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

demo/character.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React, { Component, PropTypes } from 'react';
2+
3+
import {
4+
Sprite,
5+
} from '../src';
6+
7+
export default class Character extends Component {
8+
static propTypes = {
9+
state: PropTypes.number,
10+
};
11+
render() {
12+
return (
13+
<Sprite
14+
animating
15+
src="assets/character-sprite.png"
16+
scale={4}
17+
state={this.props.state}
18+
states={[9, 9, 0]}
19+
/>
20+
);
21+
}
22+
}

demo/demo.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React, { Component } from 'react';
2+
3+
import {
4+
Game,
5+
Keys,
6+
} from '../src';
7+
8+
import Character from './character';
9+
10+
import './index.css';
11+
12+
export default class Demo extends Component {
13+
14+
handleInput = (e) => {
15+
switch (e.keyCode) {
16+
case '37':
17+
// left
18+
break;
19+
case '39':
20+
// right
21+
break;
22+
default:
23+
break;
24+
}
25+
};
26+
27+
constructor(props) {
28+
super(props);
29+
this.state = {
30+
character: 0,
31+
};
32+
this.handleClick = this.handleClick.bind(this);
33+
}
34+
35+
handleClick() {
36+
const state = this.state.character === 2 ? 0 : this.state.character + 1;
37+
this.setState({
38+
character: state,
39+
});
40+
}
41+
42+
render() {
43+
return (
44+
<Game>
45+
<Keys onInput={this.handleInput} />
46+
<Character state={this.state.character}/>
47+
{this.state.character}
48+
<button style={{ marginTop: 200 }}onClick={this.handleClick} type="button">Toggle</button>
49+
</Game>
50+
);
51+
}
52+
53+
}

demo/index.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
html, body, #root {
2+
height: 100%;
3+
width: 100%;
4+
margin: 0;
5+
padding: 0;
6+
}

0 commit comments

Comments
 (0)