47 lines
1.1 KiB
C
47 lines
1.1 KiB
C
|
#include <stdlib.h>
|
||
|
#include <stdio.h>
|
||
|
#include <graph.h>
|
||
|
#include <time.h>
|
||
|
#include <unistd.h>
|
||
|
#include "fonction.h"
|
||
|
|
||
|
void Terrain(){
|
||
|
if (pos_x[0] >1140 || pos_x[0]<=20)
|
||
|
go_on=0;
|
||
|
if (pos_y[0]<40 || pos_y[0] >=680)
|
||
|
go_on=0;
|
||
|
}
|
||
|
|
||
|
/*Fonction Pour créer la première scene du jeu*/
|
||
|
void DessinerScene(){
|
||
|
snprintf(timer,6,"%02d:%02d", minute, seconde);
|
||
|
ChoisirCouleurDessin(CouleurParComposante(5,130,4));
|
||
|
RemplirRectangle(20,20,1160,700);
|
||
|
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
||
|
EcrireTexte(10,760,timer,2);
|
||
|
serpent=ChargerSprite("IMG/serpent.png");
|
||
|
fond=ChargerSprite("IMG/fond.png");
|
||
|
|
||
|
for (i = 0; i < segment; i++){
|
||
|
AfficherSprite(serpent, x-(i*20), y);
|
||
|
pos_x[i]=x-(i*20);
|
||
|
pos_y[i]=y;
|
||
|
old_y[i]=pos_y[i];
|
||
|
old_x[i]=pos_x[i];
|
||
|
}
|
||
|
srand(time(NULL));
|
||
|
pomme=ChargerSprite("IMG/pomme.png");
|
||
|
for (p = 0; p < 5; p++) {
|
||
|
pommex[p] = ((rand() % (58)+1)*20);
|
||
|
pommey[p] = ((rand() % (35)+1)*20);
|
||
|
AfficherSprite(pomme, pommex[p], pommey[p]);
|
||
|
}
|
||
|
}
|
||
|
/*Apparition aléatoire des pommes*/
|
||
|
void Pomme(){
|
||
|
|
||
|
for (pp = 0; pp < 5; ++pp) {
|
||
|
AfficherSprite(pomme, pommex[pp], pommey[pp]);
|
||
|
}
|
||
|
|
||
|
}
|