71 lines
1.2 KiB
C
71 lines
1.2 KiB
C
#include "utils.h"
|
|
#include <graph.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "graph_sup.h"
|
|
|
|
#define FPS 60.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, char* id) {
|
|
button BT = {0, 0, 0, 0};
|
|
BT.x = x;
|
|
BT.y = y;
|
|
BT.w = w;
|
|
BT.h = h;
|
|
BT.id = id;
|
|
|
|
BT_Count++;
|
|
Buttons = (button*) realloc(Buttons, BT_Count * sizeof(button));
|
|
Buttons[BT_Count-1] = BT;
|
|
}
|
|
|
|
char* GetButton(int x, int y) {
|
|
for (int ID = 0; ID < BT_Count; ID++) {
|
|
button BT = Buttons[ID];
|
|
if (x >= BT.y && y >= BT.y && x <= BT.x + BT.w && y <= BT.y + BT.h) {
|
|
return BT.id;
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
int RegisterInputs(char * screen) {
|
|
if (ToucheEnAttente() > 0) {
|
|
int key = Touche();
|
|
|
|
if (key == XK_Escape) return -1;
|
|
|
|
if (screen == "main_menu") {
|
|
|
|
} else if (screen == "taquin") {
|
|
|
|
}
|
|
}
|
|
|
|
if (SourisCliquee()) {
|
|
char* BT_ID = GetButton(_X, _Y);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
double delta = (1/FPS)*1000000;
|
|
unsigned long suivant = (1/FPS)*1000000;
|
|
|
|
int DrawNextFrame() {
|
|
if (Microsecondes() >= suivant) {
|
|
suivant = Microsecondes() + delta;
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
} |