#include "Design.h"
/* Design::GetClothes (BITMAP *Clothes [][])
return Clothes [][];
*/
Design::Design () {
num = 0;
ChooseOption = false;
SelectNumX = 0;
SelectNumY = 0;
DropY = 0;
dropbox = false;
SetColour = 0;
for (int i = 0; i < 5; i ++)
Colour[i] = i + 1;
MainFont = load_font ("Fonts.pcx", NULL, NULL);
ChangeCol = false;
for (int i = 0; i < 4; i ++) {
setImage [i] = 0;
setColour [i] = 5;
}
}
/* 1 - black
2 - Silver
3 - Red
4 - Blue
5 - Yellow/Blonde
*/
void Design::LoadImages (int numHair , int numAddon , int numClothes, int numExtra) {
for (int i = 0; i < numHair; i ++) {
for (int a = 0 ; a < 6; a++) {
stringstream str, str2;
str << "Design\\Hair\\HairModel" << i + 1 << "(" << a + 1 << ").bmp";
str2 << "Design\\Hair\\Hair" << i + 1 << "(" << a + 1 << ").bmp";
bHairModel [i][a] = load_bitmap (str.str().c_str(), NULL);
bHair [i][a] = load_bitmap (str2.str().c_str(),NULL);
if (!bHairModel [i][a])
allegro_message ("Error could not load %s", str.str().c_str() );
else if (!bHair [i][a])
allegro_message ("Error could not load %s" , str2.str().c_str() );
} // End of Second For Loop
} // End of First For Loop
for (int i = 0; i < numClothes; i ++) {
for (int a = 0 ; a < 6; a++) {
stringstream str, str2;
str << "Design\\Clothes\\ClothesModel" << i + 1 << "(" << a + 1 << ").bmp";
str2 << "Design\\Clothes\\Clothes" << i + 1 << "(" << a + 1 << ").bmp";
bClothesModel [i][a] = load_bitmap (str.str().c_str(), NULL);
bClothes [i][a] = load_bitmap (str2.str().c_str(),NULL);
if (!bClothesModel [i][a])
allegro_message ("Error could not load %s", str.str().c_str() );
else if (!bClothes [i][a])
allegro_message ("Error could not load %s" , str2.str().c_str() );
} // End of Second For Loop
} // End of First For Loop
for (int i = 0; i < numAddon; i ++) {
for (int a = 0 ; a < 6; a++) {
stringstream str, str2;
str << "Design\\Addons\\AddonsModel" << i + 1 << "(" << a + 1 << ").bmp";
str2 << "Design\\Addons\\Addons" << i + 1 << "(" << a + 1 << ").bmp";
bAddonsModel [i][a] = load_bitmap (str.str().c_str(), NULL);
bAddons [i][a] = load_bitmap (str2.str().c_str(),NULL);
if (!bAddonsModel [i][a])
allegro_message ("Error could not load %s", str.str().c_str() );
else if (!bAddons [i][a])
allegro_message ("Error could not load %s" , str2.str().c_str() );
} // End of Second For Loop
} // End of First For Loop
for (int i = 0 ; i < 6; i++) {
stringstream str, str2;
str << "Design\\Extra\\ExtraModel" << i + 1 << ".bmp";
str2 << "Design\\Extra\\Extra" << i + 1 << ".bmp";
bExtraModel [i] = load_bitmap (str.str().c_str(), NULL);
bExtra [i] = load_bitmap (str2.str().c_str(),NULL);
if (!bExtraModel [i] )
allegro_message ("Error could not load %s", str.str().c_str() );
else if (!bExtra [i])
allegro_message ("Error could not load %s" , str2.str().c_str() );
}
// for the selections
for (int i = 0 ; i < 4; i++) {
stringstream str;
str << "Design\\Selection" << i + 1 << ".bmp";
bSelection [i] = load_bitmap (str.str().c_str (), NULL);
if (!bSelection [i])
allegro_message ("Error could not load %s" , str.str().c_str() );
}
bBackgrounds [0] = load_bitmap ("Design\\SelectionBackground.bmp",NULL);
bNone = load_bitmap ("Design\\None.bmp",NULL);
} // Design::LoadImages
void Design::Action (BITMAP *Buffer, int numHair, int numAddon, int numClothes, int numExtra) {
Design::Controls ();
Design::Restrictions (numHair,numAddon, numClothes, numExtra);
Design::Selector (Buffer);
Design::HairModel (numHair , Buffer);
Design::AddonsModel (numAddon, Buffer);
Design::ClothesModel (numClothes, Buffer);
Design::ExtraModel (numExtra, Buffer);
Design::DrawSpriteModel (Buffer, 0);
Design::PreviewModel (Buffer);
Design::DrawSprite (Buffer);
//Design::Hair (numHair , Buffer);
}
void Design::Controls () {
if (ChooseOption == false) {
if (key [KEY_DOWN])
num ++;
else if (key [KEY_UP])
num --;
if (key [KEY_Z])
ChooseOption = true;
} // If ChooseOption = false
else if (ChooseOption == true) {
if (key [KEY_Z]){
setImage [num] = SelectNumX;
setColour [num] = DropY;
}
if (key [KEY_X])
ChooseOption = false;
if (key [KEY_RIGHT])
SelectNumX ++;
else if (key [KEY_LEFT])
SelectNumX --;
if (key [KEY_DOWN]){
if (dropbox == true) {
SelectNumY += 40;
DropY ++;
}
dropbox = true;
}
else if (key [KEY_UP]) {
SelectNumY -= 40;
DropY --;
}
} // If ChooseOption = false
} // Design::Controls ()
void Design::Restrictions (int numHair, int numAddons, int numClothes, int numExtra) {
// For Selector
if (num > 3)
num = 3;
else if (num < 0)
num = 0;
// For HairModel
if (num == 0) {
if (SelectNumX > numHair)
SelectNumX = 0;
else if (SelectNumX <0)
SelectNumX = numHair;
}
if (num == 1) {
if (SelectNumX > numAddons)
SelectNumX = 0;
else if (SelectNumX <0)
SelectNumX = numAddons;
}
if (num == 2) {
if (SelectNumX > numClothes)
SelectNumX = 0;
else if (SelectNumX <0)
SelectNumX = numClothes;
}
if (num == 3) {
if (SelectNumX > numExtra)
SelectNumX = 0;
else if (SelectNumX <0)
SelectNumX = numExtra;
}
if (num < 3) {
if (SelectNumY > 200) {
SelectNumY = 200;
DropY = 5;
}
else if (SelectNumY < 0) {
dropbox = false;
SelectNumY = 0;
DropY = 0;
}
} // if Num < 3
else {
if (SelectNumY > 40) {
SelectNumY = 40;
DropY = 1;
}
else if (SelectNumY < 0) {
dropbox = false;
SelectNumY = 0;
DropY = 0;
}
}
}
void Design::Selector (BITMAP *Buffer) {
blit (bBackgrounds [0] , Buffer, 0, 0, 0, 0, 640, 480);
masked_blit (bSelection [num], Buffer, 0, 0, 0, 0, 640, 480);
textout_centre_ex (Buffer, MainFont , "Hair" , 450 , 45 , makecol (205, 205, 205), -1);
textout_centre_ex (Buffer, MainFont , "Addons", 450, 165, makecol (205, 205, 205), -1);
textout_centre_ex (Buffer, MainFont, "Clothes" , 450, 285 , makecol (205, 205, 205), -1);
textout_centre_ex (Buffer , MainFont , "Extra" , 450, 405 , makecol (205, 205, 205), -1);
}
void Design::DrawSpriteModel ( BITMAP *Buffer, int Col ) {
textout_centre_ex (Buffer , MainFont , "Preview" , 90, 370, makecol (205, 205, 205), -1);
textout_centre_ex (Buffer, MainFont, "Player", 217, 370, makecol (205, 205, 205), -1);
masked_blit (bNone , Buffer ,32, 0, 30, 400, 32, 32);
masked_blit (bNone , Buffer ,32, 32, 60, 400, 32, 32);
masked_blit (bNone , Buffer ,32, 64, 90, 400, 32, 32);
masked_blit (bNone , Buffer ,32, 96, 120, 400, 32, 32);
if (num == 0 && ChooseOption == true){
if (DropY <= 4) {
masked_blit (bHair[SelectNumX][DropY], Buffer, 32, 0, 30, 400, 32, 32);
masked_blit (bHair[SelectNumX][DropY], Buffer, 32, 32, 60, 400, 32, 32);
masked_blit (bHair[SelectNumX][DropY], Buffer, 32, 64, 90, 400, 32, 32);
masked_blit (bHair[SelectNumX][DropY], Buffer, 32, 96, 120, 400, 32, 32);
}
}
else if (num == 1 && ChooseOption == true){
if (DropY <= 4) {
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 0, 30, 400, 32, 32);
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 32, 60, 400, 32, 32);
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 64, 90, 400, 32, 32);
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 96, 120, 400, 32, 32);
}
}
else if (num == 2 && ChooseOption == true) {
if (DropY <= 4) {
masked_blit (bClothes [SelectNumX][DropY], Buffer, 32, 0, 30, 400, 32, 32);
masked_blit (bClothes [SelectNumX][DropY], Buffer, 32, 32, 60, 400, 32, 32);
masked_blit (bClothes [SelectNumX][DropY], Buffer, 32, 64, 90, 400, 32, 32);
masked_blit (bClothes [SelectNumX][DropY], Buffer, 32, 96, 120, 400, 32, 32);
} // if no clothes are selected then draw a blank sprite
}
else if (num == 3 && ChooseOption == true) {
if (DropY <= 0) {
masked_blit (bExtra [SelectNumX], Buffer, 32, 0, 30, 400, 32, 32);
masked_blit (bExtra [SelectNumX], Buffer, 32, 32, 60, 400, 32, 32);
masked_blit (bExtra [SelectNumX], Buffer, 32, 64, 90, 400, 32, 32);
masked_blit (bExtra [SelectNumX], Buffer, 32, 96, 120, 400, 32, 32);
}
}
}
void Design::PreviewModel (BITMAP *Buffer) {
masked_blit (bNone , Buffer ,32, 0, 30, 440, 32, 32);
masked_blit (bNone , Buffer ,32, 32, 60, 440, 32, 32);
masked_blit (bNone , Buffer ,32, 64, 90, 440, 32, 32);
masked_blit (bNone , Buffer ,32, 96, 120, 440, 32, 32);
if (setColour [2] <= 4) {
masked_blit (bClothes[setImage[2]][setColour[2]], Buffer, 32, 0, 30, 440, 32, 32);
masked_blit (bClothes[setImage[2]][setColour[2]], Buffer, 32, 32, 60, 440, 32, 32);
masked_blit (bClothes[setImage[2]][setColour[2]], Buffer, 32, 64, 90, 440, 32, 32);
masked_blit (bClothes[setImage[2]][setColour[2]], Buffer, 32, 96, 120, 440, 32, 32);
}
// Preview
if (num == 2 && ChooseOption == true) {
if (DropY <= 4) {
masked_blit (bClothes [SelectNumX][DropY], Buffer, 32, 0, 30, 440, 32, 32);
masked_blit (bClothes [SelectNumX][DropY], Buffer, 32, 32, 60, 440, 32, 32);
masked_blit (bClothes [SelectNumX][DropY], Buffer, 32, 64, 90, 440, 32, 32);
masked_blit (bClothes [SelectNumX][DropY], Buffer, 32, 96, 120, 440, 32, 32);
} // if no clothes are selected then draw a blank sprite
}
if (setImage [1] > 1 && setColour [1] < 5) {
masked_blit (bAddons[setImage[1]][setColour[1]], Buffer, 32, 0, 30, 440, 32, 32);
masked_blit (bAddons[setImage[1]][setColour[1]], Buffer, 32, 32, 60, 440, 32, 32);
masked_blit (bAddons[setImage[1]][setColour[1]], Buffer, 32, 64, 90, 440, 32, 32);
masked_blit (bAddons[setImage[1]][setColour[1]], Buffer, 32, 96, 120, 440, 32, 32);
}
// Preview
if (num == 1 && ChooseOption == true){
if (DropY <= 4 && SelectNumX > 1) {
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 0, 30, 440, 32, 32);
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 32, 60, 440, 32, 32);
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 64, 90, 440, 32, 32);
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 96, 120, 440, 32, 32);
}
}
if (setColour [0] <= 4) {
masked_blit (bHair[setImage[0]][setColour[0]], Buffer, 32, 0, 30, 440, 32, 32);
masked_blit (bHair[setImage[0]][setColour[0]], Buffer, 32, 32, 60, 440, 32, 32);
masked_blit (bHair[setImage[0]][setColour[0]], Buffer, 32, 64, 90, 440, 32, 32);
masked_blit (bHair[setImage[0]][setColour[0]], Buffer, 32, 96, 120, 440, 32, 32);
}
//Preview
if (num == 0 && ChooseOption == true){
if (DropY <= 4) {
masked_blit (bHair[SelectNumX][DropY], Buffer, 32, 0, 30, 440, 32, 32);
masked_blit (bHair[SelectNumX][DropY], Buffer, 32, 32, 60, 440, 32, 32);
masked_blit (bHair[SelectNumX][DropY], Buffer, 32, 64, 90, 440, 32, 32);
masked_blit (bHair[SelectNumX][DropY], Buffer, 32, 96, 120, 440, 32, 32);
}
}
if (setImage [1] <= 1 && setColour [1] <= 4) {
masked_blit (bAddons[setImage[1]][setColour[1]], Buffer, 32, 0, 30, 440, 32, 32);
masked_blit (bAddons[setImage[1]][setColour[1]], Buffer, 32, 32, 60, 440, 32, 32);
masked_blit (bAddons[setImage[1]][setColour[1]], Buffer, 32, 64, 90, 440, 32, 32);
masked_blit (bAddons[setImage[1]][setColour[1]], Buffer, 32, 96, 120, 440, 32, 32);
}
// Preview
if (num == 1 && ChooseOption == true){
if (DropY <= 4 && SelectNumX <= 1) {
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 0, 30, 440, 32, 32);
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 32, 60, 440, 32, 32);
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 64, 90, 440, 32, 32);
masked_blit (bAddons [SelectNumX][DropY], Buffer, 32, 96, 120, 440, 32, 32);
}
}
if (setColour [3] <= 0) {
masked_blit (bExtra [setImage [3]], Buffer, 32, 0, 30 , 440 , 32, 32);
masked_blit (bExtra [setImage [3]], Buffer, 32, 32, 60 , 440 , 32, 32);
masked_blit (bExtra [setImage [3]], Buffer, 32, 64, 90 , 440 , 32, 32);
masked_blit (bExtra [setImage [3]], Buffer, 32, 96, 120 , 440 , 32, 32);
}
// Preview
if (num == 3 && ChooseOption == true) {
if (DropY <= 0) {
masked_blit (bExtra [SelectNumX], Buffer, 32, 0, 30, 440, 32, 32);
masked_blit (bExtra [SelectNumX], Buffer, 32, 32, 60, 440, 32, 32);
masked_blit (bExtra [SelectNumX], Buffer, 32, 64, 90, 440, 32, 32);
masked_blit (bExtra [SelectNumX], Buffer, 32, 96, 120, 440, 32, 32);
}
}
// End of Preview
}
void Design::DrawSprite ( BITMAP *Buffer ) {
masked_blit (bNone , Buffer, 32, 0, 200, 400, 32, 32);
masked_blit (bClothes [setImage[2]][setColour[2]], Buffer, 32, 0, 200, 400, 32, 32);
if (setImage [1] > 1 && setColour [1] < 5)
masked_blit (bAddons [setImage[1]][setColour[1]], Buffer, 32, 0, 200, 400, 32, 32);
masked_blit (bHair [setImage[0]][setColour[0]], Buffer, 32, 0, 200, 400, 32, 32);
if (setImage [1] <= 1 && setColour [1] < 5)
masked_blit (bAddons[setImage[1]][setColour[1]], Buffer, 32, 0, 200, 400, 32, 32);
if (setColour [3] <= 0)
masked_blit (bExtra [setImage [3]] , Buffer, 32, 0, 200, 400, 32, 32);
}
void Design::Clothes (int NumClothes) {
if (SelectNumX > NumClothes) // the number of clothes
SelectNumX = 0;
else if (SelectNumX < 0)
SelectNumX = NumClothes;
}
//void Design::DrawSprite (BITMAP *Buffer, int Color , int HairNumber) {
// masked_blit (bNone , Buffer, 32, 0, 50, 400, 32, 32);
// }
void Design::HairModel (int numHair, BITMAP *Buffer) {
if (num == 0 && ChooseOption == true) {
if (ChangeCol) {}
masked_stretch_blit (bHairModel [SelectNumX][0] , Buffer, 0, 0, 32, 32, 40, 96, 40, 40);
if (SelectNumX > 0)
blit (bHairModel [SelectNumX -1][SetColour], Buffer, 0, 0, 10, 100, 32, 32);
else
blit (bHairModel [numHair][SetColour], Buffer, 0, 0, 10, 100, 32, 32);
if (SelectNumX < numHair)
blit (bHairModel [SelectNumX + 1][SetColour], Buffer, 0, 0, 80, 100, 32, 32);
else
blit (bHairModel [0][SetColour], Buffer, 0, 0, 80, 100, 32, 32);
if (dropbox == true) {
masked_stretch_blit (bHairModel [SelectNumX][Colour[0]] , Buffer, 0, 0, 32, 32, 40, 136, 40, 40);
masked_stretch_blit (bHairModel [SelectNumX][Colour[1]] , Buffer, 0, 0, 32, 32, 40, 176, 40, 40);
masked_stretch_blit (bHairModel [SelectNumX][Colour[2]] , Buffer, 0, 0, 32, 32, 40, 216, 40, 40);
masked_stretch_blit (bHairModel [SelectNumX][Colour[3]] , Buffer, 0, 0, 32, 32, 40, 256, 40, 40);
masked_stretch_blit (bHairModel [SelectNumX][Colour[4]] , Buffer, 0, 0, 32, 32, 40, 296, 40, 40);
}
rect (Buffer, 40, 96 + SelectNumY, 80, 136 + SelectNumY, makecol (255, 255, 0));
} // ChooseOption == true
} // Design::Hair
void Design::AddonsModel (int numAddons , BITMAP *Buffer) {
if (num == 1 && ChooseOption == true) {
if (ChangeCol) {}
masked_stretch_blit (bAddonsModel [SelectNumX][0] , Buffer, 0, 0, 32, 32, 40, 96, 40, 40);
if (SelectNumX > 0)
blit (bAddonsModel [SelectNumX -1][SetColour], Buffer, 0, 0, 10, 100, 32, 32);
else
blit (bAddonsModel [numAddons][SetColour], Buffer, 0, 0, 10, 100, 32, 32);
if (SelectNumX < numAddons)
blit (bAddonsModel [SelectNumX + 1][SetColour], Buffer, 0, 0, 80, 100, 32, 32);
else
blit (bAddonsModel [0][SetColour], Buffer, 0, 0, 80, 100, 32, 32);
if (dropbox == true) {
masked_stretch_blit (bAddonsModel [SelectNumX][Colour[0]] , Buffer, 0, 0, 32, 32, 40, 136, 40, 40);
masked_stretch_blit (bAddonsModel [SelectNumX][Colour[1]] , Buffer, 0, 0, 32, 32, 40, 176, 40, 40);
masked_stretch_blit (bAddonsModel [SelectNumX][Colour[2]] , Buffer, 0, 0, 32, 32, 40, 216, 40, 40);
masked_stretch_blit (bAddonsModel [SelectNumX][Colour[3]] , Buffer, 0, 0, 32, 32, 40, 256, 40, 40);
masked_stretch_blit (bAddonsModel [SelectNumX][Colour[4]], Buffer, 0, 0, 32, 32, 40, 296, 40, 40);
}
rect (Buffer, 40, 96 + SelectNumY, 80, 136 + SelectNumY, makecol (255, 255, 0));
} // ChooseOption == true
}
void Design::ClothesModel (int numClothes, BITMAP *Buffer) {
if (num == 2 && ChooseOption == true) {
if (ChangeCol) {}
masked_stretch_blit (bClothesModel [SelectNumX][0] , Buffer, 0, 0, 32, 32, 40, 96, 40, 40);
if (SelectNumX > 0)
blit (bClothesModel [SelectNumX -1][SetColour], Buffer, 0, 0, 10, 100, 32, 32);
else
blit (bClothesModel [numClothes][SetColour], Buffer, 0, 0, 10, 100, 32, 32);
if (SelectNumX < numClothes)
blit (bClothesModel [SelectNumX + 1][SetColour], Buffer, 0, 0, 80, 100, 32, 32);
else
blit (bClothesModel [0][SetColour], Buffer, 0, 0, 80, 100, 32, 32);
if (dropbox == true) {
masked_stretch_blit (bClothesModel [SelectNumX][Colour[0]] , Buffer, 0, 0, 32, 32, 40, 136, 40, 40);
masked_stretch_blit (bClothesModel [SelectNumX][Colour[1]] , Buffer, 0, 0, 32, 32, 40, 176, 40, 40);
masked_stretch_blit (bClothesModel [SelectNumX][Colour[2]] , Buffer, 0, 0, 32, 32, 40, 216, 40, 40);
masked_stretch_blit (bClothesModel [SelectNumX][Colour[3]] , Buffer, 0, 0, 32, 32, 40, 256, 40, 40);
masked_stretch_blit (bClothesModel [SelectNumX][Colour[4]], Buffer, 0, 0, 32, 32, 40, 296, 40, 40);
}
rect (Buffer, 40, 96 + SelectNumY, 80, 136 + SelectNumY, makecol (255, 255, 0));
} // ChooseOption == true
}
void Design::ExtraModel (int numExtra, BITMAP *Buffer) {
if (num == 3 && ChooseOption == true) {
if (ChangeCol) {}
masked_stretch_blit (bExtraModel [SelectNumX], Buffer, 0, 0, 32, 32, 40, 96, 40, 40);
if (SelectNumX > 0)
blit (bExtraModel [SelectNumX -1], Buffer, 0, 0, 10, 100, 32, 32);
else
blit (bExtraModel [numExtra], Buffer, 0, 0, 10, 100, 32, 32);
if (SelectNumX < numExtra)
blit (bExtraModel [SelectNumX + 1], Buffer, 0, 0, 80, 100, 32, 32);
else
blit (bExtraModel [0], Buffer, 0, 0, 80, 100, 32, 32);
if (dropbox == true) {
masked_stretch_blit (bExtraModel [5], Buffer, 0, 0, 32, 32, 40, 136, 40, 40);
}
rect (Buffer, 40, 96 + SelectNumY, 80, 136 + SelectNumY, makecol (255, 255, 0));
} // ChooseOption == true
}
void Design::ColorPalette (BITMAP *Buffer) {
if (DropY == 0)
rectfill (Buffer, 0, 0, 10, 10, makecol (10, 10, 10));
else if (DropY == 1)
rectfill (Buffer, 0, 0, 10, 10, makecol (200, 200, 200));
else if (DropY == 2)
rectfill (Buffer, 0, 0, 10, 10, makecol (222, 0, 0));
else if (DropY == 3)
rectfill (Buffer, 0, 0, 10, 10, makecol (0, 250, 250));
else
rectfill (Buffer, 0, 0, 10, 10, makecol (250, 250, 0));
}
|