d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Java Beginner Help
Add Reply New Topic New Poll
Member
Posts: 10,884
Joined: Jul 7 2007
Gold: 316.00
Feb 8 2013 12:13am
Hey guys I was wondering if someone was available currently to answer a java question I had about some code I'm writing. If you're on please let me know! It has to do with animation!
Member
Posts: 10,884
Joined: Jul 7 2007
Gold: 316.00
Feb 8 2013 03:20am
I'll pay FG .... LMK
Member
Posts: 4,980
Joined: Jan 16 2010
Gold: 0.00
Warn: 20%
Feb 8 2013 04:05am
Post your questions here.
Member
Posts: 4,980
Joined: Jan 16 2010
Gold: 0.00
Warn: 20%
Feb 8 2013 05:03am
Quote (Grandebedte @ 8 Feb 2013 12:05)
Post your questions here.


Here, not in my inbox.


Quote (SlayingWhileInt0xicated @ 8 Feb 2013 12:35)
The program I'm writing moves a box from the top left to the bottom right and then back up the same way but changes colors from red to blue. I cant get the box to go up and was hoping you may know what I'm doing wrong.


Code
import java.awt.*;

public class MovingPoints extends AnimationBase
{

public void drawFrame(Graphics g)
{

int x = 10, y = 10;
int f_num;
int rx, ry;

f_num = (getFrameNumber() % 37);

if(f_num > 0)
{
 rx = x + (f_num - 1) * 5;
 ry = y + (f_num - 1) * 5;
}
else
{
   rx  = x + (36) * 5;
 ry  = y + (36) * 5;
}
if ( f_num < 19)
{
 g.setColor(Color.white);
 g.fillRect(rx,ry,5,5);

 x = x + (f_num) * 5;
 y = y + (f_num) * 5;

 g.setColor(Color.red);
 g.fillRect(x,y,5,5);


}
else
{
 g.setColor(Color.white);
 g.fillRect(rx,ry,5,5);

 x = x + (f_num) * 5;
 y = y + (f_num) * 5;

 g.setColor(Color.blue);
 g.fillRect(x,y,5,5);
}
} //End of drawFrame()

}  //End of class MovingPoints

Member
Posts: 2,478
Joined: Jan 4 2007
Gold: 7,545.00
Feb 8 2013 07:16am
What does the code look like for getFrameNumber()
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll