Page 1 of 1

java target

Posted: Tue Jan 17, 2006 8:17 am
by shiznatix
hey! does anyone here know how to draw a target (the kind you would shoot at) in java? any help would be great (fast help would be best) :lol:

what i have now:

Code: Select all

import java.awt.*;
import java.applet.*;

public class final_class extends Applet
{
	public void paint(Graphics g)
	{
		int dim = 0;
		int x = 0;
		int y = 0;
		for (int i = 10; i > 0; i--)
		{
			dim = i * 10;
			x   = dim / 2;
			y   = dim * 2;
			if ( i % 2 == 0)
				g.setColor (Color.red);
			else
				g.setColor (Color.blue);
			
			g.fillOval (x,y,dim,dim);//(y-axis, x-axis, height, width)
		}
		/*
		int dim = 0;
		
		for (int i = 0; i < 10; i++)
		{
			dim = i * 10;
				
			g2d.drawRoundRect(dim, dim, 50, 50, dim, dim);
		}
		*/
    }

}

Posted: Tue Jan 17, 2006 9:08 am
by shiznatix
this is what i came up with but its not near perfect. where did i go wrong_

Code: Select all

import java.awt.*;
import java.applet.*;

public class final_class extends Applet
{
	public void paint(Graphics g)
	{
		Dimension d = size();
		
		int dimw = 0;
		int dimh = 0;
		int x = 0;
		int y = 0;
		
		for (int i = 10; i < 18; i++)
		{
			dimh = i * d.height / 20;
			dimw = i * d.width / 20;
			
			x = (700 / i);
			
			g.drawOval (x,x,dimh,dimw);
		}
    }

}

Posted: Tue Jan 17, 2006 12:12 pm
by Jenk
miscellaneous? :P

awt was never my strongpoint in Java, so I can't help I am afraid :P

Posted: Tue Jan 17, 2006 5:02 pm
by timvw
I simply used gif images in one of my first shooter games ;)

http://timvw.madoka.be/programming/java/JSpace.zip

Posted: Tue Jan 17, 2006 5:38 pm
by shiznatix
ya sorry if i posted this in the wrong forum, i was not thinking. I turned in my last code there for my final but I believe that my teacher will be ok with it. stupid x - y axis crap, who needs it!?