Slight improvements

This commit is contained in:
henry-hiles 2021-11-26 15:04:21 -05:00
parent a43b104635
commit fcaa534724

View file

@ -1,10 +1,5 @@
import { updateBird, setupBird, getBirdRect } from "./bird.js" import { updateBird, setupBird, getBirdRect } from "./bird.js"
import { import { updatePipes, setupPipes, getPassedPipesCount, getPipeRects, } from "./pipe.js"
updatePipes,
setupPipes,
getPassedPipesCount,
getPipeRects,
} from "./pipe.js"
const title = document.querySelector( "[data-title]" ) const title = document.querySelector( "[data-title]" )
const subtitle = document.querySelector( "[data-subtitle]" ) const subtitle = document.querySelector( "[data-subtitle]" )
@ -31,14 +26,7 @@ const checkLose = () => {
return outsideWorld || insidePipe return outsideWorld || insidePipe
} }
const isCollision = ( rect1, rect2 ) => { const isCollision = ( rect1, rect2 ) => rect1.left < rect2.right && rect1.top < rect2.bottom && rect1.right > rect2.left && rect1.bottom > rect2.top
return (
rect1.left < rect2.right &&
rect1.top < rect2.bottom &&
rect1.right > rect2.left &&
rect1.bottom > rect2.top
)
}
const handleStart = () => { const handleStart = () => {
title.classList.add( "hide" ) title.classList.add( "hide" )