changement de décors, rajout oeuf, séparations de tout les fichiers + erreurs MAKE
This commit is contained in:
@@ -1,38 +1,53 @@
|
||||
#include <graph.h>
|
||||
#include "../fichier.h/serpent.h"
|
||||
|
||||
void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_y[]){
|
||||
void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_y[], int* direction){
|
||||
int i = 0;
|
||||
int serpent;
|
||||
AfficherSprite(serpent, pos_x[0], pos_y[0]);
|
||||
for (i=1 ; i<segment ; i++){
|
||||
pos_x[i]=old_x[i-1];
|
||||
pos_y[i]=old_y[i-1];
|
||||
AfficherSprite(serpent, pos_x[i], pos_y[i]);
|
||||
}
|
||||
old_x[0]=pos_x[0];
|
||||
old_y[0]=pos_y[0];
|
||||
for (i=1 ; i<segment ; i++){
|
||||
|
||||
if (*direction == 1){
|
||||
pos_y[0]=old_y[0]-20;
|
||||
}
|
||||
if (*direction == 2) {
|
||||
pos_y[0]=old_y[0]+20;
|
||||
}
|
||||
if (*direction == 3) {
|
||||
pos_x[0]=old_x[0]-20;
|
||||
}
|
||||
if (*direction == 4) {
|
||||
pos_x[0]=old_x[0]+20;
|
||||
}
|
||||
for (i=0 ; i<segment ; i++){
|
||||
ChargerImage("../img/serpent2.png", pos_x[i], pos_y[i],0,0, 20,20);
|
||||
}
|
||||
for (i=0 ; i<segment ; i++){
|
||||
ChoisirCouleurDessin(CouleurParComposante(218,209,77));
|
||||
RemplirRectangle(pos_x[segment-1], pos_y[segment-1], 20,20);
|
||||
|
||||
old_x[i]=pos_x[i];
|
||||
old_y[i]=pos_y[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void Collision_Serpent(int pos_x[], int pos_y[], int segment, int murx[], int mury[], int *go_on){
|
||||
int mur;
|
||||
int i;
|
||||
mur = ChargerSprite("../img/mur.png");
|
||||
/*Serpent contre coté*/
|
||||
if (pos_x[0] >1160 || pos_x[0]<=20){
|
||||
if (pos_x[0] >1160 || pos_x[0]<=0){
|
||||
*go_on=0;
|
||||
}
|
||||
/*Serpent contre coté*/
|
||||
if (pos_y[0]<40 || pos_y[0] >=700){
|
||||
if (pos_y[0]<20 || pos_y[0] >=700){
|
||||
*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])
|
||||
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++){
|
||||
@@ -41,6 +56,7 @@ void Collision_Serpent(int pos_x[], int pos_y[], int segment, int murx[], int mu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Controle(int *direction, int last_direction, int *go_on) {
|
||||
int t;
|
||||
while(ToucheEnAttente()) {
|
||||
@@ -77,30 +93,13 @@ void Controle(int *direction, int last_direction, int *go_on) {
|
||||
}
|
||||
void Serpent(int pos_x[], int pos_y[], int old_x[], int old_y[], int *segment, int murx[], int mury[], int *go_on, int *direction) {
|
||||
int serpent;
|
||||
int x = 600;
|
||||
int y = 400;
|
||||
int i = 0;
|
||||
serpent=ChargerSprite("../img/serpent.png");
|
||||
int i = 0;
|
||||
pos_x[0] = 600;
|
||||
pos_y[0] = 400;
|
||||
for (i = 0; i < *segment; i++){
|
||||
AfficherSprite(serpent, x-(i*20), y);
|
||||
pos_x[i]=x-(i*20);
|
||||
pos_y[i]=y;
|
||||
pos_x[i]= pos_x[0];
|
||||
pos_y[i]= pos_y[0];
|
||||
old_x[i]=pos_x[i];
|
||||
old_y[i]=pos_y[i];
|
||||
}
|
||||
if (*direction == 1 && *direction != 2 ){
|
||||
pos_y[0]=old_y[0]-20;
|
||||
}
|
||||
if (*direction == 2 && *direction != 1) {
|
||||
pos_y[0]=old_y[0]+20;
|
||||
}
|
||||
if (*direction == 3 & *direction != 4) {
|
||||
pos_x[0]=old_x[0]-20;
|
||||
}
|
||||
if (*direction == 4 && *direction != 3) {
|
||||
pos_x[0]=old_x[0]+20;
|
||||
}
|
||||
Update_Serpent(pos_x, pos_y, *segment, old_x, old_y);
|
||||
Collision_Serpent(pos_x, pos_y, *segment, murx, mury, go_on);
|
||||
usleep(100000);
|
||||
}
|
Reference in New Issue
Block a user