-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lj litter #39
base: master
Are you sure you want to change the base?
lj litter #39
Conversation
Scaffolding
I made this commit with the following steps: 1. `npm install -g create-react-app` 1. `create-react-app litter-patrol` (in a different location) 1. Copy over all of the files from the new app 1. Stage any changes that aren't overriding project-specific code
Upgrade to create-react-app 2.1.1
Update package-lock.json
This is a whole bunch of code, which really should be in several commits. Unfortunately I wrote all of this without making commits as I went, and now I don't have the time to break it down better than this.
This background is made up of about 10 different layers, each with their own PNG background image. The parallax effect is made by scrolling them each at a different rate.
We also no longer refer to the game items as 'objects' within the App component. I had always intended to rename those variables once I figured out a more appropriate term, but none have come to met yet. Items is still a better name than objects, for obvious reasons.
Waves 2 and 3 were not ordered in terms of their implementation difficulty, but instead because scoring point seemed more central to the gameplay and thus was implemented earlier. However, this reorganization also seems to follow a logical gameplay progression (spotting items leading to scoring points), while also having a steadier progression of complexity.
Project redesign for C10
Due date for C10 project
Revert "Due date for C10 project"
Due date for C10 project
Litter PatrolWhat We're Looking For
|
src/App.js
Outdated
onItemClicked = () => { | ||
// Fill this in! | ||
console.log(this); | ||
if (this.type === 'litter'){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property doesn't exist on the App
component. You should instead be checking to see if the GameItem
is litter.
this.setState({clicked: true}); | ||
} | ||
|
||
if (this.props.type === 'litter') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also only call the callback the 1st time the item is clicked on and if it's litter.
<img src={icon} | ||
alt="Item" | ||
className={"icon-item"} | ||
onClick={ this.onClicked } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest moving the onClick into the `div.
Litter Patrol
Congratulations! You're submitting your assignment!
Comprehension Questions
this.state
connected?CS Fundamentals Questions
App.render
(it starts withthis.state.items.map
). What is the Big-O time complexity of this code, where n is the number of active game items?setState
-- it must re-render all of the components that now have different content because of that change.What kind of data structure are the components in, and what sort of algorithms would be appropriate for React's code to "traverse" those components?
Speculate wildly about what the Big-O time complexity of that code might be.