예제 #1
0
파일: Ennemi.cpp 프로젝트: dwarfman78/tanks
void Ennemi::renderLogic()
{
    sf::Vector3f ePos = myEntity->getPosition();
    if(myBrainTick.getElapsedTime().asMilliseconds()>200)
    {

        myBrainTick.restart();

        tirer();

        if(speed.x!=0||speed.y!=0)
            myApplication.getCurrentScene()->addTemporaryParticleEntity(ePos.x+speed.x*-3,ePos.y+speed.y*-3,16,16,myEntity->getSprite().getRotation()-90,5000000,"trails","trail");

    }
    if(!collision())
    {
        defVectVitesse();

        myEntity->makeAnimable(RUN);
        myEntity->setPosition(ePos.x+(speed.x*(myInterpolation)),
                              ePos.y+(speed.y*(myInterpolation)));

        myShadow->setPosition(ePos.x, ePos.y);

        defRotation();
    }
    else
    {
        speed.x = speed.y = 0;
        myEntity->makeAnimable(STOP);
    }
}
예제 #2
0
int GestionBateau::update()//Appelée a chaque frame en phase combat
{
    tirer();//on fait tirer tous les bateaux dispo
    bool test_aim;

    std::vector<Ship>::iterator j = tab_ship.begin();
    while(j != tab_ship.end())
    {//On fait bouger chaque bateau
        (*j).move();
        j++;
    }

    std::vector<TirBateau>::iterator i = tab_tir.begin();
    while(i != tab_tir.end())
    {//On fait bouger chaque tir
        test_aim = (*i).move();
        if(test_aim)//Si le tir est arrivé a destination !!
        {
            //detruire le mur associé
            (*i).detruireMur();
            tab_tir.erase(i);//puis le tir
        }
        else
        {
            i++;
        }
    }
    return 1;
}
예제 #3
0
/**
  * Pour les ennemis "classiques", l'ia consiste simplement, toutes les 1.5 secondes, à:
  		* se déplacer à gauche ou droite au hasard (sous réserve que le vaisseau ne touche pas déjà un bord)
  		* tirer 
  */
void Vaisseau::ia(Jeu* jeu) {
	if(dernierTir.GetElapsedTime() >= 0.4f) {
		tirer(jeu, 0.4f);
		float dirIa = sf::Randomizer::Random(0, 2);
		RenderWindow* win = jeu->getWindow();
		if(dirIa >= 1.0f) {
			deplacer(win, -10, 0);
		} else {
			deplacer(win, 10, 0);
		}
	}
}
예제 #4
0
void action(Context *C,Input *in)
{
    if(in->key[SDLK_RIGHT]&&!C->card.pause)
        deplacer(RIGHT,&(C->positionJoueur));
    if(in->key[SDLK_LEFT]&&!C->card.pause)
        deplacer(LEFT,&(C->positionJoueur));
    if(in->key[SDLK_SPACE]&&!C->card.pause) {
        tirer(C->positionJoueur,&(C->card));
        in->key[SDLK_SPACE]=0;
    }
    if(in->key[SDLK_p]) {
        if(!C->card.pause) C->card.pause=1;
        else C->card.pause=0;
        in->key[SDLK_p]=0;
    }
}
예제 #5
0
void gestiontir(struct TIR *TIR, struct DIVERSsysteme *systeme, struct PERSO *perso, struct DONJON *donjon)
{
    //pos du perso a l'ecran
    int x = (perso->perso.pict.pos.x + perso->perso.pict.pos.w/2);
    int y = (perso->perso.pict.pos.y + perso->perso.pict.pos.h/2);
    int cursy = (systeme->pointeur.pos.y + systeme->pointeur.pos.h);

    tirer (systeme->pointeur.pos.x, cursy, x, y, TIR->tx, TIR->ty, TIR->tableauutile, &TIR->degre, donjon);


    TIR->letirdemander = false;
    TIR->DepartBalle[TIR->tableauutile] = RUNNING;
    TIR->i[TIR->tableauutile] = 0;
    TIR->tableauutile++;
    if (TIR->tableauutile == NBcailloux)
	{
		TIR->tableauutile = 0;
	}
}
예제 #6
0
파일: Main.c 프로젝트: Darkyler/TP_Listes_C
int main (void)
{

    printf("John Cena welcomes you to Bataillette Navale 2015. In the most mindblowing, balltwisting battleship match of the century, two players will face their destinies in the arena of death. \n");
/* crée une partie appelée "partie" */
    Partie partie = creerPartie();

/* initialise une variable j1 correspondant au joueur 1 de la partie */
    Joueur j1 = joueur1(partie);

/* initialise une variable j2 correspondant au joueur 2 de la partie */
    Joueur j2 = joueur2(partie);

 /* modifie la partie en appelant commencerPartie(Partie) -> rend j1 actif et laisse j2 inactif */
    partie = commencerPartie(partie);



/* demande à j1 de placer ses bateaux */
    printf("\nPlayer 1 needs to place his ships \n");
    placerBateau(j1);


/* demande à j2 de placer ses bateaux */
    printf("\nPlayer 2 needs to place his ships \n");
    placerBateau(j2);





/* tant que la partie n'est pas terminé -> la flotte de j1 ou j2 n'est pas vide */

    while((estFinie(partie))==0)
    {
        if (quelNumero(joueurActif(partie)) == 1)
        {
          printf("\nJoueur 1: \n");
        }
        else
        {
          printf("\nJoueur 2: \n");
        }
        partie = tirer(partie);
        partie = changerJoueurActif(partie);
    }

    /* une des flottes est vide */

/* si la flotte de j1 est vide */

    if (estVideFlotte(flotte(j1)) == 1) {
        printf("\nGAME OVER! Player 2 is the winner.");
    }
    else
    {
        printf("\nGAME OVER! Player 1 is the winner.");
    }

    return 0;

}