⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 588-590.html

📁 java game programming e-book
💻 HTML
字号:
<HTML>
<HEAD>
<META name=vsisbn content="1571690433"><META name=vstitle content="Black Art of Java Game Programming"><META name=vsauthor content="Joel Fan"><META name=vsimprint content="Sams"><META name=vspublisher content="Macmillan Computer Publishing"><META name=vspubdate content="11/01/96"><META name=vscategory content="Web and Software Development: Programming, Scripting, and Markup Languages: Java"><TITLE>Black Art of Java Game Programming:Building the JAVAroids Game</TITLE>
<!-- HEADER --><STYLE type="text/css">  <!-- A:hover  { 	color : Red; } --></STYLE><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><script><!--function displayWindow(url, width, height) {         var Win = window.open(url,"displayWindow",'width=' + width +',height=' + height + ',resizable=1,scrollbars=yes');	if (Win) {		Win.focus();	}}//--></script><SCRIPT><!--function popUp(url) {        var Win = window.open(url,"displayWindow",'width=400,height=300,resizable=1,scrollbars=yes');	if (Win) {		Win.focus();	}}//--></SCRIPT><script language="JavaScript1.2"><!--function checkForQuery(fm) {  /* get the query value */  var i = escape(fm.query.value);  if (i == "") {      alert('Please enter a search word or phrase');      return false;  }                  /* query is blank, dont run the .jsp file */  else return true;  /* execute the .jsp file */}//--></script></HEAD><BODY> 
<TABLE border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=75 valign=top>
<img src="../1571690433.gif" width=60 height=73 alt="Black Art of Java Game Programming" border="1">
</td>
<td align="left">
    <font face="arial, helvetica" size="-1" color="#336633"><b>Black Art of Java Game Programming</b></font>
    <br>
    <font face="arial, helvetica" size="-1"><i>by Joel Fan</i>
    <br>
    Sams,&nbsp;Macmillan Computer Publishing
    <br>
    <b>ISBN:</b>&nbsp;1571690433<b>&nbsp;&nbsp;&nbsp;Pub Date:</b>&nbsp;11/01/96</font>&nbsp;&nbsp;
</td>
</tr>
</table>
<P>

<!--ISBN=1571690433//-->
<!--TITLE=Black Art of Java Game Programming//-->
<!--AUTHOR=Joel Fan//-->
<!--AUTHOR=Eric Ries//-->
<!--AUTHOR=Calin Tenitchi//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=13//-->
<!--PAGES=588-590//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="578-588.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch14/591-596.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading28"></A><FONT COLOR="#000077">Suggestion Box</FONT></H3>
<P>This game&#146;s only a starting point. Here are a few ideas for further extensions and improvements to the game:
</P>
<DL>
<DD><B>&#149;</B>&nbsp;&nbsp;Make the enemy ships more intelligent. For example, they could follow the player&#146;s ship, or exhibit different behaviors. You can use a state machine to implement multiple behaviors, as you&#146;ve seen in Chapter 5, Building a Video Game.
<DD><B>&#149;</B>&nbsp;&nbsp;Change the way the game objects move. One change you can implement almost immediately is to bounce the sprites off the edges of the screen, instead of wrapping them around to the other side. Just modify the updatePosition() method of MoveablePolygon, and you can alter the dynamic of the game dramatically!
<DD><B>&#149;</B>&nbsp;&nbsp;Another way of handling explosions and sound effects is by incorporating this functionality in the Sprite subclasses themselves. Thus, the sprites would be responsible for the sounds that occur when they collide, and the way that they explode. In this scenario, the effect manager might tell the individual sprites when to make sounds or explode, but the actual sound or explosion is the responsibility of the sprite itself. Think about the benefits of encapsulating explosion and sound effects in the Sprite subclasses, and implement it.
<DD><B>&#149;</B>&nbsp;&nbsp;Optimize the game. Here are some ways of doing this. First, precompute the coordinates of the rotated polygons, and store them in a lookup table. This way, you can avoid the floating-point multiplications while the game is playing. Secondly, use final methods whenever possible (such as accessor methods) to eliminate the overhead from dynamic method binding. A third optimization is to flatten the inheritance hierarchy, and reduce unnecessary method calls by inlining functions as much as possible.
<DD><B>&#149;</B>&nbsp;&nbsp;Allow multiple players to compete, either in alternation or at the same time. (You&#146;ll need a big keyboard!)
</DL>
<H3><A NAME="Heading29"></A><FONT COLOR="#000077">Summary</FONT></H3>
<P>You&#146;ve constructed a fairly intricate video game in this chapter. However, you&#146;ve built the game, and managed its complexity, by making use of inheritance- and responsibility-driven design. These are concepts you can take with you in designing any object-oriented application, whether it&#146;s a game or not!
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="578-588.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch14/591-596.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>


</BODY>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -