2021-11-22 17:29:33 +01:00
|
|
|
#include "utils.h"
|
|
|
|
#include <graph.h>
|
|
|
|
#include <stdio.h>
|
2021-11-24 10:24:18 +01:00
|
|
|
#include <stdlib.h>
|
2021-11-22 17:29:33 +01:00
|
|
|
#include <string.h>
|
2021-11-24 10:24:18 +01:00
|
|
|
#include "graph_sup.h"
|
2021-11-22 17:29:33 +01:00
|
|
|
|
2021-11-26 12:14:37 +01:00
|
|
|
#define FPS 120.0
|
2021-11-22 17:29:33 +01:00
|
|
|
|
2021-11-24 10:24:18 +01:00
|
|
|
button* Buttons;
|
|
|
|
int BT_Count = 0;
|
|
|
|
|
|
|
|
void clearButtons() {
|
|
|
|
BT_Count = 0;
|
|
|
|
Buttons = (button*)realloc(Buttons, sizeof(button) * 1);
|
|
|
|
}
|
|
|
|
|
2021-11-26 12:14:37 +01:00
|
|
|
void AddButton(int x, int y, int w, int h, int id) {
|
|
|
|
button BT = {x, y, w, h, id};
|
2021-11-24 10:24:18 +01:00
|
|
|
BT_Count++;
|
2021-11-26 12:14:37 +01:00
|
|
|
Buttons = (button*) realloc(Buttons, (BT_Count+1) * sizeof(button));
|
2021-11-24 10:24:18 +01:00
|
|
|
Buttons[BT_Count-1] = BT;
|
|
|
|
}
|
|
|
|
|
2021-11-26 12:14:37 +01:00
|
|
|
int GetButton(int x, int y) {
|
2021-11-24 10:24:18 +01:00
|
|
|
for (int ID = 0; ID < BT_Count; ID++) {
|
|
|
|
button BT = Buttons[ID];
|
2021-11-26 12:14:37 +01:00
|
|
|
if (x >= BT.x && y >= BT.y && x <= BT.x + BT.w && y <= BT.y + BT.h) {
|
2021-11-24 10:24:18 +01:00
|
|
|
return BT.id;
|
|
|
|
}
|
|
|
|
}
|
2021-11-26 12:14:37 +01:00
|
|
|
return -1;
|
2021-11-24 10:24:18 +01:00
|
|
|
}
|
|
|
|
|
2021-11-26 12:14:37 +01:00
|
|
|
couleur GetColorN(char* name) {
|
|
|
|
return CouleurParNom(name);
|
|
|
|
}
|
2021-11-22 17:29:33 +01:00
|
|
|
|
2021-11-24 10:24:18 +01:00
|
|
|
|
2021-11-26 12:14:37 +01:00
|
|
|
couleur GetColor(unsigned char r, unsigned char g, unsigned char b) {
|
|
|
|
return CouleurParComposante(r, g, b);
|
2021-11-22 17:29:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
double delta = (1/FPS)*1000000;
|
|
|
|
unsigned long suivant = (1/FPS)*1000000;
|
|
|
|
|
|
|
|
int DrawNextFrame() {
|
|
|
|
if (Microsecondes() >= suivant) {
|
|
|
|
suivant = Microsecondes() + delta;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|