📄 825-826.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:The Game of Worm</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, Macmillan Computer Publishing
<br>
<b>ISBN:</b> 1571690433<b> Pub Date:</b> 11/01/96</font>
</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=20//-->
<!--PAGES=825-826//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="822-825.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ewtoc.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading48"></A><FONT COLOR="#000077">Network Play</FONT></H4>
<P>Many games provide network play, be it over a modem connection, a local area network, or the Internet. Worm could be adapted to provide TCP/IP socket connections between two or more players, with the playing surface populated by more than one worm. To prevent network latency effects from breaking the timing of two worms chasing the same treat, only the local worm’s treat should be visible to the user; alternatively, multiple treats could be placed on the playing surface.
</P>
<P>The simplest way of providing network play is by having a central server manage multiple network game requests and assign a player to a given game surface. This capability should be dynamic in that new playing surfaces should be created as more players join the game, limiting the maximum number of players per playing surface. An applet could be designed that shows the current games in progress and allows the player to join any game. Player names should be assigned to their worms so players can challenge each other directly. “Wormholes” could be created that would allow the player to move from one playing surface to another.</P>
<H3><A NAME="Heading49"></A><FONT COLOR="#000077">Suggestion Box</FONT></H3>
<P>If you’d like to enhance the game of Worm, here are some suggested improvements:
</P>
<DL>
<DD><B>•</B> Add mines or other objects to avoid.
<DD><B>•</B> Add levels with different-sized playing surfaces or nonrectangular playing surfaces.
<DD><B>•</B> Create “warp holes” that open and close and send you to other levels if you hit them at just the right time.
<DD><B>•</B> Show a replay of the last 10 seconds before collision.
<DD><B>•</B> Add two-player capability (control one from the mouse and the other from the keyboard).
<DD><B>•</B> Modify the worm size to one pixel for a “stringy worm,” and allow motion in eight, not just four, directions.
<DD><B>•</B> Add score-saving capability.
<DD><B>•</B> Add network play capability.
</DL>
<H3><A NAME="Heading50"></A><FONT COLOR="#000077">Summary</FONT></H3>
<P>As you have seen, Worm becomes a fairly sophisticated programming exercise once additional worms are introduced; however, this complexity appears mainly in the avoidance and shrink/grow handlers, not in the Worm object itself. Rewriting the code to accept two-player operation would not be very difficult for this reason. Rewriting the code for network play would be relatively easy except for unrelated problems introduced by network latency.
</P>
<P>Some object-oriented methods were not used, such as inheritance, but the Worm class could be modified slightly to make it easier to build into a library for future derived worm objects. The worm design could be improved by hiding more of the interfaces: Currently the SessionManager requires that much of the worm’s attributes be exposed and under its direct control, which reduces the usefulness of the class for general purpose applications.</P>
<P>Perhaps the best part about Worm is its deceivingly simple interface and game play. Only when the player sees for the first time an autonomous worm coiling into near-oblivion does the underlying complexity of the game surface. Keeping the focus on simplicity and clean design allows you to gradually extend your game’s capabilities without losing control of the programming interfaces.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="822-825.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ewtoc.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -