CXXFLAGS = -fPIC -Wall -g -O3
endif
-LDFLAGS = -L/usr/X11R6/lib/
+LDFLAGS = -L/usr/X11R6/lib/ -lz -ldl
TASK_SRC = dummy.cc move_square.cc hit_shape.cc
TASK_OBJ = $(TASK_SRC:.cc=.task)
manipulator.o \
approximer.o \
intelligence.o
- $(CXX) -lX11 $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -lX11 -o $@ $^
%.task: %.cc misc.o universe.o polygon.o xfig_tracer.o map.o task.o manipulator.o
$(CXX) $(CXXFLAGS) -shared -Wl,-soname,$@ -o $@ $^
class MoveSquare : public Task {
- int _square_size;
+ scalar_t _square_size;
int _nb_shapes;
Polygon **_shapes;
bool *_targets;
scalar_t f = sqrt(sq(_force_x) + sq(_force_y));
if(f >= force_break) {
- _current_polygon = false;
+ _current_polygon = 0;
_force_x = 0;
_force_y = 0;
} else {
#define ASSERT(x, s)
#endif
-typedef float scalar_t;
+// typedef float scalar_t;
+typedef double scalar_t;
inline scalar_t sq(scalar_t x) { return x*x; }
else if(degree == 1) _square_size = 150;
else if(degree == 2) _square_size = 100;
else _square_size = 50;
- scalar_t x[] = { -_square_size/2, _square_size/2, _square_size/2, -_square_size/2 };
- scalar_t y[] = { -_square_size/2, -_square_size/2, _square_size/2, _square_size/2 };
+ scalar_t x[] = { -_square_size/2.0, _square_size/2.0, _square_size/2.0, -_square_size/2.0 };
+ scalar_t y[] = { -_square_size/2.0, -_square_size/2.0, _square_size/2.0, _square_size/2.0 };
_target = new Polygon(0.5, 1.0, 1.0, 0.0, x, y, 4);
_target->set_position(_square_size/2, _square_size/2 + (world_height - _square_size) * drand48(), 0);
_target->set_speed(0, 0, 0);
break;
case KeyPress:
+ KeySym mykey;
+ mykey = XkbKeycodeToKeysym(_display,
+ event.xkey.keycode, 0,
+ event.xkey.state & ShiftMask ? 1 : 0);
+
se.type = SimpleEvent::KEY_PRESS;
- strncpy(se.key,
- XKeysymToString(XKeycodeToKeysym(_display, event.xkey.keycode, 0)),
- (sizeof(se.key)/sizeof(char) - 1));
+ strncpy(se.key, XKeysymToString(mykey), (sizeof(se.key)/sizeof(char) - 1));
+
break;
case KeyRelease:
+ KeySym mykey;
+ mykey = XkbKeycodeToKeysym(_display,
+ event.xkey.keycode, 0,
+ event.xkey.state & ShiftMask ? 1 : 0);
+
se.type = SimpleEvent::KEY_RELEASE;
- strncpy(se.key,
- XKeysymToString(XKeycodeToKeysym(_display, event.xkey.keycode, 0)),
- (sizeof(se.key)/sizeof(char) - 1));
+ strncpy(se.key, XKeysymToString(mykey), (sizeof(se.key)/sizeof(char) - 1));
break;
default:
#include <X11/Xlib.h>
#include <X11/Xutil.h>
+#include <X11/XKBlib.h>
class SimpleEvent {
public:
static const int max_nb_user_colors = 100;
int _palette_red[max_nb_user_colors];
int _palette_green[max_nb_user_colors];
- int _palette_blue[max_nb_user_colors],;
+ int _palette_blue[max_nb_user_colors];
int user_color(int red, int green, int blue);
public:
XFigTracer(const char *name);