1 package com.jed.actor;
2
3 import com.jed.util.BasicShapeRenderer;
4 import com.jed.util.Vector2f;
5
6
7
8
9
10
11
12
13
14
15 public final class Ball extends PhysicsEntity {
16
17
18
19
20 private final int segments;
21
22
23
24
25 private final float g;
26
27
28
29
30 private final float r;
31
32
33
34
35 private final float b;
36
37
38
39
40
41
42
43
44
45
46
47 public Ball(Vector2f displacement, Vector2f movement, Boundary bounds, int segments, float r, float g, float b) {
48 super(displacement, movement, bounds);
49
50 this.r = r;
51 this.g = g;
52 this.b = b;
53
54 this.segments = segments;
55 }
56
57 @Override
58 public double mass() {
59 return getRadius();
60 }
61
62
63
64
65
66 public int getRadius() {
67 return ((CircleBoundary) getBounds()).radius;
68 }
69
70 @Override
71 public void render() {
72 setPosition(getPosition().add(getMovement()));
73 BasicShapeRenderer.drawFilledCircle(
74 getPosition().x,
75 getPosition().y,
76 getRadius(),
77 segments,
78 r, g, b);
79
80 }
81 }