GT500FOMOCO
Programmer
I am writing a simple Applet that creates a starfield of 1000 stars (which I have working right), and then takes an unknown number of parameters and makes buildings that are of the height specified in the Applet tag of the HTML file. Then I need to compute how wide to make these buildings so that they will all fit on the canvas using the getWidth() and getHeight() methods and by cumputing the number of parameter tags in the Applet tag in the HTML file. Here is my code so far:
Thanks for helping! X-) :-Q "and everything under the sun is in tune
but the sun is eclipsed by the moon." --Pink Floyd: Eclipse
"I'm going to spend eternity
reinstalling Windows." --Reinstalling Windows: by some British guy
Code:
import java.applet.Applet;
import java.awt.*;
import java.awt.geom.*;
import java.util.*;
import javax.swing.*;
public class Skyline extends Applet {
public void init() {
setBackground(Color.black);
}
public void paint(Graphics g) {
Graphics2D pen = (Graphics2D) g;
Stars starField = new Stars();
starField.drawStars(pen, getWidth(), getHeight());
}
}
class Stars {
public void drawStars(Graphics2D pen, int Width, int Height) {
Random generator = new Random();
int runs = 1;
while (runs <= 1000) {
int Xcord = generator.nextInt(Width - 3);
int Ycord = generator.nextInt(Height - 3);
Ellipse2D.Double star
= new Ellipse2D.Double(Xcord, Ycord, 3, 3);
pen.setColor(Color.white);
pen.draw(star);
runs++;
}
}
}
class Building {
public void drawBuildings(Graphics2D pen, int Width, int Height) {
}
}
Thanks for helping! X-) :-Q "and everything under the sun is in tune
but the sun is eclipsed by the moon." --Pink Floyd: Eclipse
"I'm going to spend eternity
reinstalling Windows." --Reinstalling Windows: by some British guy