diff --git a/.gitignore b/.gitignore
index d30f40e..dbbcb2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+.idea
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..15a15b2
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..03d9549
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/litter-patrol.iml b/.idea/litter-patrol.iml
new file mode 100644
index 0000000..24643cc
--- /dev/null
+++ b/.idea/litter-patrol.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..24eb271
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..f352e11
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..95db32d
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,221 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1543448737174
+
+
+ 1543448737174
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/App.css b/src/App.css
index 441dacf..d83272a 100644
--- a/src/App.css
+++ b/src/App.css
@@ -30,7 +30,7 @@ body {
margin: 5px;
cursor: pointer;
- animation-duration: 4s;
+ animation-duration: 9s;
animation-name: item-move;
animation-timing-function: linear;
diff --git a/src/App.js b/src/App.js
index 1ca7b71..dd15e2d 100644
--- a/src/App.js
+++ b/src/App.js
@@ -30,18 +30,21 @@ class App extends Component {
};
// Uncomment this to spawn a single test item
- //const testItem = this.spawnItem(Date.now());
- //this.state.items.push(testItem);
+ // const testItem = this.spawnItem(Date.now());
+ // this.state.items.push(testItem);
- // Uncomment this to automatically spawn new items
+ // // Uncomment this to automatically spawn new items
this.enableSpawner();
console.log(this.state);
}
-
- onItemClicked = () => {
- // Fill this in!
- }
+ onItemClicked = () => {
+ // Fill this in!
+ console.log(this);
+ this.setState({
+ points: this.state.points + 1
+ });
+ };
render() {
const items = this.state.items.map((item, i) => {
@@ -50,7 +53,13 @@ class App extends Component {
layer={100 + i} // Layer - used for a CSS style to show items on-top of bg
key={item.id} // Key - to help React with performance
- // Additional props (event callbacks, etc.) can be passed here
+ // Additional props (event c
+ // \allbacks, etc.) can be passed here
+ type={item.type}
+ index={i}
+ clicked={item.clicked}
+ onClickedCallback={this.onItemClicked}
+
/>;
});
diff --git a/src/components/GameItem.js b/src/components/GameItem.js
index 30298a8..7d1c0ac 100644
--- a/src/components/GameItem.js
+++ b/src/components/GameItem.js
@@ -3,27 +3,66 @@ import '../App.css';
import ItemIcons from '../ItemIcons.js';
import PropTypes from 'prop-types';
+
class GameItem extends Component {
- propTypes = {
- height: PropTypes.number.isRequired,
- layer: PropTypes.number.isRequired,
+ constructor(props){
+ super(props);
+
+ this.state = {
+ clicked: false
+ };
+
}
+ onClicked = () => {
+ // Fill this in!
+ console.log(this);
+ if (!this.state.clicked) {
+ this.setState({clicked: true});
+ }
+
+ if (this.props.type === 'litter') {
+ this.props.onClickedCallback();
+ }
+
+ };
+ clickedClass = () => {
+ if (this.state.clicked && this.props.type === 'litter') {
+ return "game-item spotted-litter"
+ } else if (this.state.clicked && this.props.type !== 'litter') {
+ return "game-item spotted-nature"
+ } else {
+ return "game-item"
+ }
+ };
render() {
+ // console.log(this.props);
const itemStyle = {
bottom: `${this.props.height}px`, // use props.height to offset from the bottom of screen
- zIndex: this.props.layer, // use props.layer to set z-index, so we display ontop of background
+ zIndex: this.props.layer, // use props.layer to set z-index, so we display on top of background
};
// Update this to select the correct icon for each item
- const icon = ItemIcons.rock;
+ // const icon = ItemIcons.rock;
+ const icon = ItemIcons[this.props.type];
+
return (
-
-
+
+
);
}
}
+GameItem.propTypes = {
+ height: PropTypes.number.isRequired,
+ layer: PropTypes.number.isRequired,
+};
+
export default GameItem;