亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch6.htm

?? 有關于游戲開發的教程我閱讀后感覺不錯所以就拿出來與大家共享。
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
sort of like another dimension-like a Z axis. You can think of
sprites moving around on the screen in the XY axis. Similarly,
the Z axis can be thought of as another axis projected into the
screen that determines how the sprites overlap each other. To
put it another way, Z-order determines a sprite's depth within
the screen. By making use of a Z axis, you might think that Z-ordered
sprites are 3D. The truth is that Z-ordered sprites can't be considered
3D because the Z axis is a hypothetical axis that is only used
to determine how sprite objects hide each other.
<P>
Just to make sure that you get a clear picture of how Z-order
works, let's go back for a moment to the good old days of traditional
animation. Traditional animators, such as those at Disney, used
celluloid sheets to draw animated objects. They drew on celluloid
sheets because the sheets could be overlaid on a background image
and moved independently. This was known as <I>cel animation</I>
and should sound vaguely familiar. (Cel animation is an early
version of sprite animation.) Each cel sheet corresponds to a
unique Z-order value, determined by where in the pile of sheets
the sheet is located. If a sprite near the top of the pile happens
to be in the same location on the cel sheet as any lower sprites,
it conceals them. The location of each sprite in the stack of
cel sheets is its Z-order, which determines its visibility precedence.
The same thing applies to sprites in cast-based animations, except
that the Z-order is determined by the order in which the sprites
are drawn, rather than the cel sheet location. This concept of
a pile of cel sheets representing all the sprites in a sprite
system will be useful later today when you develop the sprite
classes.
<H4><B>Collision Detection</B></H4>
<P>
No discussion of animation as it applies to games would be complete
without covering collision detection. <I>Collision detection</I>
is simply the method of determining whether sprites have collided
with each other. Although collision detection doesn't directly
play a role in creating the illusion of movement, it is tightly
linked to sprite animation and extremely crucial in games.
<P>
<I>Collision detection</I> is the process of determining whether
sprites have collided with each other.
<P>
Collision detection is used to determine when sprites physically
interact with each other. In an Asteroids game, for example, if
the ship sprite collides with an asteroid sprite, the ship is
destroyed. Collision detection is the mechanism employed to find
out whether the ship collided with the asteroid. This might not
sound like a big deal; just compare their positions and see whether
they overlap, right? Correct, but consider how many comparisons
must take place when lots of sprites are moving around; each sprite
must be compared to every other sprite in the system. It's not
hard to see how the overhead of effective collision detection
can become difficult to manage.
<P>
Not surprisingly, there are many approaches to handling collision
detection. The most simple approach is to compare the bounding
rectangles of each sprite with the bounding rectangles of all
the other sprites. This method is very efficient, but if you have
objects that are not rectangular, a certain degree of error occurs
when the objects brush by each other. This is because the corners
might overlap and indicate a collision when really only the transparent
areas are overlapping. The more irregular the shape of the sprites,
the more error typically occurs. Figure 6.1 shows how simple rectangle
collision works.
<P>
<A HREF="f6-1.gif" ><B>Figure 6.1 : </B><I>Collision detection using simple rectangle collision.</I></A>
<P>
In Figure 6.1, the areas determining the collision detection are
shaded. You can see how simple rectangle collision detection isn't
very accurate, unless you're dealing with sprites that are rectangular
in shape. An improvement on this technique is to shrink the collision
rectangles a little, which reduces the corner error. This method
improves things a little, but it has the potential of causing
error in the reverse direction by allowing sprites to overlap
in some cases without signaling a collision. Figure 6.2 shows
how shrinking the collision rectangles can improve the error on
simple rectangle collision detection. Shrunken rectangle collision
is just as efficient as simple rectangle collision because all
you are doing is comparing rectangles for intersection.
<P>
<A HREF="f6-2.gif" ><B>Figure 6.2 : </B><I>Collision detection using shrunken rectangle collision.</I></A>
<P>
The most accurate collision detection technique is to detect collision
based on the sprite image data, which involves actually checking
to see whether transparent parts of the sprite or the sprite images
themselves are overlapping. In this case, you get a collision
only if the actual sprite images are overlapping. This is the
ideal technique for detecting collisions because it is exact and
allows objects of any shape to move by each other without error.
Figure 6.3 shows collision detection using the sprite image data.
<P>
<A HREF="f6-3.gif" ><B>Figure 6.3 : </B><I>Collision detection using sprite image data.</I></A>
<P>
Unfortunately, the technique shown in Figure 6.3 requires far
more overhead than rectangle collision detection and is often
a major bottleneck in performance. Furthermore, implementing image
data for collision detection can get very messy. Considering these
facts, it's safe to say that you won't be worrying about image
data collision detection in this book. It might be an avenue worth
considering in the future if the just-in-time Java compilers can
squeeze enough additional performance out of Java, and if you
are willing to dig into the programming complexities involved
in pulling it off.
<H2><A NAME="ImplementingSpriteAnimation"><B><FONT SIZE=5 COLOR=#FF0000>Implementing
Sprite Animation</FONT></B></A></H2>
<P>
As you learned earlier in today's lesson, sprite animation involves
the movement of individual graphic objects called sprites. Unlike
simple frame animation, sprite animation involves considerably
more overhead. More specifically, it is necessary to develop not
only a sprite class, but also a sprite management class for keeping
up with all the sprites in the system. This is necessary because
sprites need to be able to interact with each other through a
common mechanism. Furthermore, it is useful to extract the background
behind the sprites into a class of its own.
<P>
In this section, you learn how to implement sprite animation in
Java by creating a suite of sprite classes. The primary sprite
classes are <TT><FONT FACE="Courier">Sprite</FONT></TT> and <TT><FONT FACE="Courier">SpriteVector</FONT></TT>.
However, there are also a few support classes that you will learn
about as you get into the details of these two primary classes.
The <TT><FONT FACE="Courier">Sprite</FONT></TT> class models a
single sprite and contains all the information and methods necessary
to get a single sprite up and running. However, the real power
of sprite animation is harnessed by combining the <TT><FONT FACE="Courier">Sprite</FONT></TT>
class with the <TT><FONT FACE="Courier">SpriteVector</FONT></TT>
class, which is a container class that manages multiple sprites
and their interaction with each other.
<H3><A NAME="TheSpriteClass"><B>The </B><TT><B><FONT SIZE=4 FACE="Courier">Sprite</FONT></B></TT><B><FONT SIZE=4>
Class</FONT></B></A></H3>
<P>
Although sprites can be implemented simply as moveable graphical
objects, you saw earlier that the sprite class developed here
will also contain support for frame animation. A frame- animated
sprite is basically a sprite with multiple frame images that can
be displayed in succession. The <TT><FONT FACE="Courier">Sprite</FONT></TT>
class you are about to see supports frame animation in the form
of an array of frame images and some methods for setting the current
frame image. Using this approach, you end up with a <TT><FONT FACE="Courier">Sprite</FONT></TT>
class that supports both fundamental types of animation and is
much more suitable for Java games.
<P>
Before jumping into the details of how the <TT><FONT FACE="Courier">Sprite</FONT></TT>
class is implemented, take a moment to think about the different
pieces of information that a sprite must keep up with. When you
understand the components of a sprite at a conceptual level, it
will be much easier to understand the Java code. So, exactly what
information should a <TT><FONT FACE="Courier">Sprite</FONT></TT>
class maintain? The following list contains the key information
that the <TT><FONT FACE="Courier">Sprite</FONT></TT> class needs
to include:
<UL>
<LI>Array of frame images
<LI>Current frame
<LI>XY position
<LI>Velocity
<LI>Z-order
<LI>Boundary
</UL>
<P>
The first component, an array of frame images, is necessary to
carry out the frame animations. Even though this sounds like you
are forcing a sprite to have multiple animation frames, a sprite
can also use a single image. In this way, the frame animation
aspects of the sprite are optional. The current frame keeps up
with the current frame of animation. In a typical frame- animated
sprite, the current frame is incremented to the next frame when
the sprite is updated.
<P>
The XY position stores the position of the sprite. You can move
the sprite simply by altering this position. Alternatively, you
can set the velocity and let the sprite alter its position internally.
<P>
The Z-order represents the depth of the sprite in relation to
other sprites. Ultimately, the Z-order of a sprite determines
its drawing order (more on that a little later).
<P>
Finally, the boundary of a sprite refers to the bounded region
in which the sprite can move. All sprites are bound by some region-usually
the size of the applet window. The sprite boundary is important
because it determines the limits of a sprite's movement.
<P>
Now that you understand the core information required by the <TT><FONT FACE="Courier">Sprite</FONT></TT>
class, it's time to get into the specific Java implementation.
Keep in mind that the <TT><FONT FACE="Courier">Sprite</FONT></TT>
class contains all the features necessary to implement sprites
in the sample games throughout the rest of the book. Let's begin
with the <TT><FONT FACE="Courier">Sprite</FONT></TT> class's member
variables, which follow:
<BLOCKQUOTE>
<TT><FONT FACE="Courier">public static final int&nbsp;SA_KILL
= 0,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SA_RESTOREPOS
= 1,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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,
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;frameTrigger;
<BR>
protected Rectangle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;collision;
<BR>
protected int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;zOrder;
<BR>
protected Point&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;velocity;
<BR>
protected Rectangle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bounds;<BR>
protected int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boundsAction;
<BR>
protected boolean&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hidden
= false;</FONT></TT>
</BLOCKQUOTE>
<P>
The member variables include the important sprite information
mentioned earlier, along with some other useful information. Most
notably, you are probably curious about the static final members
at the beginning of the listing. These members are constant identifiers
that define actions for the sprite. Two different types of actions
are supported by <TT><FONT FACE="Courier">Sprite</FONT></TT>:
sprite actions and bounds actions. <I>Sprite actions</I> are general
actions that a sprite can perform, such as killing itself or adding
another sprite. <I>Bounds actions</I> are actions that a sprite
takes in response to reaching a boundary, such as wrapping to
the other side or bouncing. Unlike sprite actions, bounds actions
are mutually exclusive, meaning that only one can be set at a
time.
<P>
After the actions, the <TT><FONT FACE="Courier">Component</FONT></TT>
member variable is the next member variable that you might be
curious about. It is necessary because an <TT><FONT FACE="Courier">ImageObserver</FONT></TT>
object is required to retrieve information about an image. But
what does <TT><FONT FACE="Courier">Component</FONT></TT> have
to do with <TT><FONT FACE="Courier">ImageObserver</FONT></TT>?
The <TT><FONT FACE="Courier">Component</FONT></TT> class implements
the <TT><FONT FACE="Courier">ImageObserver</FONT></TT> interface,
and the <TT><FONT FACE="Courier">Applet</FONT></TT> class is derived
from <TT><FONT FACE="Courier">Component</FONT></TT>. So, a <TT><FONT FACE="Courier">Sprite</FONT></TT>
object gets its image information from the Java applet itself,
which is used to initialize the <TT><FONT FACE="Courier">Component</FONT></TT>
member variable.
<P>
<CENTER><TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR><TD><B>Note</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
<TT><FONT FACE="Courier">ImageObserver</FONT></TT> is an interface defined in the <TT><FONT FACE="Courier">java.awt.image</FONT></TT> package that provides a means for receiving information about an image.
</BLOCKQUOTE>

</TD></TR>
</TABLE></CENTER>
<P>
<P>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品久久久影院| 粉嫩av亚洲一区二区图片| 亚洲柠檬福利资源导航| 亚洲国产精品高清| 久久综合色一综合色88| 亚洲欧洲国产日本综合| 国产女人18毛片水真多成人如厕 | 午夜久久福利影院| 亚洲精品日韩一| 一区二区三区精品视频在线| 国产精品毛片无遮挡高清| 国产精品拍天天在线| 成人欧美一区二区三区在线播放| 国产精品成人免费精品自在线观看| 中文一区二区完整视频在线观看| 中文字幕制服丝袜成人av| 综合激情成人伊人| 亚洲制服丝袜一区| 另类人妖一区二区av| 国产99久久久国产精品潘金网站| 高清久久久久久| 一本大道久久a久久精二百| 777奇米四色成人影色区| 欧美xxxxxxxx| 亚洲色图视频网站| 亚洲成av人片| 国产成人日日夜夜| 精品视频一区 二区 三区| 欧美一区二区三区色| 国产精品久久三| 亚洲成人av福利| 国产精品综合一区二区| 色综合天天综合网天天看片| 欧美一级日韩免费不卡| 国产精品久久久久久久第一福利| 午夜欧美在线一二页| 国产精品99久久久久久宅男| 欧美色手机在线观看| 久久久精品免费网站| 亚洲一二三专区| 国产精品综合视频| 91精品国产高清一区二区三区蜜臀 | 精品国产乱码久久久久久久| 国产精品高潮久久久久无| 美日韩黄色大片| 日本韩国欧美在线| 国产午夜三级一区二区三| 香蕉久久夜色精品国产使用方法 | 国产日韩精品一区二区浪潮av| 中文字幕亚洲成人| 久久99久久99| 欧美日韩1区2区| 亚洲精品亚洲人成人网| 国产一区免费电影| 欧美一卡在线观看| 亚洲夂夂婷婷色拍ww47| av不卡免费在线观看| 成人18视频日本| 91网站最新网址| 国产一区视频在线看| 欧美日韩视频在线观看一区二区三区 | 久久久久久**毛片大全| 亚洲一级二级三级| 色哟哟日韩精品| 亚洲视频在线一区| 99国产麻豆精品| 欧美国产激情一区二区三区蜜月 | 国产成人免费av在线| 日韩欧美的一区二区| 丝袜亚洲另类丝袜在线| 欧美亚洲图片小说| 又紧又大又爽精品一区二区| 91美女在线视频| 日韩伦理av电影| 99久久久精品| 亚洲人成网站在线| 色国产精品一区在线观看| 亚洲视频一区二区在线| 一本一道综合狠狠老| 亚洲人吸女人奶水| 欧美亚洲愉拍一区二区| 亚洲第一精品在线| 欧美一区中文字幕| 精品一区二区三区免费毛片爱| 精品国产不卡一区二区三区| 精东粉嫩av免费一区二区三区| 精品国产髙清在线看国产毛片| 国产在线日韩欧美| 亚洲国产高清aⅴ视频| gogogo免费视频观看亚洲一| 亚洲少妇中出一区| 欧美怡红院视频| 蜜桃一区二区三区四区| 亚洲精品一线二线三线无人区| 国产麻豆精品在线| 亚洲精品视频在线看| 欧美特级限制片免费在线观看| 日韩精品久久久久久| 久久久久国产一区二区三区四区| 成人激情视频网站| 一区二区久久久| 欧美一级二级三级乱码| 国产福利一区二区三区视频在线| 国产精品成人一区二区艾草| 欧美日韩一区二区三区四区 | 欧美色倩网站大全免费| 丝袜诱惑制服诱惑色一区在线观看| 国产精品人成在线观看免费| 91福利小视频| 久久av资源站| 亚洲综合视频网| 精品国产乱码久久久久久图片| jizzjizzjizz欧美| 久久精品av麻豆的观看方式| 国产精品久久一级| 日韩一区二区视频在线观看| 香蕉乱码成人久久天堂爱免费| 久久久影院官网| 欧美日韩高清一区二区不卡| 国产不卡免费视频| 男女性色大片免费观看一区二区 | 欧美二区乱c少妇| 国产成人免费av在线| 天堂成人国产精品一区| 亚洲欧洲成人自拍| 国产亚洲精品资源在线26u| 欧洲国产伦久久久久久久| 国产精品一线二线三线| 亚洲图片一区二区| 成人免费小视频| 26uuu精品一区二区| 91精品国产麻豆| 91精品1区2区| 成人av综合一区| 激情偷乱视频一区二区三区| 一区二区三区精品久久久| 国产精品麻豆欧美日韩ww| 欧美va在线播放| 欧美日韩一级黄| 欧美性感一区二区三区| 成人av电影免费在线播放| 激情综合一区二区三区| 日本成人在线一区| 日本欧美一区二区三区| 亚洲成人av在线电影| 亚洲成a天堂v人片| 亚洲资源在线观看| 一区二区欧美精品| 亚洲一区二区三区四区在线观看| **性色生活片久久毛片| 中文字幕制服丝袜一区二区三区| 中文成人综合网| 中文在线一区二区| 国产精品少妇自拍| 久久精品视频免费| 中文字幕不卡在线播放| 国产精品久久网站| 亚洲精品国产无套在线观| 亚洲精品免费播放| 亚洲精品成人a在线观看| 亚洲欧美国产77777| 综合久久久久久久| 一区二区国产视频| 天堂久久久久va久久久久| 爽爽淫人综合网网站| 蜜臂av日日欢夜夜爽一区| 美洲天堂一区二卡三卡四卡视频 | 91污片在线观看| 色综合色综合色综合色综合色综合 | 欧美r级在线观看| 久久久久88色偷偷免费| 国产精品久久影院| 亚洲自拍偷拍麻豆| 蜜臀av性久久久久蜜臀aⅴ四虎 | 成人高清视频免费观看| 欧美96一区二区免费视频| 美女www一区二区| 国产成人小视频| 99精品视频一区二区三区| 91官网在线免费观看| 91精品蜜臀在线一区尤物| 久久理论电影网| 亚洲欧美激情插 | 国产乱人伦偷精品视频不卡| 粉嫩在线一区二区三区视频| 色一区在线观看| 91精品国产麻豆国产自产在线| 久久久久亚洲蜜桃| 亚洲人成网站影音先锋播放| 日本成人在线网站| jlzzjlzz欧美大全| 精品国产一区二区亚洲人成毛片| 中文字幕国产一区| 喷白浆一区二区| 色8久久人人97超碰香蕉987| 欧美大肚乱孕交hd孕妇| 一区二区三区在线免费| 久久99国产精品尤物| 日本电影欧美片| 国产精品五月天|