ADM-201 dump PMP dumps pdf SSCP exam materials CBAP exam sample questions

【用代数讲计算机科学】坐标系 – 译学馆
未登录,请登录后再发表信息
最新评论 (0)
播放视频

【用代数讲计算机科学】坐标系

CS in Algebra: Coordinate Plane

本视频将介绍数学 如代数和几何是怎么用来开发电子游戏的
You’re going to learn how math, like algebra and geometry, can be used to develop video games.
一些现代电子游戏是非常复杂的
Some modern video games are incredibly complex
它们包括逼真的画面 物理模拟 人工智能 等等
with realistic graphics, physics, artificial intelligence and so on.
大多数游戏都是由大型团队耗费几年时间开发的
Major video games can take large teams of developers years to produce
然而 你可以使用许多和大型游戏开发者一样的概念
but you can apply many of the same concepts that the big game developers use
来开发一个你自己的简单的游戏
to create a simple game of your own.
让我们从一个相当简单的2维游戏开始
Let’s start by looking at a fairly simple 2-dimensional game.
游戏中的每一个角色 或称人物
Each of the actors, or sprites in this game
都可以用它们在屏幕上的位置和运动来描绘
can be described by their location or movement on the screen.
你的工作就是找出如何用数学方法描绘这些人物的每个动作
Your job is to figure out how we can describe the actions of each of these sprites mathematically
使其与坐标系相关联
in relation to the coordinate plane.
让我们拿植物大战僵尸举个例子
Let’s take a quick look at the game Plants vs. Zombies as an example.
假如屏幕上有一个僵尸和一朵花为了让游戏运行
If we have a zombie and a flower on the screen, there are a few things we need to know about
有几件事我们需要了解
them in order to make the game work.
僵尸在哪
Where’s the zombie?
它向哪个方向移动花在哪
In which direction is it moving?Where’s the flower?
它们之间距离多远
How far apart are they?
作为一名玩家 你可能会用模糊的概念来描述
As a player of the game, you might say in general terms
比如 它们处在屏幕的两边
that they’re on opposite sides of the screen.
僵尸正在向左移动
Or that the zombie is moving to the left.
僵尸和花两者已经相当接近
Or that the zombie and the flower are pretty close to each other.
这些近似说法或许可行但还是不够精确
These might be ok approximations but they really aren’t specific enough and they definitely
而且这些表述方式计算机是无法理解的
aren’t stated in a way that a computer can understand.
假设你和朋友正在打电话
Suppose you were talking to your friend on the phone
你正试着精确的告诉他这条龙在哪
trying to tell them exactly where the dragon is.
你可能用一些单词 例如 左但这并不精确
You could use words like on the left but that isn’t specific enough.
如果你有一把尺子 你可以告诉朋友
If you had a ruler, you could measure from the left side of the screen
这条龙距离屏幕左边有多少英寸远
and tell your friend exactly how many inches away the dragon is.
这就是计算机做的事
That is exactly what computers do.
用一条数轴从左边开始作为零
Using a number line that starts with a 0 on the far left
一边向右移动一边测量屏幕上的像素
and moving across the right measuring the number of pixels on the screen.
对于我们的游戏来说 我们将会放一条
For our video game, we’ll place the number line that the screen
在屏幕上由左及右为0到400的数轴
runs from 0 on the left to 400 on the right.
我们可以假定这条龙的图片在这个数轴的任意位置
We can imagine the image of the dragon, stick it anywhere on the line and measure the distance
然后去量从屏幕左边缘到这条龙的距离
back to the left hand edge of the screen from our dragon.
其他人只要知道我们的数轴就可以得到
Anyone else who knows about our number line will be able to duplicate the exact position
表示这条龙的确切位置的数字
of the dragon know only the number.
在屏幕得最右边龙的位置是400
On the right side of the screen, the dragon is at 400.
在中间则是200
In the center, he’s at 200.
如果我们想要这条龙在屏幕上消失呢
What if we wanted the dragon to be off the edge of the screen?
我们可以使用比400大的数字把它放到右边之外
We could use numbers bigger than 400 to place him past the right hand side
或者使用负数放在左边之外
and negative numbers to place him past the left hand side.
但即是有了一个数轴我们还是不够精确
But even with a number line, we aren’t being quite specific enough.
即使在400 这条龙也可能在屏幕上方或者下方
Even at 400, the dragon could be at the top of the screen
或者它们之间的任何地方
or at the bottom or anywhere in between.
通过添加另外一条数轴
By adding another number line
我们就能在屏幕的另一个维度上定位角色
we can locate a character anywhere on the screen in either dimension.
第一条从左向右的轴叫x轴
The first line is called the x axis which runs from left to right.
第二条从下往上的轴叫y轴
The second line which runs up and down is called the y axis.
一个2维坐标包含着它在x与y轴的位置
A 2-dimensional coordinate consists of both the x and y locations on the axis.
假设我们想定位这个忍者在屏幕上的位置
Suppose we want to locate ninja’s position on the screen.
通过从忍者向x轴做垂线
We can find the x coordinate by dropping a line down from the ninja
我们就可以读出它在x轴上的坐标
and read the position on the number line.
y轴坐标通过向y轴做垂线确定
The y coordinate is found by running a line to the y axis.
有了x和y坐标代表的两个数字
With two numbers, x and y coordinates
我们就能描述出 屏幕上任何人物的坐标
we can describe the location of any sprite on our screen.
并且通过改变这两个数字 我们可以让精灵移动到屏幕的任何地方
And by changing those numbers, we can get our sprites to move around on the screen.
我们已经建立的其实是坐标系的第一象限
What we’ve created is actually quadrant one of the coordinate plane!
如果缩放一下我们可以看到其实有四个不同的象限
If we zoom out, we can see that there are four different quadrants to the plane:
第一象限 我们用在屏幕上那个
quadrant I, which we’re using as our screen,
包含了x和y的正值
contains the points of positive values for x and y.
逆时针移动得到第二象限
Moving counterclockwise we get to quadrant II
包含了负x和正y值
which contains the points of a negative X and positive Y.
第三象限包含的所有值都是负x和负y
Quadrant III contains all points with negative X and Y
第四象限则是一个正x和一个负y
and quadrant IV contains all points with a positive X and a negative Y.

发表评论

译制信息
视频概述

本篇视频主要讲述游戏开发过程中如何使用坐标系对游戏内单位进行定位

听录译者

收集自网络

翻译译者

【B】Cod

审核员

知易行难

视频来源

https://www.youtube.com/watch?v=VlJq9mAXx1c

相关推荐