Merge pull request #34 from IngCenter/DarkCat09-patch-1
Add files via upload
This commit is contained in:
commit
7626d5e569
2 changed files with 119 additions and 39 deletions
|
@ -22,6 +22,7 @@ int middleY;
|
||||||
int extentX;
|
int extentX;
|
||||||
int extentY;
|
int extentY;
|
||||||
|
|
||||||
|
bool lvlCreatingIsStarted = false;
|
||||||
bool gameIsStarted = false;
|
bool gameIsStarted = false;
|
||||||
|
|
||||||
struct Button {
|
struct Button {
|
||||||
|
@ -37,6 +38,8 @@ struct MapPart {
|
||||||
int blocktype;
|
int blocktype;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MapPart gettedMapParts[MAP_LENGHT + 1];
|
||||||
|
|
||||||
HDC block;
|
HDC block;
|
||||||
HDC quest;
|
HDC quest;
|
||||||
HDC water;
|
HDC water;
|
||||||
|
@ -55,6 +58,8 @@ bool addingBlock(bool clicked, RECT blockBut, HDC pic,
|
||||||
int blocktype, int* arrElem, MapPart mapParts[]);
|
int blocktype, int* arrElem, MapPart mapParts[]);
|
||||||
|
|
||||||
int readFile(string file, MapPart gettedMapParts[]);
|
int readFile(string file, MapPart gettedMapParts[]);
|
||||||
|
void playGame(MapPart gettedMapParts[]);
|
||||||
|
bool areElemWithTheseCoordsExisting(RECT coords, MapPart mapParts[]);
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
@ -91,6 +96,13 @@ int main()
|
||||||
|
|
||||||
drawMenu();
|
drawMenu();
|
||||||
|
|
||||||
|
if (lvlCreatingIsStarted) {
|
||||||
|
mainFunc();
|
||||||
|
}
|
||||||
|
else if (gameIsStarted) {
|
||||||
|
playGame(gettedMapParts);
|
||||||
|
}
|
||||||
|
|
||||||
txEnd();
|
txEnd();
|
||||||
|
|
||||||
txDeleteDC(block);
|
txDeleteDC(block);
|
||||||
|
@ -167,6 +179,7 @@ void drawMenu()
|
||||||
|
|
||||||
drawButton(buttonStart);
|
drawButton(buttonStart);
|
||||||
drawButton(buttonExit);
|
drawButton(buttonExit);
|
||||||
|
drawButton(buttonPlay);
|
||||||
|
|
||||||
txSetColor(TX_BLACK, 3);
|
txSetColor(TX_BLACK, 3);
|
||||||
txSetFillColor(TX_TRANSPARENT);
|
txSetFillColor(TX_TRANSPARENT);
|
||||||
|
@ -174,18 +187,18 @@ void drawMenu()
|
||||||
drawButton(buttonHelp);
|
drawButton(buttonHelp);
|
||||||
|
|
||||||
txSleep(50);
|
txSleep(50);
|
||||||
bool flwindow = false;
|
|
||||||
|
|
||||||
while (!GetAsyncKeyState('Q') || !GetAsyncKeyState(VK_ESCAPE)) {
|
while (!GetAsyncKeyState('Q') || !GetAsyncKeyState(VK_ESCAPE)) {
|
||||||
if (!gameIsStarted) {
|
if (!lvlCreatingIsStarted && !gameIsStarted) {
|
||||||
if (In(txMousePos(), buttonStart.coords) && txMouseButtons() & 1) {
|
if (In(txMousePos(), buttonStart.coords) && txMouseButtons() & 1) {
|
||||||
while (txMouseButtons() & 1) {
|
while (txMouseButtons() & 1) {
|
||||||
txSleep(10);
|
txSleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
//loadingAnimation(2, 3);
|
loadingAnimation(2, 7);
|
||||||
txSleep(50);
|
txSleep(50);
|
||||||
mainFunc();
|
|
||||||
|
lvlCreatingIsStarted = true;
|
||||||
}
|
}
|
||||||
if (In(txMousePos(), buttonExit.coords) && txMouseButtons() & 1) {
|
if (In(txMousePos(), buttonExit.coords) && txMouseButtons() & 1) {
|
||||||
while (txMouseButtons() & 1) {
|
while (txMouseButtons() & 1) {
|
||||||
|
@ -223,22 +236,14 @@ void drawMenu()
|
||||||
|
|
||||||
if (In(txMousePos(), buttonPlay.coords) && txMouseButtons() & 1) {
|
if (In(txMousePos(), buttonPlay.coords) && txMouseButtons() & 1) {
|
||||||
|
|
||||||
MapPart gettedMapParts[MAP_LENGHT + 1];
|
|
||||||
int arrElem = readFile("level1.fslvl", gettedMapParts);
|
int arrElem = readFile("level1.fslvl", gettedMapParts);
|
||||||
|
|
||||||
for (int i = 0; i < MAP_LENGHT; i++) {
|
gameIsStarted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (gettedMapParts[i].visible) {
|
if (lvlCreatingIsStarted || gameIsStarted) {
|
||||||
|
break;
|
||||||
txBitBlt(txDC(),
|
|
||||||
gettedMapParts[i].coords.left,
|
|
||||||
gettedMapParts[i].coords.top,
|
|
||||||
60, 60,
|
|
||||||
gettedMapParts[i].picture
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
txSleep(10);
|
txSleep(10);
|
||||||
|
@ -268,8 +273,6 @@ void loadingAnimation(int delay, int speed)
|
||||||
|
|
||||||
void mainFunc()
|
void mainFunc()
|
||||||
{
|
{
|
||||||
gameIsStarted = true;
|
|
||||||
|
|
||||||
int arrElem = 0;
|
int arrElem = 0;
|
||||||
int selectedPict = -1;
|
int selectedPict = -1;
|
||||||
const int BLOCK_SIZE = 120;
|
const int BLOCK_SIZE = 120;
|
||||||
|
@ -309,7 +312,7 @@ void mainFunc()
|
||||||
bool clickedWater = false;
|
bool clickedWater = false;
|
||||||
bool clickedFire = false;
|
bool clickedFire = false;
|
||||||
|
|
||||||
while (!GetAsyncKeyState('Q')) {
|
while (!GetAsyncKeyState('Q') || !GetAsyncKeyState(VK_ESCAPE)) {
|
||||||
background(TX_WHITE);
|
background(TX_WHITE);
|
||||||
|
|
||||||
Win32::TransparentBlt(txDC(), blockBut.left, blockBut.top, 120, 120, block,
|
Win32::TransparentBlt(txDC(), blockBut.left, blockBut.top, 120, 120, block,
|
||||||
|
@ -390,18 +393,36 @@ void mainFunc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//round((mapParts[elem].coords.left + 30) / 60) * 60
|
||||||
|
|
||||||
//moving picture
|
//moving picture
|
||||||
|
RECT oldCoords = mapParts[selectedPict].coords;
|
||||||
|
|
||||||
if (selectedPict >= 0 && txMouseButtons() & 1) {
|
if (selectedPict >= 0 && txMouseButtons() & 1) {
|
||||||
txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30,
|
|
||||||
|
txBitBlt(txDC(),
|
||||||
|
txMouseX() - 30, txMouseY() - 30,
|
||||||
60, 60, mapParts[selectedPict].picture);
|
60, 60, mapParts[selectedPict].picture);
|
||||||
}
|
}
|
||||||
if (selectedPict >= 0 && !(txMouseButtons() & 1)) {
|
if (selectedPict >= 0 && !(txMouseButtons() & 1)) {
|
||||||
mapParts[selectedPict].coords = {
|
|
||||||
txMouseX() - 30, txMouseY() - 30,
|
RECT elRectCoords = {
|
||||||
txMouseX() + 30, txMouseY() + 30
|
(round((txMouseX() - 30) / 60) * 60),
|
||||||
|
(round((txMouseY() - 30) / 60) * 60),
|
||||||
|
(round((txMouseX() + 30) / 60) * 60),
|
||||||
|
(round((txMouseY() + 30) / 60) * 60)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!areElemWithTheseCoordsExisting(elRectCoords, mapParts)) {
|
||||||
|
|
||||||
|
mapParts[selectedPict].coords = elRectCoords;
|
||||||
selectedPict = -1;
|
selectedPict = -1;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
mapParts[selectedPict].coords = oldCoords;
|
||||||
|
selectedPict = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//button to complete LevelCreating
|
//button to complete LevelCreating
|
||||||
if (In(txMousePos(), doneBut) && txMouseButtons() & 1) {
|
if (In(txMousePos(), doneBut) && txMouseButtons() & 1) {
|
||||||
|
@ -462,6 +483,10 @@ void mainFunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
txSleep(10);
|
txSleep(10);
|
||||||
|
|
||||||
|
if (GetAsyncKeyState('Q') || GetAsyncKeyState(VK_ESCAPE)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,12 +505,21 @@ bool addingBlock(bool clicked, RECT blockBut, HDC pic,
|
||||||
|
|
||||||
if (*arrElem < MAP_LENGHT) {
|
if (*arrElem < MAP_LENGHT) {
|
||||||
|
|
||||||
if (txMouseX() < txGetExtentX() - BLOCK_SIZE) {
|
RECT elRectCoords = {
|
||||||
|
|
||||||
|
(round((txMouseX() - 30) / 60) * 60),
|
||||||
|
(round((txMouseY() - 30) / 60) * 60),
|
||||||
|
(round((txMouseX() + 30) / 60) * 60),
|
||||||
|
(round((txMouseY() + 30) / 60) * 60)
|
||||||
|
};
|
||||||
|
|
||||||
|
if ((txMouseX() < txGetExtentX() - BLOCK_SIZE) &&
|
||||||
|
!(areElemWithTheseCoordsExisting(elRectCoords, mapParts)))
|
||||||
|
{
|
||||||
|
cout << !(areElemWithTheseCoordsExisting(elRectCoords, mapParts)) << endl;
|
||||||
|
|
||||||
mapParts[*arrElem] = {
|
mapParts[*arrElem] = {
|
||||||
{
|
elRectCoords, true, pic, blocktype
|
||||||
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
|
|
||||||
}, true, pic, blocktype
|
|
||||||
};
|
};
|
||||||
|
|
||||||
(*arrElem)++;
|
(*arrElem)++;
|
||||||
|
@ -572,3 +606,47 @@ int readFile(string file, MapPart gettedMapParts[])
|
||||||
return arrElem;
|
return arrElem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void playGame(MapPart gettedMapParts[])
|
||||||
|
{
|
||||||
|
background(TX_WHITE);
|
||||||
|
|
||||||
|
for (int i = 0; i < MAP_LENGHT; i++) {
|
||||||
|
|
||||||
|
if (gettedMapParts[i].visible) {
|
||||||
|
|
||||||
|
txBitBlt(txDC(),
|
||||||
|
gettedMapParts[i].coords.left,
|
||||||
|
gettedMapParts[i].coords.top,
|
||||||
|
60, 60,
|
||||||
|
gettedMapParts[i].picture
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool areElemWithTheseCoordsExisting(RECT coords, MapPart mapParts[])
|
||||||
|
{
|
||||||
|
RECT elemCoords;
|
||||||
|
bool areElemExisting;
|
||||||
|
|
||||||
|
for (int i = 0; i < MAP_LENGHT + 1; i++) {
|
||||||
|
|
||||||
|
elemCoords = mapParts[i].coords;
|
||||||
|
|
||||||
|
if (coords.left == elemCoords.left &&
|
||||||
|
coords.top == elemCoords.top &&
|
||||||
|
coords.right == elemCoords.right &&
|
||||||
|
coords.bottom == elemCoords.bottom &&
|
||||||
|
|
||||||
|
mapParts[i].visible
|
||||||
|
) {
|
||||||
|
areElemExisting = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
areElemExisting = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return areElemExisting;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
22
level1.fslvl
22
level1.fslvl
|
@ -1,11 +1,13 @@
|
||||||
Block,300,180,360,240
|
Block,240,120,300,180
|
||||||
Block,120,300,180,360
|
Block,120,240,180,300
|
||||||
Block,480,240,540,300
|
Block,360,180,420,240
|
||||||
|
Block,420,180,480,240
|
||||||
|
Quest,600,120,660,180
|
||||||
|
Fire,600,180,660,240
|
||||||
|
Water,300,300,360,360
|
||||||
|
Water,360,300,420,360
|
||||||
|
Water,420,300,480,360
|
||||||
|
Block,780,240,840,300
|
||||||
Block,960,300,1020,360
|
Block,960,300,1020,360
|
||||||
Quest,840,240,900,300
|
Block,900,240,960,300
|
||||||
Fire,840,300,900,360
|
Quest,1080,360,1140,420
|
||||||
Water,480,360,540,420
|
|
||||||
Block,720,240,780,300
|
|
||||||
Quest,600,240,660,300
|
|
||||||
Water,420,360,480,420
|
|
||||||
Water,540,360,600,420
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue