mmK... This first class is my Bullet Timer. It displays a bullet that shoots across the screen for a certain amount of time.
It works fine.
import javax.swing.Timer;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Line2D;
import javax.swing.JApplet;
import java.awt.Rectangle;
import java.awt.Color;
public class Animate extends JApplet
{
int count = 0;
int count2 = 0;
int drawdecider = 1;
int bulletcount = 0;
int stickcounter = 0;
int pcount = 0;
int bool = 1;
final int xSIZE = 400;
final int ySIZE = 80;
public Animate()
{
bulletMover movebullet = new bulletMover(); //calls the innerclass
Timer supertimer = new Timer(50, movebullet); //sets up the timer for animation
supertimer.getDelay();
supertimer.start();
}
public void animatetest()
{
}
public void paint(final Graphics g)
{
setSize(xSIZE,ySIZE);
count++;
count2 = count2 + 12;
Graphics2D g2 = (Graphics2D)g;
Rectangle clear = new Rectangle(xSIZE,ySIZE); //rectangle used to clear board every refresh
bullet projectile1 = new bullet(count2,5); //calls a bullet Graphic
g2.setColor(Color.white); //sets the rectangle refresh to white
g2.fill(clear);
g2.draw(clear);
projectile1.shoot(g2); //draws bullet at cordinate
}
class bulletMover implements ActionListener
{
int count; //keeps track of how many times the paint has been called.
public void actionPerformed(ActionEvent e)
{
if(count < 10)
{
repaint(); //paints
count++;
}
}
}
}
This second class is my Control. I intend to upgrade it later with a listener taht reacts to a keystroke such as a spacebar, thus creating a new bullet object every time I hit the key.... I haven't been able to get the bullet to display at all yet so I haven't done this yet.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Line2D;
import javax.swing.JApplet;
import java.awt.Rectangle;
import java.awt.Color;
public class MasterAnimate extends JApplet
{
public MasterAnimate()
{
stickinstructions stick1 = new stickinstructions();
Timer masterTimer = new Timer(50,stick1);
}
public void paint(Graphics g)
{
Animate bulletanimation = new Animate();
bulletanimation.animatetest();
}
class stickinstructions implements ActionListener
{
int count; //keeps track of how many times the paint has been called.
public void actionPerformed(ActionEvent e)
{
if(count < 10)
{
repaint();
count++;
}
}
}
}
No errors display. A java applet opens at standard size blank. I know my code is probobalyl riddled with errors. Can you help me figure out what I'm supposed to do?