1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#ifndef VILLE_HPP_INCLUDED
#define VILLE_HPP_INCLUDED
class Ville
{
private :
// Contiendra l'architecture de la ville
Cellule Plan [ VILLE_LARGEUR ] [ VILLE_LONGUEUR ] [ VILLE_HAUTEUR ] ;
public :
// Pour batir une nouvelle ville
void Nouvelle_ville ( ) ;
// Retour l'element de la ville
Cellule Element ( int X , int Y , int Z ) { return Plan [ X ] [ Y ] [ Z ] ; } ;
} ;
void Ville :: Nouvelle_ville ( )
{
// Sprite temporaire
SDL_Surface *Temp ;
// Iterateurs
int X , Y , Z , I , J ;
for ( Z = 0 ; Z < VILLE_HAUTEUR ; Z ++ )
{
for ( Y = 0 ; Y < VILLE_LONGUEUR ; Y ++ )
{
for ( X = 0 ; X < VILLE_LARGEUR ; X ++ )
{
Plan [ X ] [ Y ] [ Z ].Image = NULL ;
Plan [ X ] [ Y ] [ Z ].Passage = "Libre" ;
}
}
}
// Variables des maisons
int Maison_largeur , Maison_longueur ;
// On remplit la ville d'herbe
Temp = SDL_LoadBMP ( "./Sprites/Sols/Herbe.bmp" ) ;
SDL_SetColorKey ( Temp , SDL_RLEACCEL | SDL_SRCCOLORKEY , SDL_MapRGB ( Temp->format , 255 , 255 , 255 ) ) ;
for ( Y = 0 ; Y < VILLE_LONGUEUR ; Y ++ )
{
for ( X = 0 ; X < VILLE_LARGEUR ; X ++ )
{
Plan [ X ] [ Y ] [ 0 ].Image = Temp ;
}
}
// Creation d'une maison
Maison_largeur = rand ( ) % 10 + 3 ;
Maison_longueur = rand ( ) % 10 + 3 ;
X = rand ( ) % ( VILLE_LARGEUR - Maison_largeur ) ;
Y = rand ( ) % ( VILLE_LONGUEUR - Maison_longueur ) ;
Temp = SDL_LoadBMP ( "./Sprites/Sols/Plancher.bmp" ) ;
SDL_SetColorKey ( Temp , SDL_RLEACCEL | SDL_SRCCOLORKEY , SDL_MapRGB ( Temp->format , 255 , 255 , 255 ) ) ;
for ( J = Y ; J < Y + Maison_longueur ; J ++ )
{
for ( I = X ; I < X + Maison_largeur ; I ++ )
{
SDL_BlitSurface ( Temp , NULL , Plan [ I ] [ J ] [ 0 ].Image , NULL ) ;
}
}
}
#endif // VILLE_HPP_INCLUDED |
Partager