Ajout Pastille
This commit is contained in:
parent
74c5f9d97e
commit
fdaadce136
57
main.c
57
main.c
@ -1,15 +1,64 @@
|
||||
#include<stdlib.h>
|
||||
#include<graph.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
#include <time.h>
|
||||
|
||||
#define W_WINDOW 1200 /* Largeur de la fenêtre*/
|
||||
#define H_WINDOW 800 /* Hauteur de la fenêtre*/
|
||||
|
||||
#define W_GAME 900
|
||||
#define H_GAME 600
|
||||
|
||||
#define T_PIXEL 15 /* Taille d'un pixel*/
|
||||
|
||||
#define DECALEMENT 15 /
|
||||
|
||||
void gen_pastille(int nb_pastille) /*Générer une pastille dans la grid*/
|
||||
/*Seulement le code n'est pas complet*/
|
||||
/*-Elles se génèrent à des endroits qui peuvent être les mêmes ou gêner le snake*/
|
||||
/*-Faire en sorte qu'elles se genèrent uniquement dans un x ou y multiple de T_PIXEL*/
|
||||
{
|
||||
couleur r;
|
||||
r=CouleurParNom("red");
|
||||
|
||||
int x_pastille,y_pastille,i;
|
||||
srand(time(NULL));
|
||||
|
||||
for(i=0;i<nb_pastille;i++)
|
||||
{
|
||||
x_pastille = rand()%W_GAME;
|
||||
y_pastille = rand()%H_GAME;
|
||||
|
||||
if(x_pastille < DECALEMENT*2)
|
||||
{
|
||||
x_pastille =+ DECALEMENT*2;
|
||||
}
|
||||
else if(y_pastille < DECALEMENT*2)
|
||||
{
|
||||
y_pastille =+ DECALEMENT*2;
|
||||
}
|
||||
printf("x : %d ; y : %d\n",x_pastille,y_pastille);
|
||||
|
||||
ChoisirCouleurDessin(r);
|
||||
RemplirRectangle(x_pastille-DECALEMENT,y_pastille-DECALEMENT,T_PIXEL,T_PIXEL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
couleur c;
|
||||
|
||||
int x_pastille,y_pastille;
|
||||
InitialiserGraphique();
|
||||
CreerFenetre(10,10,720,480);
|
||||
CreerFenetre(10,10,W_WINDOW,H_WINDOW);
|
||||
ChoisirTitreFenetre("SNAKE SAE11 IN C");
|
||||
EcrireTexte(10,100,"Hello World !",2);
|
||||
|
||||
c=CouleurParNom("lightgreen");
|
||||
ChoisirCouleurDessin(c);
|
||||
RemplirRectangle(0,0,600,400);
|
||||
RemplirRectangle(DECALEMENT,DECALEMENT,W_GAME,H_GAME);
|
||||
gen_pastille(5);
|
||||
Touche();
|
||||
FermerGraphique();
|
||||
return EXIT_SUCCESS;
|
||||
|
BIN
prog
BIN
prog
Binary file not shown.
13
touche.c
Normal file
13
touche.c
Normal file
@ -0,0 +1,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
if(Touche() == "XK_Left")
|
||||
{
|
||||
EcrireTexte(100,200,"Touché !",2);
|
||||
ToucheEnAttente();
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user