0

what im having trouble with is making an applet which has animates like the matrix code.. lines come down at random positions etc.. my lecturer said that it only takes 20 lines of code and is very simple.

he gave us this info as a hint:

Use the random class! 
 
example 
Random r = new Random(); 
for(….) 
{ 
posX = r.nextInt(300); 
posY = r.nextInt(300); 
}

this is what i have come up with so far but i don't get how to animate it :S

int rad = 25;
			int x = 25;
			
			Random r = new Random();
			
			
			for(int j =1; j<100;j++)
			{
				Color  c = new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256));
				g.setColor(c);
				g.fillOval(r.nextInt(200),r.nextInt(200), rad*2, rad*2); 
				
			}

im just testing with circles, to make them show up randomly.. this works but they are stationary, i don't get how to make them moving in less than 20 lines of code, in our lecture notes there is no info on animation.

any help will b appreciated :)

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ezzaral
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.