
-----------------------------------
jMarie
Sun Apr 24, 2011 10:06 pm

Computer Science Java Help?
-----------------------------------
I have a project in which i don't get.. I have been working on it for days..
we are supposed to make the thing move around the frame for a number of times( eg. 5), then it will move diagonally (certain # of times) then across and down the centre of the frame then around a circle in the middle..
pls help.. 
here is my code so far:

import java.awt.*;
import javax.swing.*;
import java.awt.geom.AffineTransform;

public class NAME extends JApplet implements Runnable{

private double currentAngle;
int xRot;
int yrot;
int i=0;
final int N=50;
Image ImageBuffer=null;
Graphics GraImage=null;
int x=0;
int y=0;

//double angle;

public void init(){
//setBackground(Color.white);

}

public void start()
{

Thread th=new Thread(this);
//Thread starts
th.start ();
}

//square rotation around the frame
public void run()
{
//Thread Priority
Thread.currentThread().setPriority(Threa?
for(int countime=0;countime=0)
{
x++;

repaint();

try
{
//Stop Thread
Thread.sleep(2);
}
catch (InterruptedException ex)
{
//do nothing
}
}
}
public void paintF(Graphics g) {
// super.paintF(g);
Dimension d = size();



Image image2=Toolkit.getDefaultToolkit().getIm?
int w= image2.getWidth(this);
int h = image2.getHeight(this);
g.drawImage(image2,0,0,900,700, this);
Graphics2D g2d = (Graphics2D) g;
AffineTransform origXform = g2d.getTransform();
AffineTransform newXform = (AffineTransform) (origXform.clone());


/*int radius = 200;
double angle = 2*Math.PI*i/(double)N;
x = (int)( radius*Math.cos(angle) );
y = (int)( radius*Math.sin(angle) );*/

//xRot = this.getWidth()/2;
//yRot = this.getHeight()/2;
newXform.rotate(Math.toRadians(currentAn? y);
g2d.setTransform(newXform);
Image image=Toolkit.getDefaultToolkit().getIma?
g2d.drawImage(image,x,y,null);

}//end of action



public void update(Graphics g){
ImageBuffer = createImage(this.getWidth(),this.getHeig?
GraImage=ImageBuffer.getGraphics();
paintF(GraImage);
GraImage.dispose();
g.drawImage(ImageBuffer,0,0,this);

}
public void paint(Graphics g){
update(g);
}

public static void main(String[] args){
JFrame f =new JFrame("Animation");
f.setDefaultCloseOperation(JFrame.EXIT_O?

JApplet ap = new Underwater();
ap.init();
ap.start();
f.setSize(900,732);
f.add("Center", ap);
f.setLocation(65,0);
f.setVisible(true);
}}




the background pic is underwater
then the thing moving is a starfish

-----------------------------------
apython1992
Sun Apr 24, 2011 10:08 pm

RE:Computer Science Java Help?
-----------------------------------
Can you edit your post using syntax tags?


All code goes here

[/code]

-----------------------------------
jMarie
Mon Apr 25, 2011 2:02 pm

RE:Computer Science Java Help?
-----------------------------------
it says "Can not edit a post that has been replied to."

-----------------------------------
RandomLetters
Mon Apr 25, 2011 3:00 pm

RE:Computer Science Java Help?
-----------------------------------
What don't you get or what do you need help with?

-----------------------------------
apython1992
Mon Apr 25, 2011 4:05 pm

RE:Computer Science Java Help?
-----------------------------------
If you can't edit your original post, just make a new post with the code or syntax tags. And as RandomLetters has mentioned. we could do with a bit more problem specifics. What exactly are you stuck on?
