Update SAE
This commit is contained in:
parent
5bc110a71c
commit
90faac5a01
@ -1,10 +1,43 @@
|
||||
#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();
|
||||
@ -18,6 +51,10 @@ int RegisterInputs(char * screen) {
|
||||
}
|
||||
}
|
||||
|
||||
if (SourisCliquee()) {
|
||||
char* BT_ID = GetButton(_X, _Y);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -31,18 +68,4 @@ int DrawNextFrame() {
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
double a = 0;
|
||||
void DrawGraphics(char * screen) {
|
||||
couleur black = CouleurParNom("black");
|
||||
couleur white = CouleurParNom("white");
|
||||
if (strcmp(screen, "main_menu") == 0) {
|
||||
a += 1/FPS;
|
||||
EffacerEcran(white);
|
||||
ChoisirCouleurDessin(black);
|
||||
char str[20];
|
||||
sprintf(str, "Temps : %f", a);
|
||||
EcrireTexte(100, 100, str, 2);
|
||||
}
|
||||
}
|
@ -1,10 +1,26 @@
|
||||
#ifndef _GRAPH_SUP_H
|
||||
#define _GRAPH_SUP_H
|
||||
|
||||
struct Button {
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
char* id;
|
||||
struct Button* next;
|
||||
};
|
||||
|
||||
typedef struct Button button;
|
||||
|
||||
extern button* Buttons;
|
||||
extern int BT_Count;
|
||||
|
||||
void clearButtons();
|
||||
char* GetButton(int x, int y);
|
||||
void AddButton(int x, int y, int w, int h, char* id);
|
||||
|
||||
int RegisterInputs(char * screen);
|
||||
|
||||
int DrawNextFrame(void);
|
||||
|
||||
void DrawGraphics(char * screen);
|
||||
|
||||
#endif
|
@ -1,4 +1,5 @@
|
||||
#include "utils.h"
|
||||
#include "taquin.h"
|
||||
|
||||
//Initialise le Taquin, la fonction appelle la création graphique et logique du Taquin.
|
||||
void CreateTaquin(char * filename, int rows, int columns) {
|
||||
|
@ -0,0 +1,5 @@
|
||||
#include "../graph_sup.h"
|
||||
|
||||
void AnimateTaquin(taquin T) {
|
||||
|
||||
}
|
@ -2,6 +2,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <graph.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "utils.h"
|
||||
#include "graph_sup.h"
|
||||
|
||||
@ -11,12 +13,29 @@
|
||||
int main(void) {
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(100, 100, 1200, 700);
|
||||
|
||||
char screen[30] = "taquin";
|
||||
|
||||
while (1) {
|
||||
if (RegisterInputs("main_menu") == -1) return EXIT_SUCCESS;
|
||||
if (RegisterInputs(screen) == -1) return EXIT_SUCCESS;
|
||||
|
||||
int can_draw = DrawNextFrame();
|
||||
if (can_draw == 1) {
|
||||
DrawGraphics("main_menu");
|
||||
if (DrawNextFrame()) {
|
||||
EffacerEcran(CouleurParNom("white"));
|
||||
SourisPosition();
|
||||
clearButtons();
|
||||
double x = (double)Microsecondes() / 100000.0;
|
||||
AddButton(300+sin(x)*50, 300+cos(x)*50, 100, 100, "owo");
|
||||
AddButton(500+cos(x)*50, 500+sin(x)*50, 100, 100, "owo2");
|
||||
|
||||
for (int i = 0; i < BT_Count; i++) {
|
||||
button BT = Buttons[i];
|
||||
char* ID = GetButton(_X, _Y);
|
||||
|
||||
if (!strcmp(ID, BT.id)) {
|
||||
ChoisirCouleurDessin(CouleurParNom("red"));
|
||||
} else ChoisirCouleurDessin(CouleurParNom("black"));
|
||||
DessinerRectangle(BT.x, BT.y, BT.w, BT.h);
|
||||
}
|
||||
}
|
||||
}
|
||||
FermerGraphique();
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <math.h>
|
||||
|
||||
double lerpf(double a, double b, double t) {
|
||||
double LerpF(double a, double b, double t) {
|
||||
return a + (b - a) * t;
|
||||
}
|
Loading…
Reference in New Issue
Block a user