Add files via upload

Edited main.cpp and Added water and fire block.
This commit is contained in:
Андрей 2019-10-07 15:34:23 +03:00 committed by GitHub
parent bb522fa9ba
commit 7e43d5f835
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 13 deletions

View file

@ -6,11 +6,14 @@ using namespace std;
const COLORREF MY_LIGHTBLUE = RGB(75, 127, 196); const COLORREF MY_LIGHTBLUE = RGB(75, 127, 196);
const COLORREF MY_BISQUE = RGB(255, 214, 89); const COLORREF MY_BISQUE = RGB(255, 214, 89);
const int BLOCK_TYPE = 0; const int BLOCK_TYPE = 0;
const int QUEST_TYPE = 1; 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;
int middleX; int middleX;
int middleY; int middleY;
@ -34,6 +37,8 @@ struct MapPart {
HDC block; HDC block;
HDC quest; HDC quest;
HDC water;
HDC orange_but; HDC orange_but;
HDC green_but; HDC green_but;
HDC blue_but; HDC blue_but;
@ -51,6 +56,7 @@ int main()
block = txLoadImage("pictures\\block.bmp"); block = txLoadImage("pictures\\block.bmp");
quest = txLoadImage("pictures\\question.bmp"); quest = txLoadImage("pictures\\question.bmp");
water = txLoadImage("pictures\\water.bmp");
//orange_but = txLoadImage("pictures\\orange-but.bmp"); //orange_but = txLoadImage("pictures\\orange-but.bmp");
//green_but = txLoadImage("pictures\\green-but.bmp"); //green_but = txLoadImage("pictures\\green-but.bmp");
//blue_but = txLoadImage("pictures\\blue-but.bmp"); //blue_but = txLoadImage("pictures\\blue-but.bmp");
@ -214,32 +220,43 @@ void mainFunc()
int arrElem = 0; int arrElem = 0;
RECT blockBut = { RECT blockBut = {
extentX - 60, 0, extentX, 60 extentX - 60, 0, extentX, 60
}; };
RECT questBut = { RECT questBut = {
extentX - 60, 60, extentX, 120 extentX - 60, 60, extentX, 120
};
RECT waterBut = {
extentX - 60, 120, extentX, 180
}; };
RECT doneBut = { RECT doneBut = {
extentX - 60, extentY - 60, extentX, extentY extentX - 60, extentY - 60, extentX, extentY
}; };
MapPart mapParts[12]; MapPart mapParts[MAP_LENGHT];
for (int elem = 0; elem < 12; elem++) {
for (int elem = 0; elem < MAP_LENGHT; elem++) {
mapParts[elem].visible = false; mapParts[elem].visible = false;
} }
bool clickedBlock = false; bool clickedBlock = false;
bool clickedQuest = false; bool clickedQuest = false;
bool clickedWater = false;
bool clickedFire = false;
while (!GetAsyncKeyState('Q')) { while (!GetAsyncKeyState('Q')) {
background(TX_WHITE); background(TX_WHITE);
txBitBlt(txDC(), extentX - 60, 0, 60, 60, block); txBitBlt(txDC(), blockBut.left, blockBut.top, 60, 60, block);
txBitBlt(txDC(), extentX - 60, 60, 60, 60, quest); txBitBlt(txDC(), questBut.left, questBut.top, 60, 60, quest);
txBitBlt(txDC(), waterBut.left, waterBut.top, 60, 60, water);
for (int elem = 0; elem < 12; elem++) { 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) { if (mapParts[elem].visible) {
@ -262,11 +279,18 @@ void mainFunc()
} }
if (!(txMouseButtons() & 1) && clickedBlock) { if (!(txMouseButtons() & 1) && clickedBlock) {
mapParts[arrElem] = { if (arrElem <= MAP_LENGHT) {
{ mapParts[arrElem] = {
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30 {
}, true, block, BLOCK_TYPE txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
}; }, true, block, BLOCK_TYPE
};
}
else {
//íóæåí sprintf
//txMessageBox("You cannot add more than " + (char)MAP_LENGHT + "blocks", "Error");
}
arrElem++; arrElem++;
clickedBlock = false; clickedBlock = false;
} }
@ -290,6 +314,25 @@ void mainFunc()
clickedQuest = false; clickedQuest = false;
} }
//block "water"
if (In(txMousePos(), waterBut) && txMouseButtons() & 1) {
clickedWater = true;
}
if (txMouseButtons() & 1 && clickedWater) {
txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30, 60, 60, water);
}
if (!(txMouseButtons() & 1) && clickedWater) {
mapParts[arrElem] = {
{
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
}, true, water, WATER_TYPE
};
arrElem++;
clickedWater = false;
}
//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) {
@ -303,8 +346,17 @@ void mainFunc()
switch(mapParts[elem].blocktype) switch(mapParts[elem].blocktype)
{ {
case BLOCK_TYPE: case BLOCK_TYPE:
lvlfile << "Block"; lvlfile << "Block";
case QUEST_TYPE:
lvlfile << "Quest";
} }
lvlfile << mapParts[elem].coords.left;
lvlfile << mapParts[elem].coords.top;
lvlfile << mapParts[elem].coords.right;
lvlfile << mapParts[elem].coords.bottom;
lvlfile << "";
} }
} }
} }

BIN
fire-yellow-300x182.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
water.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB