This repository has been archived on 2024-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
SDi-STOMP/app.h

58 lines
1.2 KiB
C++

#ifndef APP_H
#define APP_H
#include <QObject>
#include "interface/iStompObserver.h"
#include "stomp.h"
#include <QVector2D>
#include <cmath>
#include "Vector2D.h"
#define GRID_SIZE 32
class App : public QObject, public interface::iStompObserver {
public:
App(Stomp* st);
~App() = default;
const double MAX_LENGHT = sqrt(GRID_SIZE*GRID_SIZE + GRID_SIZE*GRID_SIZE);
// iStompObserver interface
private:
void connectConfirmation(bool success, QString version);
void sendConfirmation(bool success);
void subscribeConfirmation(bool success);
void receiveIndication(int id, QString destination, QString body);
void disconnectConfirmation();
void disconnectIndication();
protected:
Stomp* st_;
typedef struct {
Vector2D coordinate;
int relativeDistanceToMe;
int relativeDistanceToOtherPlayer;
int pts;
} Gem;
typedef struct {
int x;
int y;
bool me;
} Vehicle;
QVector<Gem> gems_;
Vector2D myVehicle_;
QVector<Vector2D> otherVehicles_;
void addGem(int x, int y, int pts);
void fillField(QString body);
Vector2D computeRelativePts(Gem g);
void computeRelativeDistance(Gem* g);
void computeMove();
};
#endif // APP_H