I've been working at this for a few hours now and I can't get it to run properly.
My goals are to:
have it run full-screen (but that's optional, and I think I can work it out on my own)
have it produce the poly-logo(as i call it) on random parts of the screen every second or so
have the logo in color (which i havent gotten around to doing just yet, any help or tips on this are apreciated)
Viewer, main class:
CODE
import javax.swing.JFrame;
public class ScreenerViewer
{
public static void main( String args[] )
{
JFrame frame = new JFrame("Mayaguez 2010 ScreenSaver");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Screener screenSaver = new Screener();
frame.add(screenSaver);
frame.setSize(1000, 500);
frame.setVisible(true);
}
}
Panel / draw class:
CODE
import java.awt.Graphics;
import java.util.Random;
import javax.swing.JPanel;
import java.awt.Graphics2D;
public class Screener extends JPanel{
public Random generator = new Random();
int x0 = generator.nextInt(1000);
int y0 = generator.nextInt(500);
int time = (int) System.currentTimeMillis();
public void Paint (Graphics g) {
Graphics2D g2 = (Graphics2D) g;
while(System.currentTimeMillis()-time < 1000/60)//60 repetitions per second(Screen refresh 60 Hz)
{
g2.draw(LogoDraw.topM(x0, y0));
g2.draw(LogoDraw.bottomM(x0,y0));
g2.draw(LogoDraw.flame1(x0,y0));
g2.draw(LogoDraw.flame2(x0,y0));
}
repaint();
}
}
Method storage / instruction class:
CODE
import java.awt.geom.GeneralPath;
import java.awt.Shape;
import javax.swing.JComponent;
public class LogoDraw extends JComponent{
public static Shape topM(int x0,int y0){
//Bigger Top M Point Instructions
// Drawing instructions
int x0Points[] = {x0+3, x0+31, x0+52, x0+73, x0+100, x0+96, x0+73, x0+52, x0+31, x0+7};
int y0Points[] = {y0+67, y0+40, y0+60, y0+40, y0+67, y0+70, y0+47, y0+66, y0+47, y0+70};
GeneralPath polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO, x0Points.length);
polygon.moveTo(x0Points[0], y0Points[0]);
for (int index = 1; index < x0Points.length; index++) {
polygon.lineTo(x0Points[index], y0Points[index]);
};
polygon.closePath();
return polygon;
}
public static Shape bottomM(int x0,int y0){
//Smaller Bottom M Point Instructions
// Drawing instructions
int x0Points[] = {x0+10, x0+31, x0+52, x0+73, x0+93, x0+90, x0+62, x0+52, x0+31, x0+13};
int y0Points[] = {y0+73, y0+55, y0+73, y0+55, y0+73, y0+76, y0+73, y0+77, y0+73, y0+76};
GeneralPath polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO, x0Points.length);
polygon.moveTo(x0Points[0], y0Points[0]);
for (int index = 1; index < x0Points.length; index++) {
polygon.lineTo(x0Points[index], y0Points[index]);
};
polygon.closePath();
return polygon;
}
public static Shape flame1(int x0,int y0){
//First Triangle
// Drawing instructions
int x0Points[] = {x0+51, x0+40, x0+51};
int y0Points[] = {y0+51, y0+37, y0+24};
GeneralPath polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO, x0Points.length);
polygon.moveTo(x0Points[0], y0Points[0]);
for (int index = 1; index < x0Points.length; index++) {
polygon.lineTo(x0Points[index], y0Points[index]);
};
polygon.closePath();
return polygon;
}
public static Shape flame2(int x0, int y0){
//Second Triangle
// Drawing instructions
int x0Points[] = {x0+51, x0+62, x0+51};
int y0Points[] = {y0+35, y0+19, y0+5};
GeneralPath polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO, x0Points.length);
polygon.moveTo(x0Points[0], y0Points[0]);
for (int index = 1; index < x0Points.length; index++) {
polygon.lineTo(x0Points[index], y0Points[index]);
};
polygon.closePath();
return polygon;
}
}
So far It opens an empty frame and panel, but does nothing else.
So, any help/tips on having it run properly are very much apreciated.