-
Notifications
You must be signed in to change notification settings - Fork 0
/
looping8.java
80 lines (63 loc) · 2.1 KB
/
looping8.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import hsa.*;
import java.awt.Color;
public class looping8{
public static void main(String[] args){
Console con = new Console();
//Animate a ball that goes from the left to right of the screen
//variables
//the x coordinate of the upper left corner of the ball.
int intX;
//initialize
intX = 0;
//Basic theory behind animation
//1 Draw something on the screen
//2 Pause
//3 Clear the screen or the somehting
//4 Draw the same something but slightly different
//5 Pause
//6 Clear
//7 Draw the same something but slightly different
//8 Pause
//9 Clear
//10 Repeat steps 7-9 as needed
con.setColor(Color.RED); //1a
con.fillOval(intX,300, 25, 25); //1b
pause(100); //2
//con.clear();
con.setColor(Color.WHITE); //3a
con.fillOval(intX, 300, 25, 25); //3b
while(intX > 600){
intX = intX + 50;
con.setColor(Color.RED);
con.fillOval(intX, 300, 25, 25);
pause(100);
con.setColor(Color.WHITE);
con.fillOval(intX, 300,25,25);
}
con.println("Ballzzzzz!!!!!");
intX = intX + 50;
con.setColor(Color.RED);
con.fillOval(intX, 300, 25, 25);
pause(100);
con.setColor(Color.WHITE);
con.fillOval(intX, 300,25,25);
intX = intX + 50;
con.setColor(Color.RED);
con.fillOval(intX, 300, 25, 25);
pause(100);
con.setColor(Color.WHITE);
con.fillOval(intX, 300,25,25);
intX = intX + 50;
con.setColor(Color.RED);
con.fillOval(intX, 300, 25, 25);
pause(100);
con.setColor(Color.WHITE);
con.fillOval(intX, 300,25,25);
}
public static void pause(int intMS){
try{
Thread.sleep(intMS);
}catch(InterruptedException e){
}
}
}