关于贴图坐标的,我英语不好,有点费解,那位大侠帮忙翻翻看!谢谢!This is where those math classes you took come in handy. Finally, functions are really useful. (And, I don't mean functions as in programming.) A row of tiles is placed along, or follows, the function f(X)=0.46875X or f(X)=0.46875X depending on which axis. (Why all the decimals? Remember in the last article we used the tile height of 30, which divided by 64 is 0.46875. If we use 0.5 instead, which doesn't seem to be too much different, we will get a slight deviation in the positioning system. The cursor will start selecting tiles beside it, in some cases as many as three tiles in the wrong direction.) The X in these function refers to the screen coordinate system. These two functions look like this:
图1
The shaded area is a value above and below the function that the tile is within. Where two shaded areas cross each other we have the shape of a tile. What we have to do in order to figure out which tile the cursor is in is to determine when the tile is inside the shaded area. So, if the Y value of the cursor is between -0.46875X+14 and -0.46875X-14 then the cursor is on the same WorldY as the tile. If the Y value is between 0.46875X+14 and 0.46875X-14 then the cursor is on the same WorldX as the tile. If both these happen at the same time then the cursor is on the tile (where the shaded areas cross). This is just for one tile. What about 100x100 tiles? This picture might give you an idea of how to solve this.
图2
First of all, every row is offset one tile height (30 pixels) from the one above. So, what we do is enumerate through all WorldX rows until we strike the right one. Then we take the number of that row and place it in the TileX Integer. Next, we enumerate through all the WorldY rows and place the right number in the TileY Integer. Finally, we return the two values to the main program. Now, the main program can use these values to get tile info, draw the er, etc. Ok? Let's implement it in our tiling engine.
图1
The shaded area is a value above and below the function that the tile is within. Where two shaded areas cross each other we have the shape of a tile. What we have to do in order to figure out which tile the cursor is in is to determine when the tile is inside the shaded area. So, if the Y value of the cursor is between -0.46875X+14 and -0.46875X-14 then the cursor is on the same WorldY as the tile. If the Y value is between 0.46875X+14 and 0.46875X-14 then the cursor is on the same WorldX as the tile. If both these happen at the same time then the cursor is on the tile (where the shaded areas cross). This is just for one tile. What about 100x100 tiles? This picture might give you an idea of how to solve this.
图2
First of all, every row is offset one tile height (30 pixels) from the one above. So, what we do is enumerate through all WorldX rows until we strike the right one. Then we take the number of that row and place it in the TileX Integer. Next, we enumerate through all the WorldY rows and place the right number in the TileY Integer. Finally, we return the two values to the main program. Now, the main program can use these values to get tile info, draw the er, etc. Ok? Let's implement it in our tiling engine.
解决方案 »
- 求抽奖程序源代码或算法(dephi版)
- 大家谁有中山大学 delphi视频教程(共51讲)???我下的几个都是34讲不能用啊,大家谁的可以用个给我发一个?
- 程序中使用了哪些Api 如何知道!
- 哪儿有DevExpress ExpressExtendedEditors Suite v4.2.7 RC1 for Delphi7下载?急
- 如何禁止AdoQuery的自动排序
- FastREPORT问题
- ADO出的问题各位来看看下面的代码。
- ADOQuery Join 的问题
- 请教一个Delphi实现下面功能的方法/代码
- 如果不用指针,如何删除内存变量
- BDE query缓存更新,如何能查到缓存中的数据?(已录入数据,在数据未保存到数据库之前对数据进行查询,可以吗?)
- 高分求delphi控制摄像头的原代码!!!
这是那些数学分类的地方你轮流受到在的影响便利的。 Finally, functions are really useful.
最后,功能真的有用。 (And, I don't mean functions as in programming.)
(AND, 我不意谓功能当做在程序规划中.) A row of tiles is placed along, or follows, the function f(X)=0.46875X or f(X)=0.46875X depending on which axis.
一个砖瓦的列被放置向前, 或跟随, 功能 f(X)=0.46875 X 或 f(X)=0.46875 X 仰赖桥。 (Why all the decimals?
( 为什么所有的十位? Remember in the last article we used the tile height of 30, which divided by 64 is 0.46875.
在我们用砖瓦画面高度的最后一个文章中记得 30,64 之前分开是 0.46875. If we use 0.5 instead, which doesn't seem to be too much different, we will get a slight deviation in the positioning system.
如果我们改为使用 0.5, 这似乎不是太多不同的,我们将会得到定位系统的一个微小的偏向。 The cursor will start selecting tiles beside it, in some cases as many as three tiles in the wrong direction.)
光标将会启动选择在它旁边的砖瓦, 在一些外壳中错误的方向多达三块砖瓦.) The X in these function refers to the screen coordinate system.
这些功能的 X 提及荧屏坐桥系统。 These two functions look like this: 这二个功能看起来像这一样:
图1图 1
The shaded area is a value above and below the function that the tile is within.
阴暗的区域在和上面功能下面是一个数值砖瓦在里面。 Where two shaded areas cross each other we have the shape of a tile.
哪里二个阴暗的区域交叉的彼此我们有砖瓦的形状。 What we have to do in order to figure out which tile the cursor is in is to determine when the tile is inside the shaded area.
我们必须为了要理解光标是哪一砖瓦 , 做的在是决定当砖瓦在阴暗的区域里的时候。 So, if the Y value of the cursor is between -0.46875X+14 and -0.46875X-14 then the cursor is on the same WorldY as the tile.
如此,如果光标的 Y 数值是在 -之间0.46875 X+14 和 -0.46875 X-14 然后光标在如同砖瓦一般的 WorldY 上。 If the Y value is between 0.46875X+14 and 0.46875X-14 then the cursor is on the same WorldX as the tile.
如果 Y 数值然后是在 0.46875 X+14 和 0.46875 X-14 之间光标在如同砖瓦一般的 WorldX 上。 If both these happen at the same time then the cursor is on the tile (where the shaded areas cross).
如果两者的这些然后同时发生光标在砖瓦上.(阴暗的区域越过哪里) This is just for one tile.
这对一块砖瓦是正直的。 What about 100x100 tiles?
100 x100 砖瓦怎么样? This picture might give you an idea of how to solve this. 这一个照片可能该如何解决这给你一个主意。
图2图 2
First of all, every row is offset one tile height (30 pixels) from the one above.
首先,每个列在上面被弥补来自那一个的一个砖瓦画面高度 (30个图素) 。 So, what we do is enumerate through all WorldX rows until we strike the right one.
如此, 什么我们做是列举过所有的 WorldX 列直到我们袭击一个正确的。 Then we take the number of that row and place it in the TileX Integer.
然后我们轮流那一个列的数目并且把它放在 TileX 整数。 Next, we enumerate through all the WorldY rows and place the right number in the TileY Integer.
然后,我们列举过所有的 WorldY 列并且把正确的数目放在 TileY 整数。 Finally, we return the two values to the main program.
最后,我们归还二个数值给主程序。 Now, the main program can use these values to get tile info, draw the er, etc. Ok?
现在,主程序能使用这些数值得到砖瓦信息, 画那条线信标器,好的等等? Let's implement it in our tiling engine. 让我们在我们的盖瓦发动机中实现它。
在这儿你所学的数学方法能派上用场。
Finally, functions are really useful.
终于,函数有了用武之地。
(And, I don't mean functions as in programming.)
(我不是说是编程中的函数)
A row of tiles is placed along, or follows, the function f(X)=0.46875X or f(X)=0.46875X depending on which axis.
一组小图片(tiles)横向,或者垂直排列,取决于函数f(X)=0.46875X 或者f(X)=0.46875X依赖的轴。
(Why all the decimals? Remember in the last article we used the tile height of 30, which divided by 64 is 0.46875. If we use 0.5 instead, which doesn't seem to be too much different, we will get a slight deviation in the positioning system.
(为什么是小数?想想在上一篇文章中,我们使用的图片高为30,用64除就是0.46875。如果我门用0.5代替,看上似乎差别不大,但我们将会发现在坐标上出现轻微的偏移。
The cursor will start selecting tiles beside it, in some cases as many as three tiles in the wrong direction.)
光标将选取附近的图片,在一些情况下在一个错误的放向上将有多达三个图片。
The X in these function refers to the screen coordinate system.
函数中的x代表屏幕坐标系统。
These two functions look like this:
两个函数入下所示
图1
The shaded area is a value above and below the function that the tile is within.
阴影区域是图片内比函数值大或小的值域
Where two shaded areas cross each other we have the shape of a tile.
两个阴影相交的部分就是我们要的图片的轮廓。
What we have to do in order to figure out which tile the cursor is in is to determine when the tile is inside the shaded area.
要找出光标在那个图片内,将要在图片在阴影区域时进行判断。
So, if the Y value of the cursor is between -0.46875X+14 and -0.46875X-14 then the cursor is on the same WorldY as the tile.
所以,如果光标的Y值在-0.46875x+14与-0.46875x-14之间,那么光标就与图片拥有相同的worldy
If the Y value is between 0.46875X+14 and 0.46875X-14 then the cursor is on the same WorldX as the tile.
所以,如果光标的X(Y?)值在-0.46875x+14与-0.46875x-14之间,那么光标就与图片拥有相同的worldx
If both these happen at the same time then the cursor is on the tile (where the shaded areas cross).
如果两者都满足,这光标在图片上(阴影的相交区域)
This is just for one tile. What about 100x100 tiles? This picture might give you an idea of how to solve this.
这是一个图片的情况。如果是100*100个图片呢?下图将提示你如何解决。
图2
First of all, every row is offset one tile height (30 pixels) from the one above.
首先,每一行与上一行的偏移量是一个图片的高度(30像素)
So, what we do is enumerate through all WorldX rows until we strike the right one.
所以,我们做得是枚举所有的worldx行,直到找出正确的一个。
Then we take the number of that row and place it in the TileX Integer.
然后,我们用图片行序号替代tilex值。
Next, we enumerate through all the WorldY rows and place the right number in the TileY Integer.
接下来,我们枚举所有的worldy行,并替换正确的tiley值。
Finally, we return the two values to the main program. Now, the main program can use these values to get tile info, draw the er, etc. Ok? Let's implement it in our tiling engine.
最后,返回两个值到主程序。现在,主程序能用这些值来获得tile信息,绘制标记等等。ok?让我们在我们的tiling引擎中来实现。
在线翻译的~~~
============
(Why all the decimals? Remember in the last article we used the tile height of 30, which divided by 64 is 0.46875. If we use 0.5 instead, which doesn't seem to be too much different, we will get a slight deviation in the positioning system. The cursor will start selecting tiles beside it, in some cases as many as three tiles in the wrong direction.)(为什么是小数?想想在上一篇文章中,我们使用的图片高为30,用64除就是0.46875。如果我们用0.5代替,看上去似乎差别不大,但实际上我们将会发现在坐标上出现轻微的偏移。在一些情况下,在错误的方向上有三张图片时,光标将会选择到目标旁边的图片。
是个在先翻译站,嗯翻的东西嘛,自己再理解理解应该还可以看的.
呵呵,各位领导.初来乍到,这厢有礼了.