I am a super noob with a super noob question.
Hey Guys,
So I'm actually a graphic designer ([url=http://linkremoved[/url] < my site) but I ran into some old java files I made back in the day. They are really stupid, and it's just a stupid game I made but I'd like to play it again for nostalgic purposes. It was back in high school when I made the program on a PC and now I'm using a mac. I'm just trying to run the damn thing in an applet but it won't launch and I believe it's because I'm not declaring a main method. Here is the code
Code:
import java.util.*;
import java.awt.Graphics.*;
import java.awt.*;
import java.applet.*;
//import javax.swing.*;
//import javax.*;
public class MyGame extends Applet
{
int x = 8;
int y = 6 ;
int x1 = 12;
int y1 = 13;
int scale = 60 ;
int xformula;
int yformula;
int toplimitx;
int botlimitx;
int toplimity;
int botlimity;
int xCoord, yCoord;
int appletWidth; // width of the Applet window
int appletHeight; // height of the Applet window
Image virtualMem;
Graphics gBuffer;
boolean firstPaint;
public void init()
{
int x = 0;
int y = 0;
int x1 = 0;
int y1 = 0;
int scale = 0;
appletWidth = getWidth();
appletHeight = getHeight();
virtualMem = createImage(appletWidth,appletHeight);
gBuffer = virtualMem.getGraphics();
gBuffer.setColor(Color.white);
gBuffer.fillRect(0,0,appletWidth,appletHeight);
}//END INIT
public void paint(Graphics g)
{
Random generator = new Random();
int speedgenerator;
System.out.println(" ");
System.out.println(" ");
System.out.println("MOUSE BEGING " + xCoord + " " + yCoord );
System.out.println("------------------------------------------");
System.out.println("BALL BEGINING " + x + " " + y);
System.out.println("------------------------------------------");
System.out.println(" ");
System.out.println(" ");
x = x + x1;
y = y + y1;
if(x >= 900)
{
xformula = x - x1;
yformula = y - y1;
toplimitx = xformula + 15;
botlimitx = xformula - 15;
toplimity = yformula + 15;
botlimity = yformula - 15;
System.out.println("FORMUAL IN PROCESS BY MIKEY ZOPPO");
System.out.println("X is " + x + " x1 is " + x1 + "X Formula is " + xformula);
System.out.println("Y is " + y + " y1 is " + y1 + "Y Formula is " + yformula);
System.out.println("FORMUAL end PROCESS BY MIKEY ZOPPO");
if(xCoord >= botlimitx && xCoord <= toplimitx && yCoord >= botlimity && yCoord <= toplimity )
{
scale = scale + 60;
}
speedgenerator = generator.nextInt(49) + 13;
x1 = 0 - speedgenerator;
}
if(x <= 0)
{
xformula = x - x1;
yformula = y - y1;
toplimitx = xformula + 15;
botlimitx = xformula - 15;
toplimity = yformula + 15;
botlimity = yformula - 15;
System.out.println("FORMUAL IN PROCESS BY MIKEY ZOPPO");
System.out.println("X is " + x + " x1 is " + x1 + "X Formula is " + xformula);
System.out.println("Y is " + y + " y1 is " + y1 + "Y Formula is " + yformula);
System.out.println("FORMUAL end PROCESS BY MIKEY ZOPPO");
if(xCoord >= botlimitx && xCoord <= toplimitx && yCoord >= botlimity && yCoord <= toplimity )
{
scale = scale + 60;
}
speedgenerator = generator.nextInt(49) + 23;
x1 = speedgenerator;
}
if(y >= 600)
{
xformula = x - x1;
yformula = y - y1;
toplimitx = xformula + 15;
botlimitx = xformula - 15;
toplimity = yformula + 15;
botlimity = yformula - 15;
System.out.println("FORMUAL IN PROCESS BY MIKEY ZOPPO");
System.out.println("X is " + x + " x1 is " + x1 + "X Formula is " + xformula);
System.out.println("Y is " + y + " y1 is " + y1 + "Y Formula is " + yformula);
System.out.println("FORMUAL end PROCESS BY MIKEY ZOPPO");
if(xCoord >= botlimitx && xCoord <= toplimitx && yCoord >= botlimity && yCoord <= toplimity )
{
scale = scale + 60;
}
speedgenerator = generator.nextInt(49) + 13;
y1 = 0 - speedgenerator;
}
if(y <= 0)
{
xformula = x - x1;
yformula = y - y1;
toplimitx = xformula + 15;
botlimitx = xformula - 15;
toplimity = yformula + 15;
botlimity = yformula - 15;
System.out.println("FORMUAL IN PROCESS BY MIKEY ZOPPO");
System.out.println("X is " + x + " x1 is " + x1 + "X Formula is " + xformula);
System.out.println("Y is " + y + " y1 is " + y1 + "Y Formula is " + yformula);
System.out.println("FORMUAL end PROCESS BY MIKEY ZOPPO");
if(xCoord >= botlimitx && xCoord <= toplimitx && yCoord >= botlimity && yCoord <= toplimity )
{
scale = scale + 60;
}
speedgenerator = generator.nextInt(42) + 13;
y1 = speedgenerator;
}
System.out.println("MOUSE " + xCoord + " " + yCoord );
System.out.println("------------------------------------------");
System.out.println("BALL " + x + " " + y);
gBuffer.setColor(Color.black);
gBuffer.fillOval(x,y,scale,scale);//BALL
g.drawImage (virtualMem,0,0, this);
for (long delay = 1; delay < 10000000; delay++);
gBuffer.setColor(Color.white);
gBuffer.fillOval(x,y,scale,scale);//ERASER
g.drawImage (virtualMem,0,0, this);
}
public boolean mouseMove(Event e, int x, int y)
{
xCoord = x;
yCoord = y;
repaint();
return true;
}
}
I just need to know what code to add where so this will actually launch in an applet. Please excuse my idiocy, as I am not a developer/programer.
Thanks guys
Re: I am a super noob with a super noob question.
Applets don't have main methods but rather are launched by a browser's applet launcher. You would do well to read the tutorials on this: Applet Tutorial
Re: I am a super noob with a super noob question.
Are there any error messages in the browser's java console?
Re: I am a super noob with a super noob question.
The link is irrelevant to the question, so it has been removed.
Also, please use a meaningful subject line.