The sprites module
The structure of the sprites module is formed by an array of sprites and several exported functions:
/*** src/sprites.js ***/ import sound from "react-native-sound"; const coinSound = new sound("coin.wav", sound.MAIN_BUNDLE); let heightOfRockUp = 25; let heightOfRockDown = 25; let heightOfGap = 30; let heightOfGround = 20; export const sprites = [ ... ]; function prepareNewRockSizes() { ... } function getRockProps(type) { ... } export function moveSprites(sprites, elapsedTime = 1000 / 60) { ... } export function bounceParrot(sprites) { ... } function hasCollided(mainSprite, sprite) { ... } export function checkForCollision(mainSprite, sprites) { ... } export function getUpdatedScore(sprites, score) { ... }
This module begins by loading the sound effect we will play when the parrot passes a set of rocks to give feedback to the user about the increment in their score.
Then, we define some heights for several sprites:
heightOfRockUp
: This is the height...