You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdegames/kue/physics.h

77 lines
1.9 KiB
C++

#ifndef _PHYSICS_H
#define _PHYSICS_H
#include "main.h"
#include "billiard.h"
#include "pocket.h"
#include "circle.h"
#include "point.h"
#include "vector.h"
#include <ntqptrvector.h>
const int TIME_CHUNK = 10;
class KuePhysics : public TQObject {
TQ_OBJECT
public:
KuePhysics();
~KuePhysics();
// Start the physics engine
void start() { _running = true; startTimer(TIME_CHUNK); }
// Full stop
void stop() { _running = false; killTimers(); }
bool running() { return _running; }
// Run the physics state for a set number of milliseconds
// You should really only pass this 0, to seperate billiards on demand
// If you can think of a clever use for it, go right ahead, though
bool run(int milliseconds);
// Inserts a billard at a specific location
void insertBilliard(unsigned int billiard, const KueBilliard &b);
// Removes a given billiard
void removeBilliard(unsigned int billiard) { _billiards.remove(billiard); }
// Inserts pocket at a specific location
void insertPocket(unsigned int pocket, const KuePocket &p);
// Removes a given pocket
void removePocket(unsigned int pocket) { _pockets.remove(pocket); }
TQPtrVector<KueBilliard> & billiards() { return _billiards; }
TQPtrVector<KuePocket> & pockets() { return _pockets; }
double fieldWidth() { return _field_width; }
double fieldHeight() { return _field_height; }
void setFieldWidth(double field_width) { _field_width = field_width; }
void setFieldHeight(double field_height) { _field_height = field_height; }
signals:
void billiardHit(unsigned int b1, unsigned int b2);
void billiardSunk(unsigned int b, unsigned int p);
void motionStopped();
protected:
void doPocketing();
void timerEvent ( TQTimerEvent * );
bool _running;
void seperate(KueBilliard *a, KueBilliard *b);
bool allStop();
TQPtrVector<KueBilliard> _billiards;
TQPtrVector<KuePocket> _pockets;
double _field_width;
double _field_height;
};
#endif