-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathround_block.java
More file actions
28 lines (28 loc) · 918 Bytes
/
Copy pathround_block.java
File metadata and controls
28 lines (28 loc) · 918 Bytes
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
public class round_block extends immovableObj{
circle c;
public round_block()
{
super();
c = new circle();
}
public round_block(point center, double radius){
super();
c = new circle(center,radius);
}
public void interactWith(sphere obj1)
{
if(obj1.c.intersects(this.c))
{
//JOptionPane.showMessageDialog(null, "there is a collisiion!!","round block collision", JOptionPane.);
double angle = 0;
angle = Math.atan2(obj1.c.center.y-this.c.center.y,obj1.c.center.x-this.c.center.x);
vector newVel1 = obj1.velocity.rotateBy(angle);
newVel1.x = -1 * newVel1.x;
obj1.velocity = newVel1.rotateBy(-angle);
obj1.velocity.x = -obj1.velocity.x;
}
else{
//System.out.println("+=+no collide");
}
}
}