Reducer
Since we have a very limited amount of actions, our reducer will also be fairly simple and will delegate most of the functionality to the sprites helper functions in the src/sprites.js
file:
/*** src/reducers/index.js ***/ import { sprites, moveSprites, checkForCollision, getUpdatedScore, bounceParrot } from "../sprites"; const initialState = { score: 0, gameOver: false, isStarted: false, sprites }; export default (state = initialState, action) => { switch (action.type) { case "TICK": return { ...state, sprites: moveSprites(state.sprites, action.elapsedTime), gameOver: checkForCollision(state.sprites[0], state.sprites.slice(1)), score: getUpdatedScore(state.sprites, state.score) }; case "BOUNCE": return { ...state, sprites: bounceParrot(state.sprites) }; case "START": return { ...initialState, isStarted: true }; default: return...