projects
/
universe.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update.
[universe.git]
/
universe.cc
diff --git
a/universe.cc
b/universe.cc
index
9522dfd
..
55e1a6d
100644
(file)
--- a/
universe.cc
+++ b/
universe.cc
@@
-7,8
+7,10
@@
#include "universe.h"
Universe::Universe(int nb_max_polygons,
#include "universe.h"
Universe::Universe(int nb_max_polygons,
- scalar_t xmax, scalar_t ymax) : _xmax(xmax), _ymax(ymax),
- _nb_max_polygons(nb_max_polygons), _nb_polygons(0) {
+ scalar_t width, scalar_t height) : _width(width),
+ _height(height),
+ _nb_max_polygons(nb_max_polygons),
+ _nb_polygons(0) {
_polygons = new Polygon *[_nb_max_polygons];
for(int n = 0; n < _nb_max_polygons; n++) _polygons[n] = 0;
}
_polygons = new Polygon *[_nb_max_polygons];
for(int n = 0; n < _nb_max_polygons; n++) _polygons[n] = 0;
}
@@
-104,7
+106,7
@@
bool Universe::update(scalar_t dt) {
bool result = false;
apply_collision_forces(dt);
for(int n = 0; n < _nb_polygons; n++) if(_polygons[n]) {
bool result = false;
apply_collision_forces(dt);
for(int n = 0; n < _nb_polygons; n++) if(_polygons[n]) {
- _polygons[n]->apply_border_forces(dt, _
xmax, _ymax
);
+ _polygons[n]->apply_border_forces(dt, _
width, _height
);
result |= _polygons[n]->update(dt);
}
return result;
result |= _polygons[n]->update(dt);
}
return result;
@@
-129,6
+131,7
@@
void Universe::print_xfig(XFigTracer *tracer) {
}
}
}
}
+#ifdef X11_SUPPORT
void Universe::draw(SimpleWindow *window) {
for(int n = 0; n < _nb_polygons; n++) {
if(_polygons[n]) {
void Universe::draw(SimpleWindow *window) {
for(int n = 0; n < _nb_polygons; n++) {
if(_polygons[n]) {
@@
-142,22
+145,21
@@
void Universe::draw(SimpleWindow *window) {
}
}
}
}
}
}
+#endif
-#ifdef CAIRO_SUPPORT
-void Universe::draw(cairo_t *context_resource) {
+void Universe::draw(Canvas *canvas) {
for(int n = 0; n < _nb_polygons; n++) {
if(_polygons[n]) {
for(int n = 0; n < _nb_polygons; n++) {
if(_polygons[n]) {
- _polygons[n]->draw(c
ontext_resource
);
+ _polygons[n]->draw(c
anvas
);
}
}
for(int n = 0; n < _nb_polygons; n++) {
if(_polygons[n]) {
}
}
for(int n = 0; n < _nb_polygons; n++) {
if(_polygons[n]) {
- _polygons[n]->draw_contours(c
ontext_resource
);
+ _polygons[n]->draw_contours(c
anvas
);
}
}
}
}
}
}
-#endif
void Universe::apply_collision_forces(scalar_t dt) {
const int nb_axis = 2;
void Universe::apply_collision_forces(scalar_t dt) {
const int nb_axis = 2;