Skip to content

Commit 0ac32a4

Browse files
authored
Add files via upload
1 parent 2e23ab2 commit 0ac32a4

File tree

2 files changed

+189
-117
lines changed

2 files changed

+189
-117
lines changed

src/AABB.java

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
/**
3-
* A simple class to represent the bounding box which encapsulates a 2D game
3+
* <p>A simple class to represent the bounding box which encapsulates a 2D game
44
* Sprite. An AABB (Axis-Aligned Bounding Box) is a simple rectangular box
55
* containing 4 coordinates to determine its location, and dimensions. They are
66
* used for fast minimum and maximum tests against other AABBs, and other
7-
* quad-based data structures.
7+
* quad-based data structures</p>
88
*
99
* @author Arash J. Farmand
10-
* @version 2.33
11-
* @date 2019-12-02
10+
* @version 2.35
11+
* @date 2019-12-04
1212
* @since 2019-11-24
1313
*/
1414
public class AABB {
@@ -25,39 +25,66 @@ public class AABB {
2525
float dx, dy;
2626
AABB nearby;
2727

28-
// Constructor for AABB class with some default values.
28+
/*******************************************************************************
29+
* <p>Constructor for AABB class with some default values</p>
30+
******************************************************************************/
2931
public AABB(){
30-
x1 = y1 = 0;
31-
x2 = y2 = 50;
32-
dx = dy = 0;
33-
wdth = hght = x2;
32+
x1 = 0;
33+
y1 = 0;
34+
x2 = 50;
35+
y2 = 50;
36+
dx = 0;
37+
dy = 0;
38+
wdth = x2;
39+
hght = y2;
3440
nearby = null;
3541
}
3642

37-
// move this AABB by delta_x, delta_y
43+
/*******************************************************************************
44+
* <p>Move this AABB by delta_x, delta_y</p>
45+
*
46+
* @param delta_x The delta value for which to increment the "x" position of
47+
* this AABB
48+
* @param delta_y The delta value for which to increment the "y" position of
49+
* this AABB
50+
******************************************************************************/
3851
public void relocate(float delta_x, float delta_y) {
3952
x1 += delta_x;
4053
y1 += delta_y;
4154
x2 += delta_x;
4255
y2 += delta_y;
4356
}
4457

45-
// toggle whether this AABB is near other AABBs
58+
/*******************************************************************************
59+
* <p>Toggle whether this AABB is near other AABBs</p>
60+
*
61+
* @param nrby The AABB to set as this AABB's nearby object
62+
******************************************************************************/
4663
public void set_Nearby(AABB nrby){
4764
nearby = nrby;
4865
}
4966

50-
// set the size by changing x2,y2 to be w,h distance from x1,y1
67+
/*******************************************************************************
68+
* <p>Set the size by changing x2,y2 to be w,h distance from x1,y1</p>
69+
*
70+
* @param w The width value wanted for this AABB
71+
* @param h The height value wanted for this AABB
72+
******************************************************************************/
5173
public void set_Size(float w, float h){
5274
x2 = x1 + w;
5375
y2 = y1 + h;
5476
wdth = x2 - x1;
5577
hght = y2 - y1;
5678
}
5779

58-
// change the direction and speed of this AABB
80+
/*******************************************************************************
81+
* <p>change the direction and speed of this AABB</p>
82+
*
83+
* @param delta_x The x value for movement speed and direction
84+
* @param delta_y The y value for movement speed and direction
85+
******************************************************************************/
5986
public void set_Velocity(float delta_x, float delta_y){
6087
dx = delta_x;
6188
dy = delta_y;
6289
}
63-
}
90+
}

0 commit comments

Comments
 (0)