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

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

?? ch13.htm

?? 有關(guān)于游戲開發(fā)的教程我閱讀后感覺不錯(cuò)所以就拿出來與大家共享。
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
+ i + j + &quot;.gif&quot;);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tracker.addImage(image[i][j],
id);<BR>
&nbsp;&nbsp;&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>
<BR>
&nbsp;&nbsp;public BitSet update() {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;// See if the scorpion escaped<BR>
&nbsp;&nbsp;&nbsp;&nbsp;BitSet action = super.update();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;if (action.get(Sprite.SA_KILL))<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScorpionRoundup.lost++;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return action;<BR>
&nbsp;&nbsp;}<BR>
}</TT>
</BLOCKQUOTE>
<HR>
<P>
The <TT>Scorpion</TT> class uses a
two-dimensional array of images to show the animations of the
scorpion kicking its legs and wagging its tail in each direction.
Figure 13.3 shows the images used by the <TT>Scorpion</TT>
class.
<P>
<A HREF="f13-3.gif" ><B>Figure 13.3 : </B><I>The images used by the Scorpion class.</I></A>
<P>
The constructor for <TT>Scorpion</TT>
takes parameters specifying the direction and speed increment
for the scorpion, <TT>dir</TT> and
<TT>speedInc</TT>. The <TT>dir</TT>
parameter determines in which direction the scorpion travels,
as well as which side of the screen it starts from, and the parameter
can be set to either <TT>0</TT> (left)
or <TT>1</TT> (right). The <TT>speedInc</TT>
parameter specifies how much to increase the scorpion's speed
beyond its default speed. This parameter is how new scorpions
become faster as the difficulty level of the game increases.
<P>
The <TT>update</TT> method in <TT>Scorpion</TT>
is overridden to track when the scorpion makes it across the screen.
This works rather indirectly, so bear with me. Notice in the constructor
for <TT>Scorpion</TT> that the bounds
action is set to <TT>BA_DIE</TT>.
If you recall, the bounds actions determine what a sprite does
when it reaches a boundary (the other side of the applet window,
in this case). The <TT>BA_DIE</TT>
bounds action causes the <TT>SA_KILL</TT>
flag to be returned by the default sprite <TT>update</TT>
method, eventually resulting in the sprite being removed from
the sprite list. By looking for this flag in <TT>Scorpion</TT>'s
overridden <TT>update</TT> method,
you can tell when the scorpion makes it across the screen unscathed.
Pretty tricky, huh?
<P>
If the scorpion has made it across safely, the <TT>ScorpionRoundup.lost</TT>
variable is incremented. This variable is a public static member
of the <TT>ScorpionRoundup</TT> applet
class that can be accessed by other classes, such as <TT>Scorpion</TT>.
You'll learn more about it later in this lesson when you get into
the <TT>ScorpionRoundup</TT> class.
<P>
Scorpion Roundup uses a derived version of the <TT>SpriteVector</TT>
class called <TT>SRVector</TT>. Listing
13.2 contains the source code for the <TT>SRVector</TT>
class.
<HR>
<BLOCKQUOTE>
<B>Listing 13.2. The </B><TT><B><FONT FACE="Courier">SRVector</FONT></B></TT><B>
class.<BR>
</B>
</BLOCKQUOTE>
<BLOCKQUOTE>
<TT>public class SRVector extends SpriteVector
{<BR>
&nbsp;&nbsp;public SRVector(Background back) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;super(back);<BR>
&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;Sprite isPointInside(Point pt) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;// Iterate backward through the sprites,
testing each<BR>
&nbsp;&nbsp;&nbsp;&nbsp;for (int i = (size() - 1); i &gt;= 0;
i--) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sprite s = (Sprite)elementAt(i);
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((s.getClass().getName().equals(&quot;Scorpion&quot;))
&amp;&amp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s.isPointInside(pt))
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return s;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return null;<BR>
&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;protected boolean collision(int i, int iHit) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;// Do nothing!<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return false;<BR>
&nbsp;&nbsp;}<BR>
}</TT>
</BLOCKQUOTE>
<HR>
<P>
The <TT>SRVector</TT> class overrides
two methods in <TT>SpriteVector</TT>:
<TT>isPointInside</TT> and <TT>collision</TT>.
The overridden <TT>isPointInside</TT>
method is necessary to distinguish between the user clicking a
scorpion sprite and clicking the net sprite. Without overriding
this method, you would never be able to detect when a scorpion
is clicked, because the net sprite would always be in the way.
This is a result of the fact that the net sprite follows the mouse
around and has a higher Z-order than the scorpions (so it can
always be seen). The simple solution is to look only for sprites
of type <TT>Scorpion</TT> in the <TT>isPointInside</TT>
method.
<P>
Because the scorpions don't need to be able to collide with each
other or the net sprite, it makes sense to do nothing when a collision
occurs. This is carried out by simply returning <TT>false</TT>
from the <TT>collision</TT> method.
<P>
You've now seen the sprite classes used by <TT>ScorpionRoundup</TT>.
It's time to check out the applet class.
<H3><A NAME="TheScorpionRoundupClass"><B>The </B><TT><B><FONT SIZE=4 FACE="Courier">ScorpionRoundup</FONT></B></TT><B><FONT SIZE=4>
Class</FONT></B></A></H3>
<P>
The <TT>ScorpionRoundup</TT> class
takes care of all the high-level animation and sound issues, as
well as handling user input. First take a look at the member variables
defined in the <TT>ScorpionRoundup</TT>
class:
<BLOCKQUOTE>
<TT>private Image&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;offImage,
back, netImage;<BR>
private AudioClip&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;music, netHit,
netMiss, applause;<BR>
private Graphics&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;offGrfx;<BR>
private Thread&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;animate;
<BR>
private MediaTracker&nbsp;&nbsp;tracker;<BR>
private SRVector&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;srv;<BR>
private Sprite&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;net;
<BR>
private int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delay
= 83; // 12 fps<BR>
private Font&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;infoFont
= new Font(&quot;Helvetica&quot;,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Font.PLAIN,
14);<BR>
private FontMetrics&nbsp;&nbsp;&nbsp;infoMetrics;<BR>
private Random&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rand
= new<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Random(System.currentTimeMillis());
<BR>
private boolean&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;musicOn
= true;<BR>
private static int&nbsp;&nbsp;&nbsp;&nbsp;level, caught;<BR>
public static int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lost;</TT>
</BLOCKQUOTE>
<P>
You might be curious about a few of these member variables. The
four <TT>AudioClip</TT> member variables
hold audio clips for the music and sound effects used in the game.
The <TT>musicOn</TT> member variable
is a boolean variable that determines whether the music is on
or off. The <TT>level</TT>, <TT>caught</TT>,
and <TT>lost</TT> member variables
are used to store the state of the game: <TT>level</TT>
is the current difficulty level, <TT>caught</TT>
is how many scorpions have been caught, and <TT>lost</TT>
is how many scorpions have escaped.
<P>
The <TT>init</TT> method in <TT>ScorpionRoundup</TT>
is pretty straightforward-it loads and initializes all the images
and sounds used by the game:
<BLOCKQUOTE>
<TT>public void init() {<BR>
&nbsp;&nbsp;// Load and track the images<BR>
&nbsp;&nbsp;tracker = new MediaTracker(this);<BR>
&nbsp;&nbsp;back = getImage(getCodeBase(), &quot;Res/Back.gif&quot;);
<BR>
&nbsp;&nbsp;tracker.addImage(back, 0);<BR>
&nbsp;&nbsp;netImage = getImage(getCodeBase(), &quot;Res/Net.gif&quot;);
<BR>
&nbsp;&nbsp;tracker.addImage(netImage, 0);<BR>
&nbsp;&nbsp;Scorpion.initResources(this, tracker, 0);<BR>
<BR>
&nbsp;&nbsp;// Load the audio clips<BR>
&nbsp;&nbsp;music = getAudioClip(getCodeBase(), &quot;Res/Music.au&quot;);
<BR>
&nbsp;&nbsp;netHit = getAudioClip(getCodeBase(), &quot;Res/NetHit.au&quot;);
<BR>
&nbsp;&nbsp;netMiss = getAudioClip(getCodeBase(), &quot;Res/NetMiss.au&quot;);
<BR>
&nbsp;&nbsp;applause = getAudioClip(getCodeBase(), &quot;Res/Applause.au&quot;);
<BR>
}</TT>
</BLOCKQUOTE>
<P>
The <TT>stop</TT> method has been
pretty standard in all the applets you've seen thus far. However,
in <TT>ScorpionRoundup</TT> it has
an extra line of code that stops looping the music audio clip:
<BLOCKQUOTE>
<TT>public void stop() {<BR>
&nbsp;&nbsp;if (animate != null) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;animate.stop();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;animate = null;<BR>
&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;music.stop();<BR>
}</TT>
</BLOCKQUOTE>
<P>
The extra line of code, <TT>music.stop()</TT>,
is important because it ensures that the music is stopped when
the thread is stopped. Without this simple method call, the music
would continue to play even after a user has left the Web page
containing the game.
<P>
<CENTER><TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR><TD><B>Warning</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
Be sure to always stop all looped sounds when the applet thread is stopped. You do this simply by calling the <TT>stop</TT> method on the <TT>AudioClip</TT> object from within the applet's <TT>stop</TT> method, as you just saw in <TT>ScorpionRoundup</TT>.
</BLOCKQUOTE>

</TD></TR>
</TABLE></CENTER>
<P>
<P>
The <TT>run</TT> method in <TT>ScorpionRoundup</TT>
calls the <TT>newGame</TT> method,
which you'll learn about in a moment. Listing 13.3 contains the
source code for the <TT>run</TT> method.
<HR>
<BLOCKQUOTE>
<B>Listing 13.3. The </B><TT><B><FONT FACE="Courier">ScorpionRoundup</FONT></B></TT><B>
class's </B><TT><B><FONT FACE="Courier">run</FONT></B></TT><B>
method.<BR>
</B>
</BLOCKQUOTE>
<BLOCKQUOTE>
<TT>public void run() {<BR>
&nbsp;&nbsp;try {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;tracker.waitForID(0);<BR>
&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;catch (InterruptedException e) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return;<BR>
&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;// Set up a new game<BR>
&nbsp;&nbsp;newGame();<BR>
<BR>
&nbsp;&nbsp;// Update everything<BR>
&nbsp;&nbsp;long t = System.currentTimeMillis();<BR>
&nbsp;&nbsp;while (Thread.currentThread() == animate) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;srv.update();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;repaint();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;try {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t += delay;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thread.sleep(Math.max(0, t
- System.currentTimeMillis()));<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;catch (InterruptedException e) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;}<BR>
}</TT>
</BLOCKQUOTE>
<HR>
<P>
After setting up a new game, the <TT>run</TT>
method enters the main update loop where it updates the sprite
list and forces a repaint. Speaking of updating, the <TT>update</TT>
method does a few new things in <TT>ScorpionRoundup</TT>;
check out Listing 13.4.
<HR>
<BLOCKQUOTE>
<B>Listing 13.4. The </B><TT><B><FONT FACE="Courier">ScorpionRoundup</FONT></B></TT><B>
class's </B><TT><B><FONT FACE="Courier">update</FONT></B></TT><B>
method.<BR>
</B>
</BLOCKQUOTE>
<BLOCKQUOTE>
<TT>public void update(Graphics g) {<BR>
&nbsp;&nbsp;// Create the offscreen graphics context<BR>
&nbsp;&nbsp;if (offGrfx == null) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;offImage = createImage(size().width, size().height);
<BR>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区免费| 色播五月激情综合网| 欧美丰满嫩嫩电影| 久草精品在线观看| 欧美日韩精品一区视频| 日本不卡免费在线视频| 久久激情五月激情| 精品视频一区三区九区| 日韩精品一区二区三区在线播放| 日韩一区在线免费观看| 精品一区二区三区久久久| 欧美妇女性影城| 久久99日本精品| 蜜桃久久精品一区二区| 欧美色网站导航| 日韩精品色哟哟| 欧美另类高清zo欧美| 91精品国产色综合久久不卡电影 | 99久久99久久综合| 综合av第一页| 狠狠色丁香婷婷综合| 538prom精品视频线放| 亚洲二区在线视频| 欧美日韩亚州综合| 99精品国产99久久久久久白柏| 亚洲天堂成人网| 欧美日韩一区二区在线观看视频| 国产精品一区二区在线看| 午夜激情久久久| 欧美美女视频在线观看| 亚洲男人的天堂在线观看| 国产福利一区在线| 成人午夜在线免费| 蜜桃精品视频在线| 成人高清视频在线观看| 久久精工是国产品牌吗| 懂色av中文一区二区三区| 欧美一区二视频| 日本欧美一区二区| 日本中文字幕一区二区有限公司| 国产欧美日韩另类视频免费观看| 国产精品午夜久久| 无码av免费一区二区三区试看 | 91丨porny丨国产| 欧美日韩在线三级| 国产亚洲欧洲一区高清在线观看| 久久久久久影视| 亚洲人一二三区| 国产一区二区久久| 欧美图区在线视频| 久久午夜国产精品| 天堂va蜜桃一区二区三区| 国产成人精品免费网站| 99免费精品视频| 日韩精品一区二区三区在线观看| 亚洲另类色综合网站| 激情文学综合插| 欧美日韩国产美| 久久久久99精品国产片| 美女视频免费一区| 色婷婷国产精品| 欧美国产综合色视频| 狠狠色丁香久久婷婷综| 69堂精品视频| 亚洲成av人片一区二区| 欧美少妇bbb| 日韩理论片一区二区| 大尺度一区二区| 国产欧美综合色| 婷婷一区二区三区| 99久久国产免费看| 18成人在线观看| 91网上在线视频| 悠悠色在线精品| 在线观看亚洲专区| 水蜜桃久久夜色精品一区的特点| 欧美亚男人的天堂| 亚洲少妇中出一区| 国产精品69久久久久水密桃| 在线看国产一区| 国产日产欧产精品推荐色| 亚洲妇熟xx妇色黄| 色综合久久88色综合天天| 欧美极品aⅴ影院| 国模无码大尺度一区二区三区| 欧美精品xxxxbbbb| 亚洲另类色综合网站| av网站免费线看精品| 亚洲国产成人在线| 国产高清亚洲一区| 欧美精品一区二区三区一线天视频 | 欧美性猛交xxxxxxxx| 中文字幕综合网| 成人激情综合网站| 成人国产精品免费观看| 久久久久久亚洲综合| 精品午夜久久福利影院| 欧美一级日韩免费不卡| 日韩极品在线观看| 3d动漫精品啪啪一区二区竹菊 | 国产99久久久国产精品免费看| 日韩欧美aaaaaa| 老司机精品视频在线| 日韩欧美三级在线| 精品制服美女久久| 日韩久久免费av| 久久成人综合网| 久久嫩草精品久久久精品一| 国产一区二区成人久久免费影院 | 欧美日本乱大交xxxxx| 亚洲第一会所有码转帖| 欧美手机在线视频| 日本欧美肥老太交大片| 日韩美女一区二区三区四区| 亚洲已满18点击进入久久| 亚洲午夜视频在线观看| 欧美日韩一区小说| 免费成人你懂的| 精品国产一区二区精华| 成人动漫精品一区二区| 亚洲人成网站影音先锋播放| 欧美中文字幕一区二区三区亚洲| 亚洲va天堂va国产va久| 欧美成人乱码一区二区三区| 国产激情偷乱视频一区二区三区| 国产欧美日韩一区二区三区在线观看| 成人午夜av在线| 亚洲综合一区二区精品导航| 日韩欧美国产一区二区在线播放| 国产精品婷婷午夜在线观看| 成人av综合一区| 国产精品久久久久一区二区三区共| 成人av网址在线| 日欧美一区二区| 久久亚洲捆绑美女| 一本色道久久综合亚洲精品按摩| 日本大胆欧美人术艺术动态| 国产欧美精品一区二区三区四区| 91色在线porny| 久久国产婷婷国产香蕉| 亚洲欧洲精品一区二区三区| 欧美一区二区三区婷婷月色| 成人免费高清视频在线观看| 天天色综合成人网| 337p粉嫩大胆噜噜噜噜噜91av| 成人小视频在线观看| 亚洲免费大片在线观看| 欧美亚洲综合色| 亚洲妇女屁股眼交7| 国产女主播在线一区二区| 欧美精品久久久久久久久老牛影院| 成人av在线网站| 爽好久久久欧美精品| 亚洲人一二三区| 久久久久久久久久久久久夜| 欧美日韩一区二区三区在线看| 国产精品一级黄| 天天爽夜夜爽夜夜爽精品视频| 日韩理论电影院| 国产欧美综合色| 久久综合色鬼综合色| 这里只有精品视频在线观看| 91蝌蚪porny成人天涯| 国产美女精品人人做人人爽| 亚洲精品成人a在线观看| 欧美亚洲国产bt| 韩国女主播一区二区三区| 精品国产免费一区二区三区四区| 国产美女视频91| 激情综合网天天干| 久久精品国产精品亚洲精品| 日韩黄色小视频| 亚洲午夜免费视频| 悠悠色在线精品| 亚洲蜜桃精久久久久久久| 国产精品乱人伦| 国产欧美一区二区精品婷婷| 精品国产乱码久久久久久浪潮| 91精品国产综合久久福利软件| 色婷婷激情久久| 欧美午夜精品久久久| 色综合欧美在线| 色欧美日韩亚洲| 91久久精品一区二区三区| 一本大道av一区二区在线播放| 午夜一区二区三区视频| 欧美一区二区三区白人| 精品在线观看视频| 免费成人在线视频观看| 丝袜脚交一区二区| 久久精品视频一区二区三区| 日韩一级大片在线观看| 蜜桃精品视频在线| 日韩av电影天堂| 图片区日韩欧美亚洲| 视频在线观看国产精品| 国产馆精品极品| 在线观看一区日韩| 91精品国产一区二区| 亚洲精品一区二区三区影院|