APL/APL1.1/SAE11_2021/graph_sup.c
2021-11-26 12:14:37 +01:00

54 lines
1.0 KiB
C

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