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

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

?? ch13.htm

?? Java游戲開發
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<HTML>

<HEAD>
   <TITLE>Chapter 13 -- Scorpion Roundup: Action By Moonlight</TITLE>
   <META>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#CE2910">
<H1><FONT COLOR=#FF0000>Chapter 13</FONT></H1>
<H1><B><FONT SIZE=5 COLOR=#FF0000>Scorpion Roundup: Action By Moonlight</FONT></B>
</H1>
<P>
<HR WIDTH="100%"></P>
<P>
<H3 ALIGN=CENTER><FONT COLOR="#000000"><FONT SIZE=+2>CONTENTS<A NAME="CONTENTS"></A>
</FONT></FONT></H3>


<UL>
<LI><A HREF="#DesigningScorpionRoundup" >Designing Scorpion Roundup</A>
<UL>
<LI><A HREF="#Sprites" >Sprites</A>
<LI><A HREF="#GamePlay" >Game Play</A>
<LI><A HREF="#Options" >Options</A>
</UL>
<LI><A HREF="#SampleAppletScorpionRoundup" >Sample Applet: Scorpion Roundup</A>
<UL>
<LI><A HREF="#TheSpriteClasses" >The Sprite Classes</A>
<LI><A HREF="#TheScorpionRoundupClass" >The ScorpionRoundup Class</A>
</UL>
<LI><A HREF="#Summary" >Summary</A>
<LI><A HREF="#QA" >Q&amp;A</A>
<LI><A HREF="#Workshop" >Workshop</A>
<UL>
<LI><A HREF="#Quiz" >Quiz</A>
<LI><A HREF="#Exercises" >Exercises</A>
</UL>
</UL>
<HR>
<P>
Yesterday you saw how sound is supported in Java. You also wrote
a fairly simple applet to demonstrate how sound can be used in
a creative way. Today you go a step further by creating your second
complete game, including sound effects and music. The entire lesson
today is devoted to the design and development of this game, which
will provide you with another invaluable Java game creation experience.
<P>
The game you develop today is called Scorpion Roundup, and it
uses the all too familiar sprite classes to implement its animation
and sprite interactions. It uses the <TT>AudioClip</TT>
class you learned about in yesterday's lesson to represent both
sound effects and music. Unlike the Traveling Gecko game you developed
a few days ago, which used the keyboard exclusively for user input,
Scorpion Roundup uses the mouse as the user input device. You'll
see why when you get into the game.
<P>
The following topics are covered in today's lesson:
<UL>
<LI>Designing Scorpion Roundup
<LI>Sample applet: Scorpion Roundup
</UL>
<H2><A NAME="DesigningScorpionRoundup"><B><FONT SIZE=5 COLOR=#FF0000>Designing
Scorpion Roundup</FONT></B></A></H2>
<P>
Unlike Traveling Gecko, Scorpion Roundup isn't directly modeled
after any other game. Before getting into how the game plays,
you need some background on the premise surrounding the game,
because it is based on a very real concept that is pretty interesting.
<P>
Scorpions are fairly popular as pets. Not quite as popular as
dogs or cats, but what do you expect? They are also useful in
captivity for retrieving their poison, which is used in developing
antivenin medicine for people and pets stung by them. They are
also used to make souvenirs; just visit Sky Harbor Airport in
Phoenix, Arizona, and you'll see plenty of scorpions frozen in
plastic in the gift shops. The point here is that there are a
variety of human uses for scorpions. And where there's a demand,
there's a supply. This means that someone has to take on the job
of heading out into the desert and catching the rascals.
<P>
Catching a scorpion isn't as easy as you might think, though.
They are nocturnal creatures, so they only come out at night.
The thought of taking off into the desert at night might not appeal
to everyone, but conquering your fear of the dark desert isn't
the only hurdle when hunting for scorpions: It's hard to find
them at night! One of those brave souls that head into the darkness
in search of scorpions figured out a neat approach to finding
scorpions in the dark-using a black light. Black lights give off
a greenish glow that illuminates certain objects, including scorpions.
Therefore, to catch scorpions you simply head out into the darkness
with a black light and a net. That's the premise of the Scorpion
Roundup game. You're a scorpion hunter armed with a net, working
within a landscape illuminated by a black light that shows the
scorpions with their greenish glow.
<P>
<CENTER><TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR><TD><B>Warning</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
Real scorpions are caught by real professionals. For your own safety, I suggest only trying to catch the Java scorpions you meet in today's lesson!</BLOCKQUOTE>

</TD></TR>
</TABLE></CENTER>
<P>
<P>
Based on this description of the game, you might already see why
the mouse is the ideal input device for the game. This is because
you are controlling a net, which is a hand-held object in real
life. The best way to handle controlling a net with the mouse
is to make the net a sprite. You also need a scorpion sprite to
model the scorpions that you are trying to catch.
<P>
At this point, the game is defined enough to move into more specifics.
Let's start by taking a look at the sprites in more detail.
<H3><A NAME="Sprites"><B>Sprites</B></A></H3>
<P>
You've established that the game requires two types of sprites
for modeling the net and the scorpions. You also know that the
net sprite is to be controlled by the mouse. Basically, all you
need the net sprite to do is follow the mouse around, which requires
very basic sprite movement. Based on this requirement of the net
sprite, it doesn't sound like you need to use a derived class
for it; you don't need any functionality beyond that provided
in the base <TT>Sprite</TT> class.
This is a correct assumption because deriving a new class is usually
only necessary when you need to add new functionality.
<P>
This means that Scorpion Roundup really only needs one derived
sprite class: the <TT>Scorpion</TT>
sprite class. What should this sprite do? To make the game a little
more simple to implement, let's limit the scorpion sprites to
traveling in horizontal directions only. The scorpions can run
in either the left or right direction, which means that they can
also face in either the left or right direction. You're probably
thinking that the directional sprite you developed last week might
work well here. Unfortunately, it won't work in this case because
it was specifically designed for sprites having exactly eight
directions; the scorpions in Scorpion Roundup only have two directions
(left and right).
<P>
The scorpion sprite needs to be frame animated so that the scorpions
look like they are moving their legs and running. You've also
established that the sprite needs two directions. Anything else?
Actually, there is one other thing. The goal of the game is to
catch as many scorpions as possible. However, you haven't established
how a game is lost; the game has no negative result when you don't
catch any scorpions. One solution is to have the scorpions get
away when they reach the other side of the screen, rather than
wrapping around. Furthermore, you could track how many scorpions
get away and end the game when a certain number of them escape.
The only place to determine when a scorpion has made it across
is within the <TT>Scorpion</TT> class.
Therefore, the <TT>Scorpion</TT> class
needs some method of determining when a scorpion has escaped and
modifying a value accordingly.
<H3><A NAME="GamePlay"><B>Game Play</B></A></H3>
<P>
Now that you understand how the sprites work in the game, let's
move on to the specifics of the game itself. You've established
that the goal of the game is to use a net to catch scorpions that
are running across the screen. You lose the game when you miss
a certain number of scorpions. You never really win; you just
try to catch as many scorpions as possible.
<P>
One thing you haven't covered is how the player is to be challenged
as the game goes on. Few games remain fun without increasing the
challenge as the play progresses, and Scorpion Roundup is no different.
The easiest way to make the game harder is to speed up the scorpions
themselves. You could also increase the speed at which the scorpions
are created; more scorpions on the screen at a time mean more
work for the player.
<P>
How do you establish when to increase the difficulty of the game?
Well, you could just do it behind the scenes based on time or
on how many scorpions have been caught. I like the latter approach
because it directly increases the difficulty based on the performance
of the player. The only catch is that most game players like to
know when they have progressed to another difficulty level. This
is easy enough to accommodate; just display the current level
along with the number of scorpions caught and lost. You then increment
the difficulty level when a certain number of scorpions have been
caught.
<H3><A NAME="Options"><B>Options</B></A></H3>
<P>
That wraps up the play aspects of the game, but you should consider
a few other small issues related to how the player controls the
game. The first one is how to start a new game. You might recall
that the Traveling Gecko game you developed a few days ago used
a New Game button to start new games. That approach was fine in
Traveling Gecko because the button was drawn on top of one of
the rocks. In Scorpion Roundup, the game appearance would suffer
more by having a button drawn on top of everything. The easy way
around starting a new game without using a button is to simply
allow the player to start a game with a certain key press, such
as the N key.
<P>
<CENTER><TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR><TD><B>Note</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
You actually could use buttons without covering up any of the game area by using an awt <TT>Canvas</TT> object as the game area, rather than the applet window. This is a good way to handle sharing the applet window between user interface controls and the 
game area, but it involves more complexity. I didn't want this added complexity to make the game implementation more difficult to understand.
</BLOCKQUOTE>

</TD></TR>
</TABLE></CENTER>
<P>
<P>
The only other issue in Scorpion Roundup that needs to be addressed
is music. Because the game uses looped music, it would be nice
for the player to be able to easily turn it on and off. Using
the keyboard approach again, the M key makes perfect sense as
a music toggle key.
<P>
That wraps up the design phase for Scorpion Roundup. Hopefully,
you're now anxious to dive into the details of implementing all
these cool ideas to build a real game!
<H2><A NAME="SampleAppletScorpionRoundup"><B><FONT SIZE=5 COLOR=#FF0000>Sample
Applet: Scorpion Roundup</FONT></B></A></H2>
<P>
The Scorpion Roundup applet is your second fully functional Java
game and shows off the sound skills you developed in yesterday's
lesson. Figure 13.1 shows a screen shot of a fast and furious
game of Scorpion Roundup. The complete source code, executable,
images, and sounds for Scorpion Roundup are located on the accompanying
CD-ROM.
<P>
<A HREF="f13-1.gif" ><B>Figure 13.1 :</B> <I>The Scopion Roundup sample applet in action.</I></A>
<P>
Scorpion Roundup begins by creating the net sprite, which you
can move around the play area with the mouse. Scorpions then begin
to run across the screen. If you click on a scorpion with the
net, you hear a sound indicating that you got him. If you miss,
you hear a sound of the net swishing through the air. All the
while, the music is playing in the background.
<P>
The current difficulty level is displayed in the upper left corner
of the screen, along with the number of scorpions caught and lost.
The level is incremented and a cheering sound is played each time
you catch 15 new scorpions. The scorpions start running faster
and appearing quicker with each increasing difficulty level.
<P>
If you let five scorpions get away, the game ends and you see
a <TT>Game Over</TT> message. Figure
13.2 shows Scorpion Roundup right after the game ends.
<P>
<A HREF="f13-2.gif" ><B>Figure 13.2 : </B><I>A Scorpion Roundup game that has come to an end.</I></A>
<P>
At this point, you can simply press the N key to start a new game.
If you haven't run Scorpion Roundup yet, please load the CD-ROM
and try it out. If you're not the type that responds well to the
word &quot;please,&quot; then by all means skip playing the game
and read on!
<H3><A NAME="TheSpriteClasses"><B>The Sprite Classes</B></A></H3>
<P>
The only derived <TT>Sprite</TT> class
used in Scorpion Roundup is the <TT>Scorpion</TT>
class, which models a horizontally running scorpion. Listing 13.1
shows the source code for the <TT>Scorpion</TT>
class.
<HR>
<BLOCKQUOTE>
<B>Listing 13.1. The </B><TT><B><FONT FACE="Courier">Scorpion</FONT></B></TT><B>
class.<BR>
</B>
</BLOCKQUOTE>
<BLOCKQUOTE>
<TT>public class Scorpion extends Sprite
{<BR>
&nbsp;&nbsp;public static Image[][] image;<BR>
&nbsp;&nbsp;private static Random&nbsp;&nbsp; rand = new Random(System.currentTimeMillis());
<BR>
<BR>
&nbsp;&nbsp;public Scorpion(Component comp, int dir, int speedInc)
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;super(comp, image[dir], 0, 1, 1, new Point((dir
== 0) ?<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(comp.size().width - image[dir][0].getWidth(comp))
: 0,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;60 + Math.abs(rand.nextInt()
% 5) * 44), new Point((dir == 0)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;? (-5 - speedInc) : (5 + speedInc),
0), 10,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sprite.BA_DIE);<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][2];<BR>
&nbsp;&nbsp;&nbsp;&nbsp;for (int i = 0; i &lt; 2; i++)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (int j = 0; j &lt; 2;
j++) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;image[i][j] =
app.getImage(app.getCodeBase(),<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;Res/Scorp&quot;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人看片黄a免费看在线| 国产精品视频线看| 午夜国产精品影院在线观看| 在线免费精品视频| 一区二区三区.www| 精品视频1区2区| 免费成人在线视频观看| 日韩欧美一区二区三区在线| 国产一区二区三区免费看| 久久美女艺术照精彩视频福利播放| 国产不卡免费视频| 最新欧美精品一区二区三区| 色婷婷av一区| 秋霞国产午夜精品免费视频| 久久精品欧美一区二区三区麻豆| 成人国产一区二区三区精品| 亚洲男人的天堂av| 日韩一区二区三区四区| 国产精品一区二区无线| 国产精品久久久久久久久搜平片| 91农村精品一区二区在线| 亚洲一二三级电影| 久久免费视频一区| 一本色道久久综合亚洲91| 日韩精品久久久久久| 欧美高清在线一区二区| 欧美日韩一区二区在线观看视频| 另类小说视频一区二区| 26uuu久久综合| 日本高清不卡在线观看| 精品一区二区三区的国产在线播放| 国产精品久久久久国产精品日日| 欧美日本在线看| 成人av网址在线| 日本少妇一区二区| 亚洲特级片在线| 精品国产免费久久| 日本韩国视频一区二区| 国产精品正在播放| 日本不卡视频在线| 亚洲欧美另类久久久精品2019| 欧美大片国产精品| 在线区一区二视频| 成人网在线免费视频| 男人的天堂亚洲一区| 亚洲精品五月天| 国产调教视频一区| 日韩欧美黄色影院| 欧美日韩一卡二卡三卡| 不卡一区在线观看| 激情五月婷婷综合| 日韩电影在线观看网站| 亚洲精品国产视频| 国产精品久久三区| 久久久久久久久伊人| 欧美精品vⅰdeose4hd| 在线视频中文字幕一区二区| 风间由美一区二区三区在线观看| 国产精品自在欧美一区| 蜜桃视频在线观看一区| 亚洲国产精品一区二区www在线| 国产精品久久国产精麻豆99网站| 久久先锋资源网| 日韩欧美一级片| 日韩欧美成人一区二区| 欧美精品丝袜久久久中文字幕| 色婷婷亚洲一区二区三区| av亚洲精华国产精华精华| 国产一区二区三区电影在线观看 | 久久色在线观看| 91精品国产综合久久福利| 欧美日韩视频在线第一区| 色吧成人激情小说| 色老汉一区二区三区| 色综合天天综合网天天狠天天 | 欧美私模裸体表演在线观看| www.av亚洲| 色又黄又爽网站www久久| 91香蕉视频在线| 日本精品一区二区三区高清 | 老司机免费视频一区二区| 亚洲123区在线观看| 五月婷婷激情综合网| 五月天激情综合网| 日韩激情视频在线观看| 青青草国产成人99久久| 精品一区二区综合| 国产在线不卡一区| 国产成a人亚洲精品| 成年人国产精品| 欧美色倩网站大全免费| 欧美精品在线一区二区| 精品久久久久久久一区二区蜜臀| www久久久久| 国产精品女人毛片| 亚洲摸摸操操av| 天天操天天干天天综合网| 日本特黄久久久高潮| 韩国精品在线观看| 大胆欧美人体老妇| 欧美系列在线观看| 欧美一区二区日韩| 中文字幕成人网| 亚洲一二三区不卡| 国产一区在线精品| 一本色道a无线码一区v| 欧美精品丝袜久久久中文字幕| 欧美精品一区二区久久久 | 亚洲免费高清视频在线| 亚洲高清不卡在线| 精品一区二区三区在线视频| 粉嫩aⅴ一区二区三区四区五区 | 色综合网站在线| 欧美mv和日韩mv的网站| 中文字幕第一区二区| 日韩综合一区二区| 欧美性大战久久| 国产日韩欧美在线一区| 一区在线播放视频| 久久精品国产精品青草| av不卡在线播放| 精品久久久久久久人人人人传媒 | 欧美精品久久一区二区三区| 久久久99精品免费观看不卡| 亚洲精品免费电影| 精品在线播放午夜| 在线观看视频一区二区欧美日韩| 欧美精品一区二区三区蜜桃视频| 亚洲综合色婷婷| 国产不卡视频在线播放| 欧美一区二区人人喊爽| 亚洲欧美区自拍先锋| 国产精品资源站在线| 欧美肥妇毛茸茸| 亚洲欧美视频在线观看视频| 精品一区二区三区欧美| 欧美日韩美少妇| 亚洲三级小视频| 国产精品一二三区在线| 日韩一区二区三区在线| 亚洲一二三四在线| 成人av在线播放网址| 日韩三级高清在线| 午夜精品福利一区二区蜜股av | 精品国产乱码久久久久久老虎| 亚洲一区二区三区四区不卡| 成人av综合在线| 久久久精品2019中文字幕之3| 日韩精品欧美精品| 欧美视频在线不卡| 又紧又大又爽精品一区二区| 成人激情小说网站| 国产亚洲精品久| 国产精品白丝jk黑袜喷水| 欧美一级二级三级乱码| 亚洲电影在线播放| 欧美色图免费看| 亚洲综合色视频| 欧美色精品天天在线观看视频| 亚洲影院免费观看| 91久久免费观看| 一区二区三区高清| 日本韩国欧美一区| 一区二区三区成人| 欧美日韩国产大片| 亚洲国产成人精品视频| 色就色 综合激情| 亚洲一区二区3| 正在播放亚洲一区| 日本少妇一区二区| 日韩一区二区三区观看| 免费成人美女在线观看| 日韩午夜av电影| 国产在线精品免费| 欧美韩国日本一区| av高清不卡在线| 一区二区三区不卡视频在线观看| 在线观看国产91| 日韩精品免费视频人成| 日韩三级免费观看| 国产精品一级片在线观看| 久久精品免费在线观看| 白白色 亚洲乱淫| 一区二区免费看| 日韩三级精品电影久久久| 精品一区二区三区欧美| 精品国精品国产| 成人午夜精品一区二区三区| 亚洲美女淫视频| 日韩一级高清毛片| 国产在线精品一区二区不卡了| 国产精品女主播在线观看| 色婷婷精品久久二区二区蜜臀av| 亚洲成人精品在线观看| 日韩一卡二卡三卡| 国产不卡在线播放| 亚洲第一福利一区| 久久久久亚洲蜜桃| 在线观看亚洲一区| 国内精品免费**视频|