【用代数讲计算机科学】游戏里的碰撞检测 – 译学馆

• #### 科普

SCIENCE

#### 英语

ENGLISH

#### 科技

TECHNOLOGY

MOVIE

FOOD

#### 励志

INSPIRATIONS

#### 社会

SOCIETY

TRAVEL

#### 动物

ANIMALS

KIDS

#### 卡通

CARTOON

#### 计算机

COMPUTER

#### 心理

PSYCHOLOGY

#### 教育

EDUCATION

#### 手工

HANDCRAFTS

#### 趣闻

MYSTERIES

CAREER

GEEKS

#### 时尚

FASHION

• 精品课
• 公开课
• 欢迎下载我们在各应用市场备受好评的APP

点击下载Android最新版本

点击下载iOS最新版本

扫码下载译学馆APP

#### 【用代数讲计算机科学】游戏里的碰撞检测

CS in Algebra: Big Game Collision Detection

All the sprites in your big game are now animated.

But nothing happens when they run into each other.

We’re going to use collision detection to find out when sprites have touched each other

so that we can later apply rules like increasing or decreasing your score when your sprites

collide.

Using the provided line-length function, you will complete a function distance that uses

the distance formula to calculate the distance between the center points of two sprites.

Next you’ll update the collide function to use the distance function.

If the distance between two sprites is less than 100 pixels, the sprites are close enough

to be touching and the collide function should return true.

If everything works, you’ll see that when the player collides with the target, your

score increases.

And when the player collides with the danger, your score decreases.

【MR】拾月