projects
/
universe.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleaning up.
[universe.git]
/
universe.cc
diff --git
a/universe.cc
b/universe.cc
index
47d7c88
..
8dec7f5
100644
(file)
--- a/
universe.cc
+++ b/
universe.cc
@@
-16,11
+16,11
@@
Universe::Universe(int nb_max_polygons,
}
Universe::~Universe() {
}
Universe::~Universe() {
-
for(int n = 0; n < _nb_polygons; n++) if(_polygons[n]) delete _polygons[n]
;
+
clear()
;
delete[] _polygons;
}
delete[] _polygons;
}
-void Universe::initialize(Polygon *p) {
+void Universe::initialize
_polygon
(Polygon *p) {
p->initialize(_nb_max_polygons);
}
p->initialize(_nb_max_polygons);
}
@@
-163,6
+163,14
@@
void Universe::draw(Canvas *canvas) {
}
}
}
}
+void Universe::apply_gravity(scalar_t dt, scalar_t fx, scalar_t fy) {
+ for(int n = 0; n < _nb_polygons; n++)
+ if(_polygons[n])
+ _polygons[n]->apply_force(dt,
+ _polygons[n]->_center_x, _polygons[n]->_center_y,
+ fx, fy);
+}
+
void Universe::apply_collision_forces(scalar_t dt) {
const int nb_axis = 2;
int nb_collision[_nb_polygons * _nb_polygons];
void Universe::apply_collision_forces(scalar_t dt) {
const int nb_axis = 2;
int nb_collision[_nb_polygons * _nb_polygons];