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

📄 615-616.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:Daleks!</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=14//-->
<!--PAGES=615-616//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="611-615.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch15/617-623.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading22"></A><FONT COLOR="#000077">Allowing Customization</FONT></H4>
<P>There are currently 10 parameters that can be specified from HTML to adjust some aspect of the game. The getHTMLParameters() method (shown in Listing 14-19) checks for each of these parameters and adjusts game variables as necessary.
</P>
<P><B>Listing 14-19</B> The daleks14.getHTMLParameters() method</P>
<!-- CODE //-->
<PRE>
public void getHTMLParameters()  &#123;
       //  read the parameters within the HTML applet tags
       if (getParameter("maxX") != null)
              maxX = Integer.parseInt(getParameter("maxX"));
       if (getParameter("maxY") != null)
              maxY = Integer.parseInt(getParameter("maxY"));
       if (getParameter("imgH") != null)
              imgH = Integer.parseInt(getParameter("imgH"));
       if (getParameter("imgW") != null)
              imgW = Integer.parseInt(getParameter("imgW"));
       if (getParameter("levelMultiple") != null)
              levelMultiple = &#8656;
Integer.parseInt(getParameter("levelMultiple"));
       if (getParameter("baseNum") != null)
              baseNumDaleks =  Integer.parseInt(getParameter("baseNum"));
       if (getParameter("maxEnemies") != null)
              maxEnemies = Integer.parseInt(getParameter("maxEnemies"));
       if (getParameter("numWidgets") != null)
              numWidgets = Integer.parseInt(getParameter("numWidgets"));
       if (getParameter("flyingWidget") != null)
              flyingWidget = getParameter("flyingWidget");
       else
              flyingWidget = "?";
       if (getParameter("title") != null)
              title = getParameter("title");
       else
              title = "Daleks!";
       &#125;
</PRE>
<!-- END CODE //-->
<P>Because we cannot assume that any &lt;param&gt; tags are actually contained in the HTML document, we have to first test for their existence. This is done using <I>if</I> statements. The value of the Strings will be <I>null</I> if the parameter is not included. There are two kinds of values that are contained in the &lt;param&gt; tags, although they all are read in as String objects. The Integer.parseInt(String) method is used to convert Strings to integers where necessary.</P>
<H3><A NAME="Heading23"></A><FONT COLOR="#000077">Suggestion Box</FONT></H3>
<DL>
<DD><B>&#149;</B>&nbsp;&nbsp;Base animation speed on actual timing rather than a <I>for</I> loop (which allows animations to vary according to processor speed)
<DD><B>&#149;</B>&nbsp;&nbsp;Rewrite the applet in a more object-oriented way to represent the game objects more logically, enhance reusability of the code, and allow for future customization
<DD><B>&#149;</B>&nbsp;&nbsp;Add graphics for the actors who played the role of Dr. Who but are left out of the game in ego-crushing obscurity
<DD><B>&#149;</B>&nbsp;&nbsp;Include additional enemies from the Dr. Who TV show and imbue them with  styles of attack even more clever than that of the Daleks
<DD><B>&#149;</B>&nbsp;&nbsp;Give the player additional options&#151;like the ability to pick up objects that enhance the player&#146;s abilities for a limited period of  time
<DD><B>&#149;</B>&nbsp;&nbsp;Add &lt;<I>param</I>&gt; tags which would rename the Sonic Screwdrivers and change how many are added each level
<DD><B>&#149;</B>&nbsp;&nbsp;Make any fundamental changes optional so players can choose between playing the &#147;classic&#148; and &#147;enhanced&#148; versions of the game
</DL>
<H3><A NAME="Heading24"></A><FONT COLOR="#000077">Comments</FONT></H3>
<P>In this chapter we covered the essence of a Java board game with a number of additional features. The applet makes use of such fundamental Java concepts as multiple threads, double-buffered animation, and event-oriented processing. The end result is a fairly simple, but effective game which puts a minimal strain on bandwidth and processor speed. The ability to customize the appearance and game play of the applet can greatly extend its interest to players. New themes and challenges for Daleks! can be created with a minimum of development effort.
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="611-615.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch15/617-623.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>


</BODY>

⌨️ 快捷键说明

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