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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ch13.htm

?? Java游戲開發(fā)
?? 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一区二区三区免费野_久草精品视频
国产亚洲综合在线| 美腿丝袜亚洲一区| 欧美日本免费一区二区三区| 成人黄色小视频| 成人免费电影视频| 国产成人免费9x9x人网站视频| 日韩电影一区二区三区| 狠狠色综合日日| 免费成人结看片| 狠狠色狠狠色综合系列| 日韩影院精彩在线| 国产在线视频一区二区| 成人av电影免费在线播放| 国产成人无遮挡在线视频| 国产成人午夜精品影院观看视频| 亚洲美女免费在线| 久久精品国产在热久久| 成人黄色a**站在线观看| 91在线国产观看| 欧美亚洲动漫制服丝袜| 精品国产制服丝袜高跟| 日本sm残虐另类| 国产欧美日韩麻豆91| 国产精品午夜电影| 韩国一区二区视频| 欧美美女一区二区三区| 欧美韩国日本不卡| 日本欧美加勒比视频| 337p亚洲精品色噜噜| 日韩理论片在线| 91免费版在线| 国产精品第四页| 91国偷自产一区二区开放时间| 亚洲精品水蜜桃| 欧美一区二区三区视频免费 | 亚洲国产欧美另类丝袜| 欧美色视频在线| 蜜臀久久99精品久久久久宅男| 91猫先生在线| 午夜精品一区二区三区电影天堂| 色婷婷国产精品| 亚洲h动漫在线| 久久久无码精品亚洲日韩按摩| 麻豆91在线播放| 一区二区在线看| 久久久久九九视频| 91视视频在线观看入口直接观看www | 欧美中文字幕一区二区三区 | 亚洲国产成人一区二区三区| 色婷婷久久久亚洲一区二区三区| 日本伊人精品一区二区三区观看方式| 国产欧美一区二区精品久导航| 日本一二三四高清不卡| 色狠狠一区二区| 激情五月婷婷综合| 亚洲成人一区二区在线观看| 欧美国产一区视频在线观看| 日韩一区二区影院| 欧美日韩精品欧美日韩精品一 | 欧美一区二区三区电影| 91麻豆国产在线观看| 国产成人亚洲综合a∨婷婷图片 | 久久免费视频色| 欧美成人免费网站| 欧美成人精品1314www| 在线电影欧美成精品| 欧美日韩视频在线一区二区| 色婷婷综合久久| 97国产一区二区| 欧美亚洲综合另类| 欧美猛男男办公室激情| 欧美日韩精品一区二区天天拍小说| 色中色一区二区| 3d成人h动漫网站入口| 国产清纯白嫩初高生在线观看91| 视频在线观看91| 一区av在线播放| 亚洲国产精品麻豆| 舔着乳尖日韩一区| 免费观看一级特黄欧美大片| 麻豆精品视频在线观看视频| 国产精品一二三四| 91在线porny国产在线看| 91久久精品一区二区二区| 欧美夫妻性生活| 中文字幕在线观看不卡| 天天av天天翘天天综合网色鬼国产| 一区二区三区在线不卡| 欧美电视剧在线看免费| 国产日韩三级在线| 蜜臀va亚洲va欧美va天堂| 99久久久国产精品免费蜜臀| 日韩精品一区二区三区在线| 中文字幕一区三区| 黄一区二区三区| 欧美巨大另类极品videosbest | 欧美日本视频在线| 亚洲猫色日本管| 福利一区在线观看| 久久久久88色偷偷免费| 午夜精品在线视频一区| 欧美日本在线播放| 日韩精品三区四区| 欧美婷婷六月丁香综合色| 国产精品午夜久久| 国产福利精品一区| 精品国产麻豆免费人成网站| 免费人成在线不卡| 欧美精品xxxxbbbb| 日韩中文字幕av电影| 欧美日本韩国一区二区三区视频 | 国产盗摄精品一区二区三区在线 | 99精品欧美一区二区蜜桃免费 | 亚洲图片自拍偷拍| 91精品国产一区二区| 香蕉成人伊视频在线观看| 欧美日韩一区二区三区不卡| 香港成人在线视频| 欧美zozozo| 色综合天天视频在线观看| 亚洲一二三区在线观看| 欧美日韩成人综合| 国产在线精品一区二区三区不卡| 国产日韩欧美一区二区三区乱码| 波多野结衣一区二区三区| 一区二区三区四区不卡在线 | 欧美xxxx在线观看| 91色.com| 久久国产精品色婷婷| 亚洲婷婷综合色高清在线| 69堂亚洲精品首页| 国产成人午夜精品5599| 久久成人羞羞网站| 亚洲综合男人的天堂| 国产精品福利影院| 欧美大片拔萝卜| 91麻豆精品国产91久久久久| 国产成人精品www牛牛影视| 午夜免费久久看| 五月婷婷色综合| 一区二区成人在线观看| 亚洲天堂网中文字| 国产精品毛片久久久久久| 久久久久综合网| 欧美国产国产综合| 国产精品国产成人国产三级| 国产精品传媒在线| 亚洲精品国产精华液| 午夜久久福利影院| 免费成人在线观看| 国产自产高清不卡| av综合在线播放| 91久久国产最好的精华液| 欧美性大战久久久久久久| 欧美精品一级二级三级| 欧美日韩精品一区二区三区蜜桃 | 26uuu色噜噜精品一区二区| 精品欧美久久久| 亚洲三级在线观看| 日本成人中文字幕| aa级大片欧美| 91精品国产乱码久久蜜臀| 久久一留热品黄| 国产精品久久久久久久久免费相片 | 91精品国产综合久久婷婷香蕉| 日韩一区二区三区av| 欧美一个色资源| 久久精品视频在线免费观看| 国产精品成人在线观看| 亚洲国产日韩a在线播放性色| 久久精品久久综合| 在线免费观看日韩欧美| 日韩精品一区二区三区老鸭窝| |精品福利一区二区三区| 亚洲成人久久影院| 色中色一区二区| 国产精品久久一级| 高清beeg欧美| 国产精品无码永久免费888| 麻豆中文一区二区| 精品毛片乱码1区2区3区| 日韩精品91亚洲二区在线观看| 99精品欧美一区二区蜜桃免费| 欧美国产一区二区在线观看| 丰满少妇久久久久久久| 日韩一区二区精品葵司在线 | 高清久久久久久| 亚洲欧美在线aaa| 欧美在线一二三| 欧美精品一区二区三区高清aⅴ | 91成人免费在线| 日本一区二区视频在线观看| 日日摸夜夜添夜夜添精品视频| 99re热这里只有精品免费视频| 欧美一二区视频| 亚洲欧美激情小说另类| 久久99国内精品| 51精品国自产在线| 亚洲欧美日韩在线播放| 99视频热这里只有精品免费|