diff --git a/src/App.css b/src/App.css
index 441dacf..1dc812a 100644
--- a/src/App.css
+++ b/src/App.css
@@ -30,7 +30,7 @@ body {
margin: 5px;
cursor: pointer;
- animation-duration: 4s;
+ animation-duration: 8s;
animation-name: item-move;
animation-timing-function: linear;
diff --git a/src/App.js b/src/App.js
index 1ca7b71..0143474 100644
--- a/src/App.js
+++ b/src/App.js
@@ -30,8 +30,8 @@ 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
this.enableSpawner();
@@ -39,32 +39,46 @@ class App extends Component {
console.log(this.state);
}
- onItemClicked = () => {
+ onItemClicked = (index) => {
// Fill this in!
+ let updatedPoints = this.state.points;
+ let updatedItems = this.state.items;
+ const item = this.state.items[index]
+
+ if(item.type === "litter" && !(item.clicked)){
+ updatedPoints += 1
+ updatedItems[index].clicked = true
+ this.setState({ points: updatedPoints });
+ this.setState({ items: updatedItems });
+ }
}
render() {
+
const items = this.state.items.map((item, i) => {
- return ;
+ return ;
});
return (
-
- Litter Spotted: { this.state.points }
-
-
+
+ Litter Spotted: { this.state.points }
+
+
-
- { this.levelBackground() }
- { items }
-
+
+ { this.levelBackground() }
+ { items }
+
);
@@ -140,7 +154,6 @@ class App extends Component {
choice -= weight; // otherwise move past this entry
}
});
-
return selectedType;
}
@@ -150,10 +163,10 @@ class App extends Component {
levelBackground() {
const layers = ['clouds-1', 'clouds-2', 'clouds-3', 'clouds-4',
- 'hills-1','hills-2','bushes','trees-1','trees-2','ground'];
+ 'hills-1','hills-2','bushes','trees-1','trees-2','ground'];
return (
- {layers.map(layer => (
))}
+ {layers.map(layer => (
))}
);
}
diff --git a/src/components/GameItem.js b/src/components/GameItem.js
index 673cee9..dd5d082 100644
--- a/src/components/GameItem.js
+++ b/src/components/GameItem.js
@@ -4,7 +4,21 @@ import ItemIcons from '../ItemIcons.js';
import PropTypes from 'prop-types';
class GameItem extends Component {
+ constructor() {
+ super();
+ this.state = {
+ litterSpottedClass: "",
+ };
+ }
+ spotLitter = () =>{
+ if (this.props.type === "litter"){
+ this.setState({ litterSpottedClass: "spotted-litter" });
+ } else {
+ this.setState({ litterSpottedClass: "spotted-nature" });
+ }
+ this.props.pointsCallback(this.props.index)
+ }
render() {
const itemStyle = {
@@ -13,11 +27,15 @@ class GameItem extends Component {
};
// 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 (
-
-
+
+
+
);
}