ajout png + beug collisions
This commit is contained in:
parent
182af0f304
commit
90fdcd7036
BIN
SAE_semestre1/img/bombe.png
Normal file
BIN
SAE_semestre1/img/bombe.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
BIN
SAE_semestre1/img/mur.png
Normal file
BIN
SAE_semestre1/img/mur.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -48,7 +48,6 @@ void DessinerScene(){
|
||||
ChoisirCouleurDessin(CouleurParComposante(91,222,122));
|
||||
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");
|
||||
mur = ChargerSprite("../img/mur.png");
|
||||
@ -67,7 +66,7 @@ void DessinerScene(){
|
||||
pommey[p] = ((rand() % (35)+1)*20);
|
||||
AfficherSprite(pomme, pommex[p],pommey[p]);
|
||||
}
|
||||
for(i=0; i<20; i++){
|
||||
for(i=0; i<30; i++){
|
||||
murx[i] = ((rand() % (55)+1)*20);
|
||||
mury[i] = ((rand() % (35)+1)*20);
|
||||
AfficherSprite(mur, murx[i], mury[i]);
|
||||
@ -85,7 +84,7 @@ void Score(){
|
||||
void Update_Timer(){
|
||||
snprintf(timer,6,"%02d:%02d", minute, seconde);
|
||||
ChoisirCouleurDessin(CouleurParComposante(0,0,0));
|
||||
RemplirRectangle(10,700,1160,800);
|
||||
RemplirRectangle(10,700,12000,800);
|
||||
ChoisirCouleurDessin(CouleurParComposante(255,255,255));
|
||||
EcrireTexte(50,760,"time: ",2);
|
||||
EcrireTexte(120,760,timer,2);
|
||||
@ -108,16 +107,33 @@ void Update_Serpent(){
|
||||
|
||||
}
|
||||
|
||||
void Terrain(){
|
||||
if (pos_x[0] >1140 || pos_x[0]<=20)
|
||||
void Collision_Serpent(){
|
||||
int bombe;
|
||||
bombe = ChargerSprite("../img/bombe.png");
|
||||
/*Serpent contre coté*/
|
||||
if (pos_x[0] >1160 || pos_x[0]<=20){
|
||||
ChoisirCouleurDessin(CouleurParNom("red"));
|
||||
RemplirRectangle(pos_x[0],pos_x[0], 20,20);
|
||||
go_on=0;
|
||||
if (pos_y[0]<40 || pos_y[0] >=680)
|
||||
}
|
||||
/*Serpent contre coté*/
|
||||
if (pos_y[0]<40 || pos_y[0] >=700){
|
||||
ChoisirCouleurDessin(CouleurParNom("red"));
|
||||
RemplirRectangle(pos_y[0],pos_y[0], 20,20);
|
||||
go_on=0;
|
||||
|
||||
}
|
||||
/*Serpent contre Serpent*/
|
||||
for (i = 1; i < segment; i++) {
|
||||
if (pos_x[0] == pos_x[i] && pos_y[0] == pos_y[i])
|
||||
go_on = 0;
|
||||
}
|
||||
/*Serpent contre mur*/
|
||||
for(i=0; i<30;i++){
|
||||
if(pos_x[0] == murx[i] && pos_y[0] == mury[i]){
|
||||
AfficherSprite(bombe, murx[i], mury[i]);
|
||||
go_on=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -200,7 +216,7 @@ void Serpent() {
|
||||
}
|
||||
|
||||
Update_Serpent();
|
||||
Terrain();
|
||||
Collision_Serpent();
|
||||
usleep(100000);
|
||||
|
||||
}
|
||||
@ -211,16 +227,7 @@ void Pomme(){
|
||||
AfficherSprite(pomme, pommex[pp], pommey[pp]);
|
||||
}
|
||||
}
|
||||
void Mur(){
|
||||
for(i=0; i<20;i++){
|
||||
if(pos_x[0] == murx[i] && pos_y[0] == mury[i]){
|
||||
ChoisirCouleurDessin(CouleurParNom("red"));
|
||||
RemplirRectangle(murx[i],mury[i], 20,20);
|
||||
go_on=0;
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
@ -238,7 +245,6 @@ int main(){
|
||||
Controle();
|
||||
Serpent();
|
||||
Pomme();
|
||||
Mur();
|
||||
}
|
||||
FermerGraphique();
|
||||
return EXIT_SUCCESS;
|
||||
|
Loading…
Reference in New Issue
Block a user