Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- Python
- Nest.js
- nestjs
- OCR
- react
- 자료구조
- mongoose
- Express
- GIT
- flask
- 게임
- class
- nodejs
- MongoDB
- MySQL
- jest
- TypeScript
- dfs
- game
- Queue
- 정렬
- JavaScript
- Sequelize
- Dinosaur
- typeORM
- cookie
- AWS
- 공룡게임
- Bull
Archives
- Today
- Total
목록구글게임 (1)
포시코딩
javascript - 구글 공룡 게임 구현(5) - Collision detection(충돌감지)
dino 캐릭터의 움직임, cactus 들의 접근까지 구현했으니 그 둘이 부딪히면 게임오버되게 만들어보자 충돌감지라고 영어로는 Collision detection 이라고 하는데 게임에서는 빠져선 안되는 기능이다. 2D인데다 사각형끼리의 충돌이니 간단하게 구현해보자 function collisionDetection(dino, cactus){ let xValue = cactus.x - ( dino.x + dino.width ); let yValue = cactus.y - ( dino.y + dino.height ); if( xValue < 0 && yValue < 0 ){ // 충돌! // 충돌 시 실행되는 코드 } } dino 가 점프했을 경우도 포함하여 두 사각형이 겹치는 순간이 있으면 if 문 안의 코..
개인프로젝트/구글 공룡 게임
2022. 6. 22. 14:59