boid/structure.pu

95 lines
2.1 KiB
Plaintext

@startuml Boids
hide empty members
PhysicsObject <|- Boid
Drawable <|.. Boid
ChunkManager o- PhysicsObject
Boid -- ChunkManager: register, get_objects >
Display - DrawableCollection: draws >
DrawableCollection o-- Drawable
DrawableCollection <|.. Main
Main -- PhysicsObject: simulate >
Main o-- Boid
JFrame <|- Display
class Boid {
- int group
-- constructor --
+ Boid(int width, int height, int group)
-- methods --
+ draw(Graphics g): void
+ simulate(int group): void
}
class ChunkManager {
- {static} ArrayList<ArrayList<PhysicsObject>> chunks
- {static} int width
- {static} int height
- {static} int chunks_x
- {static} int chunks_y
-- initializers --
+ {static} init(int width, int height, int chunks_x, int chunks_y):
+ {static} clear(): void
-- methods --
- {static} to_chunk_coordinates(int x, int y): int
- {static} wrap(int index, int max): int
+ {static} register(PhysicsObject obj): void
+ {static} get_objects(int x, int y): ArrayList<PhysicsObject>
}
class Display {
- int width
- int height
- DrawableCollection dc
-- constructor --
+ Display(int width, int height, DrawableCollection dc)
-- methods --
+ paint(Graphics g): void
}
class Drawable << interface >> {
+ draw(Graphics g): void
}
class DrawableCollection <<interface>> {
+ get_drawables(): Drawable[]
}
class Main <<Program Entry>> {
- {static} final int WIDTH
- {static} final int HEIGHT
- {static} final int BOID_COUNT
- {static} final int CHUNKS_X
- {static} final int CHUNKS_Y
- {static} final int FRAME_STEP
- {static} final int MAX_SPEED
..
- Boid[] boids
- Display d
-- constructor --
+ Main()
-- methods --
+ {static} main(String[] args): void
+ run(): void
+ get_drawables(): Drawable[]
}
class PhysicsObject{
+ {static} int width
+ {static} int height
+ {static} float max_speed
..
+ float x
+ float y
+ float v_x
+ float v_y
-- constructor --
+ PhysicsObject(int x, int y, int v_x, int v_y)
-- methods --
- clamp(float f, float min, float max): float
+ simulate(): void
+ apply_force(float x, float y, float factor): void
+ get_sqr_distance(PhysicsObject obj): double
}
@enduml