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

📄 the java game programming tutorial part i.htm

📁 不错的JAVA书
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0057)http://www.intergate.bc.ca/personal/iago/javatut/jtp1.htm -->
<HTML><HEAD><TITLE>The Java Game Programming Tutorial: Part I</TITLE>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
<META content="Garry Morse" name=Author>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR>
<META content="An expanding tutorial on Java 2D/3D game programming" 
name=Description>
<META 
content=Java,Java,Java,Java,Java,Java,Java,Java,Java,Java,Java,Java,Java,Java,Java,Java,Java 
name=KeyWords></HEAD>
<BODY aLink=#ff0000 bgColor=#d0d5ff link=#0000ee text=#000000 vLink=#551a8b>
<H1><A href="http://www.intergate.bc.ca/personal/iago/javatut/index.htm"><IMG 
align=ABSCENTER border=0 height=85 
src="The Java Game Programming Tutorial Part I_ficheiros/coffee.gif" 
width=116></A><FONT color=#804040><FONT size=+2><A 
href="http://www.intergate.bc.ca/personal/iago/javatut/index.htm">The Java Game 
Programming Tutorial</A></FONT></FONT></H1>
<H1>
<HR width="100%">
</H1>
<H2>Part I:&nbsp;What about Applets?</H2>
<UL>
  <P>Applets are compiled Java programs which are run through the<BR>Applet 
  Viewer or through any world wide web browser which<BR>supports Java. Applets 
  are considered quite "safe" because of<BR>their limited file and network 
  access, and are nevertheless impressive. </P>
  <P>Each applet contains five functions to be called during its existence:</P>
  <UL>
    <LI><B>init</B> - called when applet is first loaded to initialize values 
    such as sounds. 
    <LI><B>start</B> - called after init is finished to perform task such as 
    playing a sound. 
    <LI><B>stop</B> - called when user leaves web page to stop actions in 
    progress from start. 
    <LI><B>destroy</B> - called when browser is quit to release system resources 
    used by applet. 
    <LI><B>paint</B> - called whenever the screen is redrawn. </LI></UL>
  <P>These will often be rewritten but an applet still has a default function 
  for each.</P>
  <P>The Java programmer writes the applet source code in files with<BR>the 
  .java extension. The resulting compiled files have the same<BR>name with the 
  .class extension. </P>
  <P>eg.) Hello.java will be compiled into Hello.class </P>
  <P>Here is the Java code for a tiny applet which draws a message: </P>
  <UL><PRE><B><TT>// Hello.java
// by Garry Morse

import java.awt.*;
import java.applet.*;

public class Hello extends Applet {

  public void paint(Graphics g) {
    g.drawString("Hello there!",10,10);
  }

}</TT></B></PRE></UL>
  <P>The import statements are common to all applets which inherit 
  the<BR>functionality of Java classes. Here, our class Hello is declared <BR>as 
  a subclass of the Applet class. For C/C++ programmers, this is<BR>rather like 
  the #include statement for header files. </P>
  <P>Since users of the world wide web are viewing pages coded in<BR>HTML, it 
  seems logical that Java applets are embedded in these<BR>pages through the use 
  of the &lt;APPLET&gt; tag.</P>
  <P>Here is the HTML for a blank web page containing a Java applet: </P>
  <UL><PRE><B>&lt;HTML&gt;
&lt;APPLET CODE="Hello.class" WIDTH=200 HEIGHT=50&gt;
&lt;/APPLET&gt;
&lt;/HTML&gt;</B></PRE></UL>
  <P>There are required tags which follow the applet tag:</P>
  <UL>
    <P><B>CODE</B> - filename of executable code with class extension. 
    (required)<BR><B>WIDTH</B> - width of the window to open for the applet. 
    (required)<BR><B>HEIGHT</B> - height of the window to open for the applet. 
    (required) </P></UL>
  <P>These are other tags which will appear in later examples: </P>
  <UL>
    <P><B>ALT</B> - alternate image or text for web browsers which are not 
    Java-capable.<BR><B>ALIGN</B> - position applet on web page, left, right, or 
    center.<BR><B>CODEBASE</B> - location of Java code if in different directory 
    than HTML page.<BR><B>HSPACE</B> - amount of horizontal space around an 
    aligned applet.<BR><B>NAME</B> - symbolic name for applets on same page to 
    refer to one another by.<BR><B>PARAM</B> - repeated for applets designed to 
    take parameters such as filenames.<BR><B>VSPACE</B> - amount of vertical 
    space around an aligned applet. </P></UL></UL>
<P><FONT size=+1><A 
href="http://www.intergate.bc.ca/personal/iago/javatut/hello.htm">Click here to 
see the Hello applet in action!</A></FONT></P>
<P><FONT color=#b3b3ff><FONT size=-2>The Java Game Programming Tutorial and all 
tutorials within are created by Garry Morse, Copyright 
1997</FONT></FONT></P></BODY></HTML>

⌨️ 快捷键说明

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