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

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

?? ch13.htm

?? 有關于游戲開發的教程我閱讀后感覺不錯所以就拿出來與大家共享。
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
&nbsp;&nbsp;&nbsp;&nbsp;offGrfx = offImage.getGraphics();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;infoMetrics = offGrfx.getFontMetrics(infoFont);
<BR>
&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;// Draw the sprites<BR>
&nbsp;&nbsp;srv.draw(offGrfx);<BR>
<BR>
&nbsp;&nbsp;// Draw the game info<BR>
&nbsp;&nbsp;offGrfx.setFont(infoFont);<BR>
&nbsp;&nbsp;offGrfx.setColor(Color.white);<BR>
&nbsp;&nbsp;offGrfx.drawString(new String(&quot;Level: &quot;
+ level +<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&quot;&nbsp;&nbsp;Caught: &quot; + caught
+ &quot;&nbsp;&nbsp;Lost: &quot; + lost), 10, 5 +<BR>
&nbsp;&nbsp;&nbsp;&nbsp;infoMetrics.getAscent());<BR>
<BR>
&nbsp;&nbsp;// Is the game over?<BR>
&nbsp;&nbsp;if (lost &gt;= 5) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;Font&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f
= new Font(&quot;Helvetica&quot;, Font.BOLD, 36);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;FontMetrics fm = offGrfx.getFontMetrics(f);
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s
= new String(&quot;Game Over&quot;);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;offGrfx.setFont(f);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;offGrfx.drawString(s, (size().width -
fm.stringWidth(s)) / 2,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((size().height - fm.getHeight())
/ 2) + fm.getAscent());<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;// Stop the music<BR>
&nbsp;&nbsp;&nbsp;&nbsp;music.stop();<BR>
&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;else<BR>
&nbsp;&nbsp;&nbsp;&nbsp;// Add a new scorpion?<BR>
&nbsp;&nbsp;&nbsp;&nbsp;if ((rand.nextInt() % (20 - level / 2))
== 0)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;srv.add(new Scorpion(this,
1 -<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Math.abs(rand.nextInt()
% 2), level));<BR>
<BR>
&nbsp;&nbsp;// Draw the image onto the screen<BR>
&nbsp;&nbsp;g.drawImage(offImage, 0, 0, null);<BR>
}</TT>
</BLOCKQUOTE>
<HR>
<P>
After drawing the sprites, the <TT>update</TT>
method draws the game information in the upper left corner of
the applet window. The game information includes the difficulty
level, the number of scorpions caught, and the number of scorpions
lost. It then checks the <TT>lost</TT>
member variable to see whether it is greater than or equal to
<TT>5</TT>. If so, the game has ended,
so <TT>update</TT> draws the <TT>Game
Over</TT> message and stops the music. If the game isn't
over, <TT>update</TT> determines whether
or not it should add a new scorpion. This determination is based
on the current level and a little randomness.
<P>
The mouse input in the game is handled by four different methods:
<TT>mouseEnter</TT>, <TT>mouseExit</TT>,
<TT>mouseMove</TT>, and <TT>mouseDown</TT>.
<TT>mouseEnter</TT> and <TT>mouseExit</TT>
show and hide the net sprite based on the mouse being inside or
outside the applet window:
<BLOCKQUOTE>
<TT>public boolean mouseEnter(Event evt,
int x, int y) {<BR>
&nbsp;&nbsp;if (net != null)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;net.show();<BR>
&nbsp;&nbsp;return true;<BR>
}<BR>
<BR>
public boolean mouseExit(Event evt, int x, int y) {<BR>
&nbsp;&nbsp;if (net != null)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;net.hide();<BR>
&nbsp;&nbsp;return true;<BR>
}</TT>
</BLOCKQUOTE>
<P>
Showing and hiding the net sprite based on the mouse being in
the applet window visually helps tie the net to the mouse pointer.
The <TT>mouseMove</TT> method simply
sets the position of the net to the position of the mouse, which
causes the net to follow the mouse around:
<BLOCKQUOTE>
<TT>public boolean mouseMove(Event evt, int
x, int y) {<BR>
&nbsp;&nbsp;if (net != null)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;net.setPosition(new Point(x - 10, y -
10));<BR>
&nbsp;&nbsp;return true;<BR>
}</TT>
</BLOCKQUOTE>
<P>
The last of the mouse input methods, <TT>mouseDown</TT>,
checks to see whether a scorpion has been caught by calling the
<TT>isPointInside</TT> method:
<BLOCKQUOTE>
<TT>public boolean mouseDown(Event evt, int
x, int y) {<BR>
&nbsp;&nbsp;if (lost &lt; 5) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;Sprite s = srv.isPointInside(new Point(x
- 5, y - 5));<BR>
&nbsp;&nbsp;&nbsp;&nbsp;if (s != null) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Remove the scorpion and
increase number caught<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;srv.removeElement(s);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((++caught % 15) == 0)
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Increase the
level and play applause sound<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;level++;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;applause.play();
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Play the net
hit sound<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;netHit.play();
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;else<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Play the net miss sound
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;netMiss.play();<BR>
&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;return true;<BR>
}</TT>
</BLOCKQUOTE>
<P>
If no scorpion has been caught, the <TT>mouseDown</TT>
method plays the <TT>netMiss</TT>
audio clip. If a scorpion has been caught, the scorpion sprite
is removed from the list, and the <TT>caught</TT>
member variable is incremented. If <TT>caught</TT>
is divisible by <TT>15</TT>, <TT>level</TT>
is also incremented, and the <TT>applause</TT>
audio clip is played. This results in a new level being reached
for every 15 scorpions that are caught.
<P>
The keyboard input in Scorpion Roundup is only used to start a
new game or toggle the music on and off. The <TT>keyDown</TT>
method checks for these keys and takes the appropriate actions:
<BLOCKQUOTE>
<TT>public boolean keyDown(Event evt, int
key) {<BR>
&nbsp;&nbsp;if ((key == (int)'n') || (key == (int)'N'))<BR>
&nbsp;&nbsp;&nbsp;&nbsp;newGame();<BR>
&nbsp;&nbsp;else if ((key == (int)'m') || (key == (int)'M')) {
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;musicOn = !musicOn;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;if (musicOn)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;music.loop();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;else<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;music.stop();<BR>
&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;return true;<BR>
}<BR>
Finally, you arrive at the newGame method:<BR>
void newGame() {<BR>
&nbsp;&nbsp;// Set up a new game<BR>
&nbsp;&nbsp;level = 1;<BR>
&nbsp;&nbsp;caught = lost = 0;<BR>
&nbsp;&nbsp;srv = new SRVector(new ImageBackground(this, back));
<BR>
&nbsp;&nbsp;net = new Sprite(this, netImage, new Point((size().width
-<BR>
&nbsp;&nbsp;&nbsp;&nbsp;netImage.getWidth(this)) / 2, (size().height
-<BR>
&nbsp;&nbsp;&nbsp;&nbsp;netImage.getHeight(this)) / 2), new Point(0,
0), 20,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;Sprite.BA_WRAP);<BR>
&nbsp;&nbsp;srv.add(net);<BR>
&nbsp;&nbsp;if (musicOn)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;music.loop();<BR>
}</TT>
</BLOCKQUOTE>
<P>
The <TT>newGame</TT> method does everything
necessary to initialize and start a new game: The <TT>level</TT>,
<TT>caught</TT>, and <TT>lost</TT>
member variables are initialized, the sprite list is re-created,
and the net sprite is re-created and added back to the list. The
music is also restarted.
<P>
That wraps up the details of Scorpion Roundup, your second complete
Java game. You are fast becoming a Java game expert! However,
before you throw the book down and start hacking away at a game
of your own, make sure you fully understand how this game works.
I encourage you to try your hand at enhancing it and adding some
new features. For some enhancement ideas, check out the &quot;Exercises&quot;
section at the end of this lesson.
<H2><A NAME="Summary"><B><FONT SIZE=5 COLOR=#FF0000>Summary</FONT></B></A>
</H2>
<P>
In today's lesson, you built your second complete Java game-Scorpion
Roundup. You began by learning a little background on the game,
followed by fleshing out the conceptual game design. With the
groundwork laid, you saw that it wasn't so bad moving on to the
actual game implementation. It was still a lot of work, but it
resulted in a pretty neat game that made use of mouse input, sound
effects, and music.
<P>
With another complete game under your belt, you're probably feeling
pretty invincible. It's a good thing too, because tomorrow you're
going to shift gears and tackle an often difficult and sobering
aspect of game programming-debugging. Tomorrow's lesson covers
all the big issues relating to hunting down and ridding your games
of bugs. But you don't need to worry about that now; go play a
few games of Scorpion Roundup and relax!
<H2><A NAME="QA"><B><FONT SIZE=5 COLOR=#FF0000>Q&amp;A</FONT></B></A>
<BR>
</H2>

<TABLE>
<TR VALIGN=TOP><TD WIDTH=50><B>Q</B></TD><TD><B>Are scorpions really popular as pets?</B>
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=50><B>A</B></TD><TD>Yes they are. If you're interested in adopting your own pet scorpion, the folks at Glades Herp, Inc. would be glad to help you out. They are on the Web and can be found at <TT><A 
HREF="http://www.tntonline.com/gherp/gherp.htm">http://www.tntonline.com/gherp/gherp.htm</A></TT>.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=50><B>Q</B></TD><TD><B>Why are the scorpions in the game colored green?</B>
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=50><B>A</B></TD><TD>Because scorpion hunters use black lights to illuminate scorpions at night, thereby making them visible. The black light causes the scorpions to take on a greenish glow.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=50><B>Q</B></TD><TD><B>Why isn't the net sprite implemented as a new sprite class?</B>
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=50><B>A</B></TD><TD>Because it doesn't require any new functionality beyond that provided by the <TT>Sprite</TT> class. You should make a strong effort to only derive new classes when you specifically need to add new functionality.

</TD></TR>
<TR VALIGN=TOP><TD WIDTH=50><B>Q</B></TD><TD><B>Why is the music in Scorpion Roundup so repetitive?</B>
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=50>A</TD><TD>The music is implemented as a looped audio clip. Because audio clips tend to take up a lot of space and therefore take a while to transfer over an Internet connection, it is important to keep them as short as possible. 
Although it is short and repetitive, the music in Scorpion Roundup still manages to add an interesting dimension to the game without taking all day to transfer.
</TD></TR>
</TABLE>
<P>
<H2><A NAME="Workshop"><B><FONT SIZE=5 COLOR=#FF0000>Workshop</FONT></B></A>
</H2>
<P>
The Workshop section provides questions and exercises to help
you get a better feel for the material you learned today. Try
to answer the questions and at least think about the exercises
before moving on to tomorrow's lesson. You'll find the answers
to the questions in appendix A, &quot;Quiz Answers.&quot;
<H3><A NAME="Quiz"><B>Quiz</B></A></H3>
<OL>
<LI>Which major U.S. airport is a good place to find scorpion
souvenirs?
<LI>Why do you need the <TT>SRVector</TT>
class?
<LI>Why do scorpions only come out at night?
<LI>Why is the music stopped in the <TT>stop</TT>
method of the <TT>ScorpionRoundup</TT>
class?
<LI>Why is the <TT>lost</TT> member
variable in the <TT>ScorpionRoundup</TT>
class declared as public static?
</OL>
<H3><A NAME="Exercises"><B>Exercises</B></A></H3>
<OL>
<LI>Order your own pet scorpion and give it a loving home.
<LI>Make the net a frame-animated sprite that gives the effect
of the net waving in the air.
<LI>Buy a black light and see whether your pet scorpion really
looks green.
<LI>Change the sound effects and music to use your own custom
audio clips.
<LI>Add some entirely new sound effects, such as a laughter sound
when a scorpion gets away.
<LI>Use the Scorpion Roundup code to create an entirely new game.
For example, you could change the graphics and sound, modify the
code a little, and turn the game into a target shooting game.
Just change the background to a picture of a sky, the net to cross-hairs,
and the scorpions to clay targets. Then modify the code so that
the clay targets arch through the air, and use a gunshot sound
instead of the swoosh sound used for the net. You'll have a whole
new game!
</OL>
<P>
<HR WIDTH="100%"></P>

<CENTER><P><A HREF="ch12.htm"><IMG SRC="pc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="index.htm"><IMG SRC="hb.gif" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="#CONTENTS"><IMG SRC="cc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="ch14.htm"><IMG 
SRC="nc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A></P></CENTER>

<P>
<HR WIDTH="100%"></P>

</BODY>
</HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆成人久久精品二区三区| 国产成人综合自拍| 九九九精品视频| 99免费精品在线| 精品对白一区国产伦| 亚洲你懂的在线视频| 国产米奇在线777精品观看| 欧美三区在线观看| 中文字幕一区二| 国产一区二区三区四区在线观看| 色嗨嗨av一区二区三区| 国产三级欧美三级日产三级99| 亚洲一二三区在线观看| 成人爽a毛片一区二区免费| 精品区一区二区| 秋霞成人午夜伦在线观看| 在线观看日韩国产| 亚洲免费av观看| 91在线精品秘密一区二区| 久久精品男人天堂av| 九九精品一区二区| 制服丝袜中文字幕一区| 偷窥少妇高潮呻吟av久久免费| 色婷婷综合五月| 亚洲黄色录像片| 一本一道久久a久久精品| 中文字幕一区二区三区蜜月| 国产不卡免费视频| 日本一区二区三区四区 | 亚洲视频电影在线| www.久久精品| 成人欧美一区二区三区黑人麻豆| 国产盗摄女厕一区二区三区| 国产视频一区二区在线观看| 床上的激情91.| 国产精品国产三级国产a| zzijzzij亚洲日本少妇熟睡| 中文字幕一区二区三区四区 | 国产精品成人网| 成人av一区二区三区| 国产精品的网站| 色天使久久综合网天天| 亚洲与欧洲av电影| 欧美精品高清视频| 国产综合久久久久久久久久久久| 久久夜色精品国产噜噜av| 国产成人综合亚洲91猫咪| 国产午夜久久久久| 99久久99久久综合| 亚洲成人av一区| 日韩欧美视频在线 | 青娱乐精品在线视频| 日韩欧美中文字幕精品| 精品一区二区三区蜜桃| 久久久精品综合| 色婷婷综合激情| 热久久一区二区| 欧美—级在线免费片| 91视频一区二区| 日本不卡一区二区| 国产日韩精品一区| 欧美中文字幕一区二区三区| 日一区二区三区| 日本一区二区三区免费乱视频| 色婷婷亚洲一区二区三区| 青椒成人免费视频| 亚洲欧洲精品一区二区精品久久久 | 五月激情综合网| 中文字幕欧美激情| 欧美另类久久久品| 国产精品1024久久| 五月婷婷综合激情| 国产精品剧情在线亚洲| 欧美剧情片在线观看| 国产99精品在线观看| 艳妇臀荡乳欲伦亚洲一区| 久久久五月婷婷| 欧美日韩精品二区第二页| 国产美女精品一区二区三区| 亚洲一区二区视频在线| 国产欧美一区在线| 在线不卡的av| 91日韩精品一区| 国产精品99久久久久久久女警| 亚洲小少妇裸体bbw| 国产精品女主播av| 亚洲精品在线电影| 8x8x8国产精品| 欧美中文字幕一区| 91免费在线视频观看| 激情小说欧美图片| 免费成人小视频| 亚洲一区二区三区视频在线| 中文字幕在线观看不卡| 日韩欧美你懂的| 制服丝袜中文字幕一区| 在线视频综合导航| 色婷婷一区二区三区四区| 成人高清伦理免费影院在线观看| 九九**精品视频免费播放| 性感美女极品91精品| 一区二区三区在线观看欧美| 国产精品欧美久久久久无广告 | 在线播放视频一区| 欧美日韩精品一区二区三区| 一本高清dvd不卡在线观看| 懂色av噜噜一区二区三区av| 国产美女av一区二区三区| 美美哒免费高清在线观看视频一区二区 | 国产成a人亚洲精品| 黄网站免费久久| 九色|91porny| 奇米精品一区二区三区在线观看 | 99精品久久久久久| av亚洲精华国产精华精| 成人动漫视频在线| 不卡欧美aaaaa| 99久久久精品| 在线视频你懂得一区| 欧美色图在线观看| 这里只有精品视频在线观看| 91精品国产免费| 欧美大片日本大片免费观看| 日韩精品中文字幕一区二区三区| 欧美电影免费观看高清完整版在线| 日韩手机在线导航| 久久亚区不卡日本| 国产精品区一区二区三区| 国产精品国产精品国产专区不蜜 | 中文字幕成人av| 亚洲免费观看高清完整| 亚洲综合区在线| 亚洲国产精品久久久久婷婷884 | 亚洲一区二区成人在线观看| 亚洲曰韩产成在线| 免费成人av在线播放| 国产精品一级片在线观看| 成人丝袜18视频在线观看| 在线精品视频免费播放| 91精品国产综合久久国产大片| 欧美成人伊人久久综合网| 国产欧美一区二区三区沐欲| 亚洲欧美日韩在线不卡| 视频在线观看91| 国产福利91精品| 欧美性受xxxx黑人xyx性爽| 日韩免费看的电影| 国产精品美日韩| 偷拍日韩校园综合在线| 懂色av一区二区三区蜜臀 | 成人av电影观看| 欧美另类久久久品| 国产精品妹子av| 卡一卡二国产精品 | 欧美亚洲尤物久久| 精品久久久久久亚洲综合网 | 在线观看欧美日本| 日韩写真欧美这视频| 国产精品入口麻豆九色| 秋霞午夜av一区二区三区| 91丨九色丨国产丨porny| 日韩欧美一区二区在线视频| 亚洲欧美综合另类在线卡通| 免费人成精品欧美精品| 色婷婷综合激情| 久久精品亚洲国产奇米99| 午夜精品成人在线视频| www.成人在线| 久久亚洲捆绑美女| 亚洲综合区在线| 99久久99久久精品免费看蜜桃| 欧美一区二区三区性视频| 亚洲色图色小说| 国产精品羞羞答答xxdd| 欧美一级日韩不卡播放免费| 亚洲欧洲综合另类| 福利91精品一区二区三区| 日韩三级av在线播放| 午夜天堂影视香蕉久久| 91视频在线观看| 亚洲视频一区在线| 成人免费毛片片v| 久久综合色天天久久综合图片| 日韩电影在线一区二区三区| 色综合天天综合网国产成人综合天 | 亚洲成人免费视频| 99re8在线精品视频免费播放| 精品日韩在线观看| 看电视剧不卡顿的网站| 欧美一卡二卡在线观看| 日本欧美大码aⅴ在线播放| 欧美日本韩国一区二区三区视频| 亚洲精品国产精华液| 日本久久精品电影| 亚洲欧美激情视频在线观看一区二区三区| 国产成人夜色高潮福利影视| 久久久久久影视| 国产盗摄精品一区二区三区在线 | 26uuu亚洲综合色欧美 | 一本到高清视频免费精品|