bonsoir a tous je suis en train de crée un
pacman mais j´ai des problemes pour les colision si une ame charitable pouvai m´aider ce serais cool
PS:je crée mon jeux grace au NGCK de lapintade je met le code sources si ca interrese kelkun
/ /
--------------------------------------------------
---------
- include " ../Ngck_moteur/Ngck.h"
/ /
--------------------------------------------------
---------
int x;
int y;
int xg1;
int yg1;
int xg2;
int yg2;
int DirectionPac;
int blockx, blocky;
void Position(void){
/*////////////////////////////////////////////////
//*/
/ *//AFFICHE L´IMAGE PAR RAPPORT A LA DIRECTION//*/
/*////////////////////////////////////////////////
//*/
KSetDisplayColor(YELLOW);
if(DirectionPac==1)
KPrintPac(x,y);
if(DirectionPac==2)
KPrintPacG(x,y);
if(DirectionPac==3)
KPrintPacH(x,y);
if(DirectionPac==4)
KPrintPacB(x,y);
}
void map(){
for(blockx=0;blockx<6;blockx++)
KPrintSquare(blockx,16);
for(blockx=3;blockx<6;blockx++)
KPrintSquare(blockx,4);
for(blockx=18;blockx<16;blockx++)
KPrintSquare(blockx,17);
for(blockx=8;blockx<15;blockx++)
KPrintSquare(blockx,13);
for(blockx=9;blockx<15;blockx++)
KPrintSquare(blockx,10);
for(blockx=17;blockx<21;blockx++)
KPrintSquare(blockx,11);
for(blockx=15;blockx<23;blockx++)
KPrintSquare(blockx,15);
for(blockx=12;blockx<15;blockx++)
KPrintSquare(blockx,2);
for(blockx=15;blockx<22;blockx++)
KPrintSquare(blockx,3);
for(blocky=2;blocky<13;blocky++)
KPrintSquare(3,blocky);
for(blocky=4;blocky<16;blocky++);
KPrintSquare(6,blocky);
for(blocky=0;blocky<10;blocky++)
KPrintSquare(9,blocky);
for(blocky=12;blocky<17;blocky++)
KPrintSquare(8,blocky);
for(blocky=15;blocky<17;blocky++);
KPrintSquare(11,blocky);
for(blocky=13;blocky<15;blocky++)
KPrintSquare(15,blocky);
for(blocky=15;blocky<19;blocky++)
KPrintSquare(23,blocky);
for(blocky=4;blocky<7;blocky++)
KPrintSquare(12,blocky);
for(blocky=2;blocky<10;blocky++)
KPrintSquare(15,blocky);
for(blocky=6;blocky<11;blocky++)
KPrintSquare(17,blocky);
for(blocky=2;blocky<11;blocky++)
KPrintSquare(21,blocky);
}
/ //
--------------------------------- ----------------
--------------------------------------------------
-----------------------------
void InitialiseGame()
{
int DirectionPac=0;
xg1=3;
yg1=3;
xg2=5;
yg2=5;
x=14;
y=9;
}
/ /
--------------------------------------------------
--------------------------------------------------
-------------------------------
void GameLoop()
{
int h;
int h2;
/ ///////////////////////////////////////////////
/ //////////////////////////////////////////////
int DirOK;
int i;
KSetDisplayColor(WHITE);
map();
/ / Dessine la barre du haut et la barre du bas
for ( i=0; i<30; i++) {
KPrintSquare(i, 0);
KPrintSquare(i, 19);
}
/ / Dessine la barre de droite et la barre de gauche
for ( i=0; i<20; i++) {
KPrintSquare(0, i);
KPrintSquare(29, i);
}
/ / Dessine la barre de separation
for(i=0; i<20; i++) {
KPrintSquare(24,i);
}
KSetDisplayColor(YELLOW);
/ ////////////GESTION DES TOUCHES////////////
if(DirOK!=1){
if ( KGetRight()){
DirectionPac=1;
x = x + 1;
KPrintPac(x,y);
}
}
if(DirOK!=2){
if ( KGetLeft() ) {
DirectionPac=2;
x = x - 1;
KPrintPacG(x,y);
}
}
if(DirOK!=3){
if ( KGetUp() ) {
DirectionPac=3;
y = y - 1;
KPrintPacH(x, y);
}
}
if(DirOK!=4){
if ( KGetDown() ) {
DirectionPac=4;
y = y + 1;
KPrintPacB(x, y);
}
}
KPrintGhost(3,3);
Position();
/ ///////COLISION//////////
/ /////////////ENNEMIE N°1////////////
h=rand()%4;
if(h==1)
xg1++;
if(h==2)
xg1--;
if(h==3)
yg1++;
if(h==4)
yg1--;
KSetDisplayColor(RED);
KPrintGhost(xg1,yg1);
/ ////////////////ENNEMIE N°2//////////
KSetDisplayColor(BLUE);
h2=rand()%4;
if(h2==1)
xg2++;
if(h2==2)
xg2--;
if(h2==3)
yg2++;
if(h2==4)
yg2--;
/ //////////////////PERLES///////////////////
KSetDisplayColor(GREEN);
KPrintBille(13,8);
}
/ /
--------------------------------------------------
---------
/ *KPrintGhost(3,3);
KPrintPac(15,15);
KPrintBille(13,8);*/
Re-PS: je suis un " debutan confirmé"
donc mon code n´est pas parfait.Toutes les remarque serons les bien venu 