Add files via upload

This commit is contained in:
Mike Milligram 2019-10-15 16:56:07 +03:00 committed by GitHub
parent 2cb8e069f3
commit fafb83dd9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -238,6 +238,49 @@ void loadingAnimation(int delay, int speed)
background(TX_WHITE); background(TX_WHITE);
} }
void drawPictures (int MAP_LENGHT, MapPart mapParts[])
{
for (int elem = 0; elem < MAP_LENGHT; elem++) //i = elem
{
mapParts[elem].coords.left = round((mapParts[elem].coords.left + 30) / 60) * 60;
mapParts[elem].coords.top = round((mapParts[elem].coords.top + 30) / 60) * 60;
if (mapParts[elem].visible)
{
txBitBlt(txDC(), mapParts[elem].coords.left, mapParts[elem].coords.top, 60, 60, mapParts[elem].picture);
}
}
}
int moveBlock (int MAP_LENGHT, int BLOCK_TYPE, MapPart mapParts[], int arrElem, HDC block)
{
if (arrElem < MAP_LENGHT)
{
mapParts[arrElem] =
{
{
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
},
true, block, BLOCK_TYPE
};
arrElem++;
}
else {
char maplen_str[50];
sprintf(maplen_str, "You cannot add more than %d blocks", MAP_LENGHT);
txMessageBox(maplen_str, "Error");
arrElem--;
}
return arrElem;
}
void mainFunc() void mainFunc()
{ {
gameIsStarted = true; gameIsStarted = true;
@ -256,12 +299,11 @@ void mainFunc()
RECT waterBut = { RECT waterBut = {
extentX - BLOCK_SIZE, 2 * BLOCK_SIZE, extentX, 3 * BLOCK_SIZE extentX - BLOCK_SIZE, 2 * BLOCK_SIZE, extentX, 3 * BLOCK_SIZE
}; };
RECT fireBut = { RECT fireBut = {
extentX - BLOCK_SIZE, 3* BLOCK_SIZE, extentX, 4 * BLOCK_SIZE extentX - BLOCK_SIZE, 3* BLOCK_SIZE, extentX, 4 * BLOCK_SIZE
}; };
RECT doneBut = { RECT doneBut = {
extentX - 60, extentY - 60, extentX, extentY extentX - 60, extentY - 60, extentX, extentY
}; };
@ -295,67 +337,22 @@ void mainFunc()
0, 0, 60, 60, -1); 0, 0, 60, 60, -1);
drawButton(completeButton, false); drawButton(completeButton, false);
drawPictures (MAP_LENGHT, mapParts);
for (int elem = 0; elem < MAP_LENGHT; elem++) {
mapParts[elem].coords.left = round((mapParts[elem].coords.left + 30) / 60) * 60;
mapParts[elem].coords.top = round((mapParts[elem].coords.top + 30) / 60) * 60;
if (mapParts[elem].visible) {
txBitBlt(txDC(),
mapParts[elem].coords.left,
mapParts[elem].coords.top,
60, 60,
mapParts[elem].picture
);
}
}
//block "block" //block "block"
clickedBlock = checkClickBlock(blockBut, clickedBlock); clickedBlock = checkClickBlock(blockBut, clickedBlock);
drawBlock(clickedBlock, block); drawBlock(clickedBlock, block);
if (!(txMouseButtons() & 1) && clickedBlock) { if (!(txMouseButtons() & 1) && clickedBlock) {
arrElem = moveBlock (MAP_LENGHT,BLOCK_TYPE, mapParts, arrElem, block);
if (arrElem < MAP_LENGHT) {
mapParts[arrElem] = {
{
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
}, true, block, BLOCK_TYPE
};
arrElem++;
}
else {
char maplen_str[50];
sprintf(maplen_str, "You cannot add more than %d blocks", MAP_LENGHT);
txMessageBox(maplen_str, "Error");
arrElem--;
}
//arrElem++;
clickedBlock = false; clickedBlock = false;
} }
//block "quest" //block "quest"
clickedQuest = checkClickBlock(questBut, clickedQuest); clickedQuest = checkClickBlock(questBut, clickedQuest);
drawBlock (clickedQuest, quest); drawBlock (clickedQuest, quest);
if (!(txMouseButtons() & 1) && clickedQuest) { if (!(txMouseButtons() & 1) && clickedQuest)
if (arrElem < MAP_LENGHT) {
mapParts[arrElem] = {
{ {
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30 arrElem = moveBlock (MAP_LENGHT, QUEST_TYPE, mapParts, arrElem, quest);
}, true, quest, QUEST_TYPE
};
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;
} }
@ -363,22 +360,7 @@ void mainFunc()
clickedWater = checkClickBlock(waterBut,clickedWater); clickedWater = checkClickBlock(waterBut,clickedWater);
drawBlock (clickedWater,water); drawBlock (clickedWater,water);
if (!(txMouseButtons() & 1) && clickedWater) { if (!(txMouseButtons() & 1) && clickedWater) {
arrElem = moveBlock (MAP_LENGHT, WATER_TYPE, mapParts, arrElem, water);
if (arrElem < MAP_LENGHT) {
mapParts[arrElem] = {
{
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
}, true, water, WATER_TYPE
};
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;
} }
@ -386,6 +368,7 @@ void mainFunc()
clickedfire = checkClickBlock (fireBut ,clickedfire); clickedfire = checkClickBlock (fireBut ,clickedfire);
drawBlock (clickedfire ,fire); drawBlock (clickedfire ,fire);
if (!(txMouseButtons() & 1) && clickedfire) { if (!(txMouseButtons() & 1) && clickedfire) {
arrElem = moveBlock (MAP_LENGHT, FIRE_TYPE, mapParts, arrElem, fire);
if (arrElem < MAP_LENGHT) { if (arrElem < MAP_LENGHT) {
mapParts[arrElem] = { mapParts[arrElem] = {
@ -406,7 +389,8 @@ void mainFunc()
} }
//button to complete LevelCreating //button to complete LevelCreating
if (In(txMousePos(), doneBut) && txMouseButtons() & 1) { if (In(txMousePos(), doneBut) && txMouseButtons() & 1)
{
while (txMouseButtons() & 1) { while (txMouseButtons() & 1) {
txSleep(10); txSleep(10);
} }