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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? ch10.htm

?? 有關(guān)于游戲開(kāi)發(fā)的教程我閱讀后感覺(jué)不錯(cuò)所以就拿出來(lái)與大家共享。
?? HTM
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
&nbsp;&nbsp;public static Image[] image;<BR>
<BR>
&nbsp;&nbsp;public GilaMonster(Component comp) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;super(comp, image, 0, 1, 4, new Point(comp.size().width
-<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;image[0].getWidth(comp), 45),
new Point(-1, 0), 30,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sprite.BA_WRAP);<BR>
&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;public static void initResources(Applet app, MediaTracker
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;tracker, int id) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;image = new Image[2];<BR>
&nbsp;&nbsp;&nbsp;&nbsp;for (int i = 0; i &lt; 2; i++) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;image[i] = app.getImage(app.getCodeBase(),
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;Res/GilaMon&quot;
+ i + &quot;.gif&quot;);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tracker.addImage(image[i],
id);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;protected void setCollision() {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;collision = new Rectangle(position.x +
3, position.y + 3,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position.width - 6, position.height
- 6);<BR>
&nbsp;&nbsp;}<BR>
}</FONT></TT>
</BLOCKQUOTE>
<HR>
<P>
The <TT><FONT FACE="Courier">GilaMonster</FONT></TT> class uses
two images to show a simple animation of a Gila monster kicking
its legs. The constructor specifies a fixed horizontal velocity
that, when combined with the frame animation, gives the effect
of the Gila monster walking. Admittedly, having only two frame
animations creates some limitation in how effective the illusion
of walking is in this case. But remember that you're trying to
avoid using tons of graphics that take up precious time loading
over the Internet.
<P>
The three other predator classes (<TT><FONT FACE="Courier">Scorpion</FONT></TT>,
<TT><FONT FACE="Courier">Rattler</FONT></TT>, and <TT><FONT FACE="Courier">Tarantula</FONT></TT>)
are almost identical to <TT><FONT FACE="Courier">GilaMonster</FONT></TT>,
with the changes being the velocities, the images loaded in <TT><FONT FACE="Courier">initResources</FONT></TT>,
and the amount that the collision rectangle is shrunken. Based
on the code for <TT><FONT FACE="Courier">GilaMonster</FONT></TT>,
you might be wondering why it's even implemented as a derived
sprite class. It doesn't really add any new functionality; you
could just as easily create a Gila monster using the <TT><FONT FACE="Courier">Sprite</FONT></TT>
class. The truth is that all the predator classes are created
as more of a convenience than a necessity. Allowing the classes
to manage their own image resources via <TT><FONT FACE="Courier">initResources</FONT></TT>,
as well as having self-contained constructors that don't take
a bunch of parameters, improves organization.
<P>
This goes against typical object-oriented design because the classes
don't technically add any new functionality. However, the clean
packaging of the classes and their improved ease of use makes
them justifiable in this case. You might think that I'm taking
a lot of liberties by encouraging you to break the rules that
are so crucial in object-oriented languages such as Java. That's
not entirely true. The real skill in object-oriented programming
is in knowing when to apply OOP techniques and when to leverage
them against more simple solutions, as you've done here.
<P>
The <TT><FONT FACE="Courier">Rock</FONT></TT> class is the last
of the <TT><FONT FACE="Courier">Sprite</FONT></TT> derived classes
used in Traveling Gecko. Listing 10.4 contains the source code
for the <TT><FONT FACE="Courier">Rock</FONT></TT> class.
<HR>
<BLOCKQUOTE>
<B>Listing 10.4. The </B><TT><B><FONT FACE="Courier">Rock</FONT></B></TT><B>
class<BR>
</B>
</BLOCKQUOTE>
<BLOCKQUOTE>
<TT><FONT FACE="Courier">public class Rock extends Sprite {<BR>
&nbsp;&nbsp;public static Image[] image;<BR>
<BR>
&nbsp;&nbsp;public Rock(Component comp, int i) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;super(comp, image, i, 0, 0, new Point((i
% 2 == 0) ? 0 :<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comp.size().width - image[i].getWidth(comp),
(i &lt; 2) ?<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 : comp.size().height - image[i].getHeight(comp)),
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new Point(0, 0), 40, Sprite.BA_STOP);
<BR>
&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;public static void initResources(Applet app, MediaTracker
tracker,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;int id) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;image = new Image[4];<BR>
&nbsp;&nbsp;&nbsp;&nbsp;for (int i = 0; i &lt; 4; i++) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;image[i] = app.getImage(app.getCodeBase(),
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;Res/Rock&quot;
+ i + &quot;.gif&quot;);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tracker.addImage(image[i],
id);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;public BitSet update() {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return (new BitSet());<BR>
&nbsp;&nbsp;}<BR>
}</FONT></TT>
</BLOCKQUOTE>
<HR>
<P>
The <TT><FONT FACE="Courier">Rock</FONT></TT> class is somewhat
similar to the predator classes in that it doesn't add much functionality.
However, you have a very useful reason for creating a <TT><FONT FACE="Courier">Rock</FONT></TT>
class, as opposed to just creating rocks as <TT><FONT FACE="Courier">Sprite</FONT></TT>
objects. That reason has to do with an optimization related to
the <TT><FONT FACE="Courier">update</FONT></TT> method. If you
recall, the <TT><FONT FACE="Courier">update</FONT></TT> method
is called for every sprite in the sprite list to allow the animation
frame and position to be updated. Rocks have no animation frames
and the positions are fixed. Therefore, you can speed things up
a little by overriding <TT><FONT FACE="Courier">update</FONT></TT>
with a &quot;do nothing&quot; version. Because speed is a crucial
issue in games, especially Java games, seemingly small optimizations
like this can add up in the end.
<P>
<CENTER><TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR><TD><B>Note</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
The trick that is used to help improve speed in the <TT><FONT FACE="Courier">Rock</FONT></TT> class's <TT><FONT FACE="Courier">update</FONT></TT> method brings up a good point in regard to game programming: Don't be afraid to override unneeded methods with 
&quot;do nothing&quot; versions. Every little bit of execution overhead that you can eliminate will ultimately improve the performance of a game. If you see a way to cut a corner in a derived class simply by overriding a parent class method, go for it! 
Just remember to wait and look for these types of shortcuts after the code is already working.
</BLOCKQUOTE>

</TD></TR>
</TABLE></CENTER>
<P>
<P>
The only other sprite-related class to deal with in regard to
Traveling Gecko is the derived <TT><FONT FACE="Courier">SpriteVector</FONT></TT>
class, <TT><FONT FACE="Courier">TGVector</FONT></TT>. You need
the <TT><FONT FACE="Courier">TGVector</FONT></TT> class to handle
the collisions between the sprites. Listing 10.5 contains the
source code for the <TT><FONT FACE="Courier">TGVector</FONT></TT>
class.
<HR>
<BLOCKQUOTE>
<B>Listing 10.5. The </B><TT><B><FONT FACE="Courier">TGVector</FONT></B></TT><B>
class.<BR>
</B>
</BLOCKQUOTE>
<BLOCKQUOTE>
<TT><FONT FACE="Courier">public class TGVector extends SpriteVector
{<BR>
&nbsp;&nbsp;private Component component;<BR>
<BR>
&nbsp;&nbsp;public TGVector(Background back, Component comp) {
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;super(back);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;component = comp;<BR>
&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;protected boolean collision(int i, int iHit) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;Sprite s = (Sprite)elementAt(i);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;Sprite sHit = (Sprite)elementAt(iHit);
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;if (sHit.getClass().getName().equals(&quot;Rock&quot;))
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Collided with rock, so
stay put<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;else if (sHit.getClass().getName().equals(&quot;Geckocide&quot;))
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Collided with geckocide,
so do nothing<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;else if (s.getClass().getName().equals(&quot;Gecko&quot;))
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Kill or reposition it<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point pos = new Point(s.getPosition().x,
s.getPosition().y);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (--TravelingGecko.lives
&lt;= 0)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;removeElementAt(i--);
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s.setPosition(new
Point(42, 232));<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Collided with bad guy,
so add geckocide<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (add(new Geckocide(component,
pos)) &lt;= i)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i++;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return false;<BR>
&nbsp;&nbsp;}<BR>
}</FONT></TT>
</BLOCKQUOTE>
<HR>
<P>
As you can see, the only overridden method in <TT><FONT FACE="Courier">TGVector</FONT></TT>
is <TT><FONT FACE="Courier">collision</FONT></TT>, which is called
when a collision occurs between two sprites. The sprite hit in
the collision is first checked to see whether it is a <TT><FONT FACE="Courier">Rock</FONT></TT>
object. If so, <TT><FONT FACE="Courier">true</FONT></TT> is returned,
which causes the sprite that is doing the hitting to stay where
it is and not use its updated position. This results in the gecko
being stopped when he runs into a rock.
<P>
The sprite being hit is then checked to see whether it is a <TT><FONT FACE="Courier">Geckocide</FONT></TT>
object, in which case <TT><FONT FACE="Courier">collision</FONT></TT>
returns <TT><FONT FACE="Courier">false</FONT></TT>. This results
in allowing the sprite that is doing the hitting to continue on
its course, and basically results in a null collision. The purpose
of this code is to make sure that <TT><FONT FACE="Courier">Geckocide</FONT></TT>
objects don't interfere with any other objects; they are effectively
ignored by the collision detection routine.
<P>
The real work begins when the hitting sprite is checked to see
whether it is a <TT><FONT FACE="Courier">Gecko</FONT></TT> object.
If so, you know that the gecko has collided with a predator, so
the number of lives is decremented. The <TT><FONT FACE="Courier">lives</FONT></TT>
variable is like <TT><FONT FACE="Courier">score</FONT></TT> because
it is a public static member of the <TT><FONT FACE="Courier">TravelingGecko</FONT></TT>
applet class. If <TT><FONT FACE="Courier">lives</FONT></TT> is
less than or equal to zero, the game is over and the <TT><FONT FACE="Courier">Gecko</FONT></TT>
object is removed from the sprite list. If <TT><FONT FACE="Courier">lives</FONT></TT>
is greater than zero, the gecko is repositioned back at the starting
position. To the player, it appears as if a new gecko has been
created, but you're really just moving the old one. Because a
gecko has died in either case, a <TT><FONT FACE="Courier">Geckocide</FONT></TT>
object is created.
<P>
At this point, you've seen all the supporting sprite classes required
of Traveling Gecko. The last step is to see what tasks the applet
class itself is responsible for.
<H3><A NAME="TheTravelingGeckoClass"><B>The </B><TT><B><FONT SIZE=4 FACE="Courier">TravelingGecko</FONT></B></TT><B><FONT SIZE=4>
Class</FONT></B></A></H3>
<P>
The <TT><FONT FACE="Courier">TravelingGecko</FONT></TT> class
drives the applet and takes care of higher-level issues such as
dealing with user input. Much of this class consists of animation
overhead that you're already familiar with, so let's skip ahead
to the more interesting aspects of <TT><FONT FACE="Courier">TravelingGecko</FONT></TT>.
<P>
The <TT><FONT FACE="Courier">init</FONT></TT> method adds a new
twist by creating the New Game button. It also handles initializing
all the resources for the different sprites. The code for the
<TT><FONT FACE="Courier">init</FONT></TT> method is shown in Listing
10.6.
<HR>
<BLOCKQUOTE>
<B>Listing 10.6. The </B><TT><B><FONT FACE="Courier">TravelingGecko</FONT></B></TT><B>
class's </B><TT><B><FONT FACE="Courier">init</FONT></B></TT><B>
method.<BR>
</B>
</BLOCKQUOTE>
<BLOCKQUOTE>
<TT><FONT FACE="Courier">public void init() {<BR>

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆精品国产91久久久久 | 一区二区理论电影在线观看| 成人黄色av电影| 久久一区二区三区国产精品| 国产成人在线视频网站| 国产精品黄色在线观看| 色婷婷av一区二区三区软件 | 国产自产高清不卡| 国产日韩欧美亚洲| 97久久超碰精品国产| 亚洲欧洲日产国码二区| 欧美又粗又大又爽| 免费在线观看一区| 精品国内二区三区| a级高清视频欧美日韩| 亚洲一卡二卡三卡四卡无卡久久| 欧美精品aⅴ在线视频| 国内成人免费视频| 国产精品区一区二区三区| 欧美性一级生活| 久久99国产精品久久99| 成人欧美一区二区三区在线播放| 欧美日韩大陆一区二区| 久久精品国产亚洲a| 中文字幕一区二区三区蜜月| 正在播放亚洲一区| 国产精品一区二区男女羞羞无遮挡| 亚洲男人的天堂一区二区 | 久久综合一区二区| eeuss鲁片一区二区三区| 午夜电影网亚洲视频| 久久综合狠狠综合久久综合88| 99re热这里只有精品免费视频| 三级亚洲高清视频| 综合久久久久久久| 欧美精品一区二区高清在线观看 | 91视频xxxx| 国产综合色精品一区二区三区| 亚洲欧美视频在线观看视频| 久久综合精品国产一区二区三区 | 欧美性色综合网| 国产麻豆精品久久一二三| 亚洲精品你懂的| 国产女同互慰高潮91漫画| 欧美老年两性高潮| 色婷婷久久综合| 国产精品123| 麻豆精品久久精品色综合| 亚洲猫色日本管| 国产拍欧美日韩视频二区| 777精品伊人久久久久大香线蕉| 粉嫩一区二区三区在线看| 久久er精品视频| 午夜精品久久一牛影视| 亚洲精品免费电影| 国产精品色哟哟网站| 337p粉嫩大胆噜噜噜噜噜91av| 国产欧美综合在线观看第十页| 国产精品一区二区无线| 蜜桃视频一区二区三区在线观看| 一区二区三区四区激情| 综合分类小说区另类春色亚洲小说欧美| 日韩欧美亚洲国产精品字幕久久久 | 国产嫩草影院久久久久| 精品久久免费看| 欧美一区二区女人| 91 com成人网| 欧美精品丝袜中出| 7777女厕盗摄久久久| 欧美日韩国产免费一区二区| 欧美亚洲综合久久| 欧美性xxxxxxxx| 精品视频在线看| 欧美三级电影网站| 欧美日韩一级二级| 欧美日韩一区成人| 91精品国产欧美日韩| 91精品免费观看| 日韩欧美黄色影院| 久久美女高清视频| 欧美国产1区2区| 中文字幕在线不卡视频| 亚洲天堂av一区| 亚洲嫩草精品久久| 丝袜诱惑制服诱惑色一区在线观看 | 精品写真视频在线观看| 国产在线国偷精品产拍免费yy| 国产一区亚洲一区| 9色porny自拍视频一区二区| 99久久国产综合精品色伊| 99在线精品一区二区三区| 91国产成人在线| 91精品国产综合久久国产大片| 日韩一区二区三区av| 久久九九久精品国产免费直播| 久久精品一区二区三区不卡牛牛| 国产精品无遮挡| 亚洲网友自拍偷拍| 久久av资源网| 99国产麻豆精品| 欧美老人xxxx18| 国产三级欧美三级日产三级99| 最新日韩在线视频| 婷婷一区二区三区| 黑人精品欧美一区二区蜜桃| 99久久伊人网影院| 欧美另类变人与禽xxxxx| 久久婷婷久久一区二区三区| 亚洲欧美一区二区三区孕妇| 日韩精品乱码免费| 成人午夜视频福利| 欧美精品亚洲一区二区在线播放| 久久久蜜臀国产一区二区| 亚洲摸摸操操av| 免费观看在线色综合| 成人午夜又粗又硬又大| 欧美人牲a欧美精品| 国产三级欧美三级| 成人精品gif动图一区| 成人av先锋影音| 欧美一区二区三区精品| 国产精品私人影院| 日韩二区三区四区| 成人动漫一区二区三区| 欧美久久久久久久久| 国产精品美女久久久久av爽李琼| 亚洲aⅴ怡春院| 不卡一卡二卡三乱码免费网站| 91精品国产色综合久久不卡蜜臀| 国产精品久久毛片a| 日本伊人精品一区二区三区观看方式| 国产一区二区三区综合| 欧美综合久久久| 国产亚洲欧美色| 肉丝袜脚交视频一区二区| aaa欧美大片| 久久久久久黄色| 青娱乐精品在线视频| 91久久免费观看| 国产日韩三级在线| 美女一区二区三区在线观看| 日本电影欧美片| 国产精品初高中害羞小美女文| 麻豆国产精品视频| 欧美在线看片a免费观看| 国产精品入口麻豆原神| 久久草av在线| 日韩午夜激情视频| 亚洲mv在线观看| 在线精品视频一区二区三四| 亚洲天堂免费看| 成人99免费视频| 国产亚洲va综合人人澡精品| 另类小说综合欧美亚洲| 91精品在线麻豆| 亚洲va欧美va国产va天堂影院| 色哟哟亚洲精品| 亚洲精品国产无天堂网2021 | 亚洲成人手机在线| 日本韩国精品在线| 自拍偷拍亚洲欧美日韩| av网站一区二区三区| 欧美国产欧美亚州国产日韩mv天天看完整| 麻豆传媒一区二区三区| 日韩亚洲欧美中文三级| 裸体歌舞表演一区二区| 日韩免费看的电影| 精品一区二区三区在线观看国产 | 成人国产精品免费观看动漫| 国产亚洲精品资源在线26u| 国产一区二区不卡在线 | 国产精品素人视频| jvid福利写真一区二区三区| 国产精品国产馆在线真实露脸 | 久久在线免费观看| 国产成人精品网址| 国产精品久久久久久久午夜片 | 婷婷一区二区三区| 日韩一区二区在线观看视频播放| 免费在线视频一区| 精品国产一区二区三区av性色| 奇米四色…亚洲| 国产亚洲欧美激情| 99久久婷婷国产| 国产成人自拍高清视频在线免费播放| 精品国精品自拍自在线| 国产精品888| 国产精品久久久久aaaa| 色94色欧美sute亚洲线路二| 亚洲自拍偷拍麻豆| 欧美一区二区播放| 国产乱人伦偷精品视频免下载| 欧美极品美女视频| 欧洲日韩一区二区三区| 日本伊人色综合网| 久久久久久久电影| 一本色道久久综合狠狠躁的推荐| 亚洲第一狼人社区| 337p粉嫩大胆噜噜噜噜噜91av| av在线播放一区二区三区|