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

📄 349-352.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:Advanced Networking and Multiplayer Gaming Concepts</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=9//-->
<!--PAGES=349-352//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="347-349.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch10/353-358.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading56"></A><FONT COLOR="#000077">Suggestion Box</FONT></H3>
<P>Here are some ideas for extending what you have learned in this chapter. Some are minor additions to the ChatClient, while others explore how you could extend these concepts to other projects.
</P>
<DL>
<DD><B>&#149;</B>&nbsp;&nbsp;Use applet parameters (in the HTML APPLET tag) to embed the host and port the client should use in an HTML page. This first one is in the source code included with this book.
<DD><B>&#149;</B>&nbsp;&nbsp;Allow the server to use a user-defined port, instead of just 1123. (You&#146;ll need to use the <I>args[]</I> array.)
<DD><B>&#149;</B>&nbsp;&nbsp;Extend the ChatClient GUI to include some more components. How about labels that provide help and information for the user, like his or her current alias? You could create a Choice Component to allow the user to choose what color the TextArea should be. You could create another TextArea for displaying information about anything you want. Some suggestions: user information, advertising, information about the network connection or about the current version of the software.
<DD><B>&#149;</B>&nbsp;&nbsp;Modify the current applet and server to handle multiple selections in the List. This means that the user would be able to &#147;whisper&#148; to multiple people at one time. This will require some modifications to the protocol we use to send <I>whisper</I> messages, but, since we already use a flexible protocol for message sending, this is not too hard.
<DD><B>&#149;</B>&nbsp;&nbsp;Modify the server to collect and track information about each user logged on, like e-mail addresses, real names, and location. Then, program the client to display this information whenever a user double-clicks on another user in the List. (Remember that java.awt.List generates an ACTION_EVENT whenever an item is double-clicked. You can then check which item is currently selected to find out which one it was.)
<DD><B>&#149;</B>&nbsp;&nbsp;Use the protocols and code that we have established here to create a &#147;never-ending story&#148; applet. Each user logged on is invited to add a line to a continuing story, which is prompted by the server. Users may log on and review the current story and then contribute their own sentences to it.
<DD><B>&#149;</B>&nbsp;&nbsp;When a user logs into the chat room, he or she should see a summary of what has been said prior to their entry (perhaps the last 10 things said). This list should be kept by the server. Every time something is said, it should be added to a queue that is displayed for new logins.
<DD><B>&#149;</B>&nbsp;&nbsp;Have the client display different types of messages differently. There are a number of ways this could be handled. One would be to have <I>say</I> messages in normal font and <I>whisper</I> messages in bold. Or perhaps different colors.
<DD><B>&#149;</B>&nbsp;&nbsp;One last idea that works well with the previous suggestion is to extend the number of types of messages. Perhaps add <I>shouts</I> or other emotional messages. One feature of many similar programs is an <I>emote</I> command that allows the user to do things rather than say them (i.e., Eric jumps up and down).
</DL>
<H3><A NAME="Heading57"></A><FONT COLOR="#000077">Summary</FONT></H3>
<P>In this chapter, we explored a more advanced networking program than the one we created in Chapter 8, Implementing a High Score Server on a Network. The principles and skills required to implement the Java chat room are the same fundamental concepts you must understand to do any kind of multiplayer gaming on the Internet. Although a chat room is not technically a game (although it certainly is fun), the concepts used in creating it can easily be applied to nearly any online game. From this foundation, you open the door to creating a whole new kind of gaming experience for your user.
</P>
<P>In addition to networking concepts, we explored some facets of the Java AWT more fully than we did in previous chapters. Once you understand how to implement the basic AWT Components, you can implement them all by simply reading the Java API specifications to learn what specific methods each Component uses. Perhaps most importantly, we explored the use of Events to control the flow of an applet, which is terribly important for game developers to understand properly.</P>
<P>From here, you can do anything. Once you have firmly mastered the AWT and Sockets, your games can progress from clunky to sophisticated and, most importantly, from local to global!</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="347-349.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch10/353-358.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>


</BODY>

⌨️ 快捷键说明

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