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
Raw Normal View History

2023-11-29 10:53:20 +00:00
#ifndef APP_H
#define APP_H
#include <QObject>
#include "interface/iStompObserver.h"
2023-12-22 11:44:28 +00:00
#include "stomp.h"
2023-12-26 21:09:42 +00:00
#include <QVector2D>
2023-12-28 13:57:13 +00:00
#include <cmath>
#include "Vector2D.h"
#define GRID_SIZE 32
2023-11-29 10:53:20 +00:00
class App : public QObject, public interface::iStompObserver {
public:
2023-12-26 17:10:52 +00:00
App(Stomp* st);
2023-11-30 08:53:53 +00:00
~App() = default;
2023-12-28 13:57:13 +00:00
const double MAX_LENGHT = sqrt(GRID_SIZE*GRID_SIZE + GRID_SIZE*GRID_SIZE);
2023-11-30 08:53:53 +00:00
// iStompObserver interface
private:
2023-12-26 17:10:52 +00:00
void connectConfirmation(bool success, QString version);
2023-11-30 08:53:53 +00:00
void sendConfirmation(bool success);
void subscribeConfirmation(bool success);
void receiveIndication(int id, QString destination, QString body);
void disconnectConfirmation();
void disconnectIndication();
2023-12-22 11:44:28 +00:00
2023-12-28 13:57:13 +00:00
protected:
2023-12-26 17:10:52 +00:00
Stomp* st_;
typedef struct {
2023-12-28 13:57:13 +00:00
Vector2D coordinate;
2023-12-28 17:15:53 +00:00
int relativeDistanceToMe;
int relativeDistanceToOtherPlayer;
2023-12-26 17:10:52 +00:00
int pts;
} Gem;
typedef struct {
int x;
int y;
bool me;
} Vehicle;
QVector<Gem> gems_;
2023-12-28 13:57:13 +00:00
Vector2D myVehicle_;
2023-12-28 17:15:53 +00:00
QVector<Vector2D> otherVehicles_;
2023-12-26 17:10:52 +00:00
void addGem(int x, int y, int pts);
void fillField(QString body);
2023-12-28 13:57:13 +00:00
Vector2D computeRelativePts(Gem g);
2023-12-28 17:15:53 +00:00
void computeRelativeDistance(Gem* g);
2023-12-26 21:09:42 +00:00
void computeMove();
2023-12-26 17:10:52 +00:00
2023-11-29 10:53:20 +00:00
};
#endif // APP_H