2023-12-07 14:02:18 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <graph.h>
|
|
|
|
#include "fonction.h"
|
2023-12-21 11:33:41 +01:00
|
|
|
#define LIGNE 34
|
2023-12-20 13:40:58 +01:00
|
|
|
#define COLONNE 58
|
|
|
|
#define TAILLE_CASE 20
|
|
|
|
|
|
|
|
int i,j,posx=20, posy=20;
|
|
|
|
int p=0;
|
|
|
|
int i=0;
|
|
|
|
int pp=0;
|
|
|
|
int imageMenu;
|
2023-12-07 14:02:18 +01:00
|
|
|
|
|
|
|
void Terrain(){
|
2023-12-10 11:56:12 +01:00
|
|
|
if (pos_x[0] >1160 || pos_x[0]<20)
|
2023-12-07 14:02:18 +01:00
|
|
|
go_on=0;
|
2023-12-10 11:56:12 +01:00
|
|
|
if (pos_y[0]<20 || pos_y[0] >680)
|
2023-12-07 14:02:18 +01:00
|
|
|
go_on=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Fonction Pour créer la première scene du jeu*/
|
2023-12-19 15:44:28 +01:00
|
|
|
void DessinerScene(int segment, int serpent, int pomme){
|
2023-12-20 13:40:58 +01:00
|
|
|
for(i=0;i<LIGNE;i++){
|
|
|
|
for(j=0;j<COLONNE;j++){
|
|
|
|
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
|
|
|
DessinerRectangle(posx,posy, TAILLE_CASE, TAILLE_CASE);
|
|
|
|
posx += 1;
|
|
|
|
posy += 1;
|
|
|
|
ChoisirCouleurDessin(CouleurParComposante(5,130,4));
|
|
|
|
RemplirRectangle(posx,posy, TAILLE_CASE, TAILLE_CASE);
|
|
|
|
posx += TAILLE_CASE;
|
|
|
|
posx -= 1;
|
|
|
|
posy -= 1;
|
|
|
|
}
|
|
|
|
posy += TAILLE_CASE;
|
|
|
|
posx = TAILLE_CASE;
|
|
|
|
}
|
|
|
|
|
2023-12-21 11:33:41 +01:00
|
|
|
snprintf(timer,6,"%02d:%02d", 0, 0);
|
2023-12-07 14:02:18 +01:00
|
|
|
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
|
|
|
EcrireTexte(10,760,timer,2);
|
2023-12-19 15:44:28 +01:00
|
|
|
|
2023-12-18 13:36:17 +01:00
|
|
|
|
2023-12-07 14:02:18 +01:00
|
|
|
for (i = 0; i < segment; i++){
|
2023-12-18 17:05:44 +01:00
|
|
|
AfficherSprite(serpent, 500-(i*20), 360);
|
|
|
|
pos_x[i]=500-(i*20);
|
|
|
|
pos_y[i]=360;
|
2023-12-07 14:02:18 +01:00
|
|
|
old_y[i]=pos_y[i];
|
|
|
|
old_x[i]=pos_x[i];
|
|
|
|
}
|
|
|
|
srand(time(NULL));
|
|
|
|
for (p = 0; p < 5; p++) {
|
|
|
|
pommex[p] = ((rand() % (58)+1)*20);
|
2023-12-10 12:09:56 +01:00
|
|
|
pommey[p] = ((rand() % (34)+1)*20);
|
2023-12-07 14:02:18 +01:00
|
|
|
AfficherSprite(pomme, pommex[p], pommey[p]);
|
|
|
|
}
|
|
|
|
}
|
2023-12-10 13:11:43 +01:00
|
|
|
|
2023-12-10 14:52:16 +01:00
|
|
|
/*création du menu d'accueil*/
|
|
|
|
void MenuDebut(){
|
|
|
|
imageMenu=ChargerSprite("IMG/menu1.png");
|
|
|
|
AfficherSprite(imageMenu,0,0);
|
|
|
|
EcrireTexte(450,100,"JEU DU SERPENT",2);
|
|
|
|
EcrireTexte(410,500,"Appuyer sur Q pour quitter",2);
|
|
|
|
EcrireTexte(290,400,"Appuyer sur Fleche de Droite pour lancer le jeu",2);
|
|
|
|
}
|
|
|
|
|
2023-12-07 14:02:18 +01:00
|
|
|
/*Apparition aléatoire des pommes*/
|
2023-12-19 15:44:28 +01:00
|
|
|
void Pomme(int pomme){
|
2023-12-07 14:02:18 +01:00
|
|
|
for (pp = 0; pp < 5; ++pp) {
|
|
|
|
AfficherSprite(pomme, pommex[pp], pommey[pp]);
|
|
|
|
}
|
|
|
|
|
2023-12-10 13:11:43 +01:00
|
|
|
}
|