Repository navigation
Expand file tree
/
Copy pathComputer.java
More file actions
71 lines (61 loc) · 1.62 KB
/
Copy pathComputer.java
File metadata and controls
71 lines (61 loc) · 1.62 KB
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
package stickerball_game;
/*
* * Please Visit us at www.codemiles.com *
* This Program was Developed by www.codemiles.com forums Team
* * Please Don't Remove This Comment *
*/
import java.awt.Color;
import java.awt.Graphics;
import java.applet.*;
import java.awt.*;
/**
*
* @author Mohamed Eldib
*/
public class Computer {
public int x;
public int y;
public int sizex;
public int sizey;
public int vy;
private int real_y;
private Color StickColor;
/** Creates a new instance of Computer */
public Computer(int x,int y,int sizex,int sizey,Color StickColor) {
this.x=x;
this.y=y;
this.sizex=sizex;
this.sizey=sizey;
this.StickColor=StickColor;
vy = 4;
}
public void ComputerMove(Ball b) {
real_y = y + (sizey / 2);
if (b.vx < 0) {
if (real_y < 150) {
y += vy;
}
else if (real_y > 150) {
y -= vy;
}
} else if (b.vx > 0) {
if ( real_y != b.y) {
if (b.y < real_y) {
y -= vy;
}
else if (b.y > real_y) {
y += vy;
}
}
}
}
public void DrawStrick(Graphics g) {
g.setColor(StickColor);
g.fillRect(x, y, sizex, sizey);
}
}
/*
* * Please Visit us at www.codemiles.com *
* This Program was Developed by www.codemiles.com forums Team
* * Please Don't Remove This Comment *
*/