NetDragons.com
Name
Password
Save Password?

Class MovingStars


[ Source | Index | Back to Nelzan ]

class MovingStars
extends Object
MovingStars - Displays stars that move at random speeds.

This class generates a variable number of stars, puts them at random locations, with random colors, and moves them at random speeds.


Variable Index

 o color
 o height
 o i
 o length
 o maxXMove
 o maxYMove
 o r
For generating random Numbers.
 o width
 o x
 o xMove
 o y
 o yMove

Constructor Index

 o MovingStars(int, int, int, int, int)
Creates All the data to draw MovingStars.

Method Index

 o abs(int)
Returns the distance from zero.
 o genStart()
Generates the stars starting location, everything is random.
 o paint(Graphics)
Paints the stars.
 o update()
Updates the stars location.

Variables

 o x
 private int x[]
 o y
 private int y[]
 o xMove
 private int xMove[]
 o yMove
 private int yMove[]
 o color
 private Color color[]
 o height
 private int height
 o width
 private int width
 o maxXMove
 private int maxXMove
 o maxYMove
 private int maxYMove
 o length
 private int length
 o r
 Random r
For generating random Numbers.

 o i
 int i

Constructors

 o MovingStars
 MovingStars(int width,
             int height,
             int maxX,
             int maxY,
             int count)
Creates All the data to draw MovingStars.

Parameters:
width - The width of the screen.
height - The height of the screen.
maxX - Max speed the stars move in the X direction.
maxY - Max speed the stars move in the Y direction.
count - The number of stars to display.

Methods

 o update
 public void update()
Updates the stars location. It will also generate a new star should the current one be outside of visual range.

 o paint
 public void paint(Graphics g)
Paints the stars.

Parameters:
g - Where to draw the stars.
 o genStart
 private void genStart()
Generates the stars starting location, everything is random.

 o abs
 private int abs(int i)
Returns the distance from zero.

Parameters:
i - The number to check.
Returns:
s an int of the distance from zero.
Copyright © 1997-2010 by NetDragons.com. All Rights Reserved.