Java Game Programming For Dummies 1998, książki, informatyka, Seria For Dummies
[ Pobierz całość w formacie PDF ]
Next Wave °f java-Fueled
Internet Ga
ming
DUNRUES BOORS
IN
PRINT
A Reference for
The Fun and Easy Way'
to Create Your Own
Games and Put Them
on Your Web Page
Your First Aid Kif
for Adding Pizzazz
to Boring Web Sites
Creating Cool Games
in Java - Explained
in Plain English
by Wayne Holder
& Doug Bell
I
D
G
BOOK
WORLDNN"ID
Catch the
the Rest of Us!'
`ova
wtne Programming
For Dummies`
maxiwE
<APPLET> Tag Attributes
Attribute
Value
CODE
Required:
The name of the Java class file containing the compiled
Appl et
subclass to execute.
WIDTH,
Required:
The
suggested
pixel width and height of the area the browser
HEIGHT
should reserve for the applet in the Web page.
CODEBAS E
The uniform resource locator (URL) of the directory or folder that contains the
applet code.
If
CODEBAS E is
not specified, then the Web browser viewing the
document defaults to the location of the HTML document.
COD EBAS E
allows
the applet code to be place in a different location than the HTML.
NAME
The applet name that other applets on the Web page can use to find it and
communicate with it.
ALT
Text displayed by browsers that cannot run the applet.
The
ALT
text is
displayed, for instance, if the user has turned off the Java option in their
browser.
ALIGN
The alignment of the applet relative to the text line containing it. This attribute
works like the
ALI GN
attribute for the
I MG
tag.
The possible values are
top,
mi
ddI
e, bottom, 1 eft,
and
ri ght.
The alignment is
bottom
by default.
HSPAC E ,
The number of pixels of space the browser should leave around the applet
VSPACE
on the left and right
(
HSPAC E)
and top and bottom
( VSPACE).
Built-in Java Colors
Commonly Overridden Applet
Methods
Color
RGB values
Applet Method Override It To . . .
void init( Perform any one-time
initialization the applet
needs before it runs.
void start()
Begin animations,
processing, or threads.
void paint
Draw the applet to the
( Graphics g)
screen.
void
stop()
Suspend animations,
processing, or threads
Color.black
0,0,0
Col or.blue
0,0,255
Color.cyan
0,255,255
Color.darkGray
64,64,64
1 28, 128, 128
Color.green 0,255,0
Color.lightGray 192,192,192
Color.magenta
255,0,255
Color.orange
255,200,0
>
initiated in
start( ).
void
Clean up after the applet
destroy()
before it quits.
Col or. pi nk
255, 175, 175
Col or. red
255,0,0
Color.white
255, 255, 255
Color.yellow
255,255,0
Copyright © 1998 IDG Books Worldwide, Inc.
All rights reserved.
IDG
Cheat Sheet $2.95 value. Item 0168-2.
OOH
For more information about IDG Books,
call 1-800-762-2974.
...
For Dummies:
#
1 Computer Book Series for Beginners
WORLDWIDE
Col or. gray
Computer
BOOK
SERIES
FROM IDG
ava?M
Some ProgramM
4
For Dstmmiei
Drawing Outlined Shapes and Lines
drawRect(int x, int y,
i nt width, int height)
3-DRectangle draw3DRect(int x, int y,
i nt width, int height,
boolean raised)
Method and Parameters
fillRect(int ~, -
i nt width, i , - ~~ -
fi113DRect(int x, int
i nt width, int -eigih^I-
boolean raised)
Rounded
Rectangle
drawRoundRect(int x, int
y, int width, int
height, int arcWidth,
i nt arcHeight)
draw0val(int x, int y,
i nt width, int height)
drawArc(int x, int y, int
width, int height,
boolean raised, int
startAngle, int arcAngle)
drawPolygon(int[]
xPoints, int[] yPoints,
i nt nPoints)
or.,
fillRoundRect(ir-
x
y, int width, int
r=
int arcWidth,int
arcHeight)
fillOval(int x, 4, nt _. .
int width, int heigh
Arc
fil]Arc(int x, int y,
int width, int height,
boolean raised, int
startAngle, int arcAngle
fillPolygon(int[]
xPoints, int[] yPoints,
i
nt nPoints)
Tag
Example Usage
Description
<A
-;FF=http: //www.
The anchor tag creates a link to another document
or Web page, in this case the IDG Books Web site.
APPLET<APPLET CODE=MyAppl etInsert a Java applet, in this case an applet with the
WIDTH=80 HEIGHT=50></APPLET>filenameMyApplet.
<IMG SRC="image.gif">
I nsert aGIForJPEGimage. IMGdoesn't require anendtag.
<P>This is anew paragraph< / P>
Starts anew paragraph. An end tag </P> is not
required, but is good practice.
==',T
<FONT
SIZE=5
COLOR=RED>Set the font
size and/or color of the contained text.
Big Red Text< / FONT>
<TT>Monospaced text< /TT>
The teletype tag displays the contained text using
monospaced text.
< I >Italic text< / I >
Italicize the contained text.
< B>Bold text< / B>
Display the contained text with a bold face font.
<U>Underlinedtext</U>
Underline the contained text.
. .
For Dummies:
#
1 Computer Book Series for Beginners
Shape Outline Method and Parameters
Rectangle
id .c~^
>IDGBooks</A>
Table of Contents
lntroduetion .................................................................
1
About This Book .................................................................................................. 1
Who You Are......................................................................................................... 1
About the Java Code in This Book.................................................................... 2
How This Book Is Organized .............................................................................. 2
Part 1: Steppin' Out .................................................................................... 2
Part II: Up to Speed .................................................................................... 2
Part III: Seven League Boots ..................................................................... 3
Part IV: The Part of Tens ........................................................................... 3
Appendix: About the CD-ROM ................................................................. 3
CD Chapters: Fundamentals.....................................................................3
Icons Used in This Book ..................................................................................... 4
Part 1: Steppin' Out....................................................... 5
Chapter 1: Follow the Bouncing Ball ..........................................................
7
Ticking Off the Time ............................................................................................ 7
Making Things Move ........................................................................................... 9
Floating the point....................................................................................... 9
Encapsulating the essence of a ball ........................................................ 9
Setting Bounds ................................................................................................... 10
Moving out of bounds ............................................................................. 11
Bouncing back.......................................................................................... 11
Coding movement and bounce .............................................................. 11
Settin' things in motion........................................................................... 13
Drawing the Details ........................................................................................... 14
Drawing offscreen .................................................................................... 15
Overriding the flicker .............................................................................. 15
Drawing the background and the ball .................................................. 16
Putting.the action on the screen ........................................................... 16
Chapter 2: Ponglet........................................................................................ 17
Setting State ....................................................................................................... 17
Breaking down the task .......................................................................... 18
Serving the ball ........................................................................................ 20
Up Java Creek without a Paddle ...................................................................... 22
Returning the serve ................................................................................. 23
Changing state .......................................................................................... 24
Creating a computer opponent.............................................................. 24
Rolling down the gutter .......................................................................... 25
He shoots, he scores! .............................................................................. 26
We have a winna!...................................................................................... 26
I.........*0000,000*0.*..*000.0.0 *&0*.0000
Introduction .................................................................
1
About This Book .................................................................................................. 1
Who You Are......................................................................................................... 1
About the Java Code in This Book .................................................................... 2
How This Book Is Organized .............................................................................. 2
Part I: Steppin' Out .................................................................................... 2
Part II: Up to Speed .................................................................................... 2
Part III: Seven League Boots ..................................................................... 3
Part IV: The Part of Tens ........................................................................... 3
Appendix: About the CD-ROM ................................................................. 3
CD Chapters: Fundamentals ..................................................................... 3
Icons Used in This Book ..................................................................................... 4
Part l: Steppin' Out....................................................... 5
Chapter 1: Follow the Bouncing Ball.......................................................... 7
Ticking Off the Time ............................................................................................ 7
Making Things Move ........................................................................................... 9
Floating the point....................................................................................... 9
Encapsulating the essence of a ball ........................................................ 9
Setting Bounds ................................................................................................... 10
Moving out of bounds ............................................................................. 11
Bouncing back .......................................................................................... 11
Coding movement and bounce .............................................................. 11
Settin' things in motion........................................................................... 13
Drawing the Details ........................................................................................... 14
Drawing offscreen .................................................................................... 15
Overriding the flicker .............................................................................. 15
Drawing the background and the ball .................................................. 16
Putting.the action on the screen ........................................................... 16
Chapter 2: Ponglet........................................................................................ 17
Setting State ....................................................................................................... 17
Breaking down the task .......................................................................... 18
Serving the ball ........................................................................................ 20
Up Java Creek without a Paddle ...................................................................... 22
Returning the serve ................................................................................. 23
Changing state.......................................................................................... 24
Creating a computer opponent.............................................................. 24
Rolling down the gutter .......................................................................... 25
He shoots, he scores! .............................................................................. 26
We have a winna! ...................................................................................... 26
Table of Contents
[ Pobierz całość w formacie PDF ]