コード例 #1
0
ファイル: Image.cpp プロジェクト: BG-Prod/Games
void Image::print(Coordonnees where, Coordonnees from)
{
    SDL_Rect ou, dou;
    ou.x = where.x();
    ou.y = where.y();
    ou.w = where.w();
    ou.h = where.h();
    dou.x = from.x();
    dou.y = from.y();
    dou.w = from.w();
    dou.h = from.h();
    SDL_BlitSurface(image, &dou, SDL_GetVideoSurface(), &ou);
}
コード例 #2
0
ファイル: Image.cpp プロジェクト: BG-Prod/Games
void Image::print(Image * buffer, Coordonnees where, Coordonnees from)
{
    SDL_Rect ou, dou;
    ou.x = where.x();
    ou.y = where.y();
    ou.w = where.w();
    ou.h = where.h();
    dou.x = from.x();
    dou.y = from.y();
    dou.w = from.w();
    dou.h = from.h();
    SDL_BlitSurface(image, &dou, buffer->image, &ou);
}
コード例 #3
0
ファイル: Vaisseau.cpp プロジェクト: BG-Prod/Games
void Vaisseau::move()
{
    /**
    *** On déplace proportionnellement à la distance à parcourir le vaisseau sur les deux axes.
    *** Ensuite on signale si on a bougé
    **/
    Coordonnees pos = Coordonnees(position.x()+position.w()/2, position.y()+position.h()/2, position.w(), position.h());
    int vecX = cible.x()-pos.x();
    int vecY = cible.y()-pos.y();
    int base = abs(vecX)+abs(vecY);
    if(base > vitesse) {
        int movX = vitesse*vecX/base;
        int movY = vitesse*vecY/base;
        position.x(position.x()+movX);
        position.y(position.y()+movY);
        etat[0] = (abs(movX)>abs(movY)) ? (movX>0 ? RIGHT : LEFT) : (movY>0 ? BOTTOM : TOP);
        hasMoved = true;
    }
    else
    {
        hasMoved = false;
    }
}
コード例 #4
0
void PlaceJoueur::getZone(Coordonnees coordActuel, int **carte, int largeur, int hauteur, bool **depl, vector<Coordonnees>* zone, int peuple)
{
	if (!depl[coordActuel.x()][coordActuel.y()])
	{
		depl[coordActuel.x()][coordActuel.y()]=true;
		if (coordActuel.x()-1>=0)
		{
			if (verif[peuple][carte[coordActuel.x()-1][coordActuel.y()]])
			{
				Coordonnees coord(coordActuel.x()-1,coordActuel.y());
				if (find(zone->begin(),zone->end(),coord)==zone->end())
					zone->push_back(coord);
				getZone(coord,carte, largeur, hauteur,depl,zone,peuple); 
			}
		}
		if (coordActuel.x()+1<largeur)
		{
			if (verif[peuple][carte[coordActuel.x()+1][coordActuel.y()]])
			{
				Coordonnees coord(coordActuel.x()+1,coordActuel.y());
				if (find(zone->begin(),zone->end(),coord)==zone->end())
					zone->push_back(coord);
				getZone(coord,carte, largeur, hauteur,depl,zone,peuple); 
			}
		}
		if (coordActuel.y()-1>=0)
		{
			if (verif[peuple][carte[coordActuel.x()][coordActuel.y()-1]])
			{
				Coordonnees coord(coordActuel.x(),coordActuel.y()-1);
				if (find(zone->begin(),zone->end(),coord)==zone->end())
					zone->push_back(coord);
				getZone(coord,carte, largeur, hauteur,depl,zone,peuple); 
			}
		}
		if (coordActuel.y()+1<hauteur)
		{
			if (verif[peuple][carte[coordActuel.x()][coordActuel.y()+1]])
			{
				Coordonnees coord(coordActuel.x(),coordActuel.y()+1);
				if (find(zone->begin(),zone->end(),coord)==zone->end())
					zone->push_back(coord);
				getZone(coord,carte, largeur, hauteur,depl,zone,peuple); 
			}
		}
		if (peuple==Nain && carte[coordActuel.x()][coordActuel.y()]==Montagne)
        {
            for (int i=0;i<largeur;i++)
            {
                for (int j=0;j<hauteur;j++)
                {
                    if(carte[i][j]==Montagne)
                    {
							Coordonnees coord(i,j);
							if (find(zone->begin(),zone->end(),coord)==zone->end())
								zone->push_back(coord);
							getZone(coord,carte, largeur, hauteur,depl,zone,peuple); 
                    }
                }
            }
        }
	}
}