Add files via upload
Edited main.cpp.
This commit is contained in:
parent
49b5552b06
commit
17bf3cda49
1 changed files with 67 additions and 27 deletions
|
@ -12,7 +12,7 @@ const int QUEST_TYPE = 1;
|
||||||
const int WATER_TYPE = 2;
|
const int WATER_TYPE = 2;
|
||||||
const int FIRE_TYPE = 3;
|
const int FIRE_TYPE = 3;
|
||||||
|
|
||||||
const int MAP_LENGHT = 15;
|
const int MAP_LENGHT = 5;
|
||||||
|
|
||||||
int middleX;
|
int middleX;
|
||||||
int middleY;
|
int middleY;
|
||||||
|
@ -92,6 +92,8 @@ int main()
|
||||||
|
|
||||||
txDeleteDC(block);
|
txDeleteDC(block);
|
||||||
txDeleteDC(quest);
|
txDeleteDC(quest);
|
||||||
|
txDeleteDC(water);
|
||||||
|
//txDeleteDC(fire);
|
||||||
|
|
||||||
txDisableAutoPause();
|
txDisableAutoPause();
|
||||||
}
|
}
|
||||||
|
@ -218,24 +220,27 @@ void mainFunc()
|
||||||
gameIsStarted = true;
|
gameIsStarted = true;
|
||||||
|
|
||||||
int arrElem = 0;
|
int arrElem = 0;
|
||||||
|
const int BLOCK_SIZE = 120;
|
||||||
|
|
||||||
RECT blockBut = {
|
RECT blockBut = {
|
||||||
extentX - 60, 0, extentX, 60
|
extentX - BLOCK_SIZE, 0, extentX, BLOCK_SIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
RECT questBut = {
|
RECT questBut = {
|
||||||
extentX - 60, 60, extentX, 120
|
extentX - BLOCK_SIZE, BLOCK_SIZE, extentX, 2 * BLOCK_SIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
RECT waterBut = {
|
RECT waterBut = {
|
||||||
extentX - 60, 120, extentX, 180
|
extentX - BLOCK_SIZE, 2 * BLOCK_SIZE, extentX, 3 * BLOCK_SIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
RECT doneBut = {
|
RECT doneBut = {
|
||||||
extentX - 60, extentY - 60, extentX, extentY
|
extentX - 60, extentY - 60, extentX, extentY
|
||||||
};
|
};
|
||||||
|
|
||||||
MapPart mapParts[MAP_LENGHT];
|
MapPart mapParts[MAP_LENGHT + 1];
|
||||||
|
|
||||||
|
Button completeButton = {doneBut, "Done"};
|
||||||
|
|
||||||
for (int elem = 0; elem < MAP_LENGHT; elem++) {
|
for (int elem = 0; elem < MAP_LENGHT; elem++) {
|
||||||
mapParts[elem].visible = false;
|
mapParts[elem].visible = false;
|
||||||
|
@ -249,9 +254,16 @@ void mainFunc()
|
||||||
while (!GetAsyncKeyState('Q')) {
|
while (!GetAsyncKeyState('Q')) {
|
||||||
background(TX_WHITE);
|
background(TX_WHITE);
|
||||||
|
|
||||||
txBitBlt(txDC(), blockBut.left, blockBut.top, 60, 60, block);
|
Win32::TransparentBlt(txDC(), blockBut.left, blockBut.top, 120, 120, block,
|
||||||
txBitBlt(txDC(), questBut.left, questBut.top, 60, 60, quest);
|
0, 0, 60, 60, -1);
|
||||||
txBitBlt(txDC(), waterBut.left, waterBut.top, 60, 60, water);
|
|
||||||
|
Win32::TransparentBlt(txDC(), questBut.left, questBut.top, 120, 120, quest,
|
||||||
|
0, 0, 60, 60, -1);
|
||||||
|
|
||||||
|
Win32::TransparentBlt(txDC(), waterBut.left, waterBut.top, 120, 120, water,
|
||||||
|
0, 0, 60, 60, -1);
|
||||||
|
|
||||||
|
drawButton(completeButton, false);
|
||||||
|
|
||||||
for (int elem = 0; elem < MAP_LENGHT; elem++) {
|
for (int elem = 0; elem < MAP_LENGHT; elem++) {
|
||||||
|
|
||||||
|
@ -279,19 +291,22 @@ void mainFunc()
|
||||||
}
|
}
|
||||||
if (!(txMouseButtons() & 1) && clickedBlock) {
|
if (!(txMouseButtons() & 1) && clickedBlock) {
|
||||||
|
|
||||||
if (arrElem <= MAP_LENGHT) {
|
if (arrElem < MAP_LENGHT) {
|
||||||
mapParts[arrElem] = {
|
mapParts[arrElem] = {
|
||||||
{
|
{
|
||||||
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
|
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
|
||||||
}, true, block, BLOCK_TYPE
|
}, true, block, BLOCK_TYPE
|
||||||
};
|
};
|
||||||
|
arrElem++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//íóæåí sprintf
|
char maplen_str[50];
|
||||||
//txMessageBox("You cannot add more than " + (char)MAP_LENGHT + "blocks", "Error");
|
sprintf(maplen_str, "You cannot add more than %d blocks", MAP_LENGHT);
|
||||||
|
txMessageBox(maplen_str, "Error");
|
||||||
|
arrElem--;
|
||||||
}
|
}
|
||||||
|
|
||||||
arrElem++;
|
//arrElem++;
|
||||||
clickedBlock = false;
|
clickedBlock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,12 +319,20 @@ void mainFunc()
|
||||||
}
|
}
|
||||||
if (!(txMouseButtons() & 1) && clickedQuest) {
|
if (!(txMouseButtons() & 1) && clickedQuest) {
|
||||||
|
|
||||||
mapParts[arrElem] = {
|
if (arrElem < MAP_LENGHT) {
|
||||||
{
|
mapParts[arrElem] = {
|
||||||
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
|
{
|
||||||
}, true, quest, QUEST_TYPE
|
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
|
||||||
};
|
}, true, quest, QUEST_TYPE
|
||||||
arrElem++;
|
};
|
||||||
|
arrElem++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
char maplen_str[50];
|
||||||
|
sprintf(maplen_str, "You cannot add more than %d blocks", MAP_LENGHT);
|
||||||
|
txMessageBox(maplen_str, "Error");
|
||||||
|
arrElem--;
|
||||||
|
}
|
||||||
|
|
||||||
clickedQuest = false;
|
clickedQuest = false;
|
||||||
}
|
}
|
||||||
|
@ -323,12 +346,20 @@ void mainFunc()
|
||||||
}
|
}
|
||||||
if (!(txMouseButtons() & 1) && clickedWater) {
|
if (!(txMouseButtons() & 1) && clickedWater) {
|
||||||
|
|
||||||
mapParts[arrElem] = {
|
if (arrElem < MAP_LENGHT) {
|
||||||
{
|
mapParts[arrElem] = {
|
||||||
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
|
{
|
||||||
}, true, water, WATER_TYPE
|
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
|
||||||
};
|
}, true, water, WATER_TYPE
|
||||||
arrElem++;
|
};
|
||||||
|
arrElem++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
char maplen_str[50];
|
||||||
|
sprintf(maplen_str, "You cannot add more than %d blocks", MAP_LENGHT);
|
||||||
|
txMessageBox(maplen_str, "Error");
|
||||||
|
arrElem--;
|
||||||
|
}
|
||||||
|
|
||||||
clickedWater = false;
|
clickedWater = false;
|
||||||
}
|
}
|
||||||
|
@ -341,20 +372,29 @@ void mainFunc()
|
||||||
|
|
||||||
ofstream lvlfile;
|
ofstream lvlfile;
|
||||||
lvlfile.open("level1.fslvl");
|
lvlfile.open("level1.fslvl");
|
||||||
for (int elem = 0; elem < 12; elem++) {
|
for (int elem = 0; elem < arrElem; elem++) {
|
||||||
if (mapParts[elem].visible) {
|
if (mapParts[elem].visible) {
|
||||||
switch(mapParts[elem].blocktype)
|
switch(mapParts[elem].blocktype)
|
||||||
{
|
{
|
||||||
case BLOCK_TYPE:
|
case BLOCK_TYPE:
|
||||||
lvlfile << "Block";
|
lvlfile << "Block,";
|
||||||
|
break;
|
||||||
case QUEST_TYPE:
|
case QUEST_TYPE:
|
||||||
lvlfile << "Quest";
|
lvlfile << "Quest,";
|
||||||
|
break;
|
||||||
|
case WATER_TYPE:
|
||||||
|
lvlfile << "Water,";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
lvlfile << mapParts[elem].coords.left;
|
lvlfile << mapParts[elem].coords.left;
|
||||||
|
lvlfile << ",";
|
||||||
lvlfile << mapParts[elem].coords.top;
|
lvlfile << mapParts[elem].coords.top;
|
||||||
|
lvlfile << ",";
|
||||||
lvlfile << mapParts[elem].coords.right;
|
lvlfile << mapParts[elem].coords.right;
|
||||||
|
lvlfile << ",";
|
||||||
lvlfile << mapParts[elem].coords.bottom;
|
lvlfile << mapParts[elem].coords.bottom;
|
||||||
|
lvlfile << "\n";
|
||||||
|
|
||||||
lvlfile << "";
|
lvlfile << "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue