Add files via upload
Это первый мой русский комментарий. Я в FallSimulator поправил кучу багов! Но один из не хочет поправляться... Михаил, я на занятии расскажу - что пытался сделать. Пока что, если можете, помогите, пожалуйста! У меня после своих редактирований блоки не ставятся. Шо делать?..
This commit is contained in:
parent
05647e125a
commit
b90e675eca
2 changed files with 118 additions and 39 deletions
|
@ -22,6 +22,7 @@ int middleY;
|
|||
int extentX;
|
||||
int extentY;
|
||||
|
||||
bool lvlCreatingIsStarted = false;
|
||||
bool gameIsStarted = false;
|
||||
|
||||
struct Button {
|
||||
|
@ -37,6 +38,8 @@ struct MapPart {
|
|||
int blocktype;
|
||||
};
|
||||
|
||||
MapPart gettedMapParts[MAP_LENGHT + 1];
|
||||
|
||||
HDC block;
|
||||
HDC quest;
|
||||
HDC water;
|
||||
|
@ -55,6 +58,8 @@ bool addingBlock(bool clicked, RECT blockBut, HDC pic,
|
|||
int blocktype, int* arrElem, MapPart mapParts[]);
|
||||
|
||||
int readFile(string file, MapPart gettedMapParts[]);
|
||||
void playGame(MapPart gettedMapParts[]);
|
||||
bool areElemWithTheseCoordsExisting(RECT coords, MapPart mapParts[]);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -91,6 +96,13 @@ int main()
|
|||
|
||||
drawMenu();
|
||||
|
||||
if (lvlCreatingIsStarted) {
|
||||
mainFunc();
|
||||
}
|
||||
else if (gameIsStarted) {
|
||||
playGame(gettedMapParts);
|
||||
}
|
||||
|
||||
txEnd();
|
||||
|
||||
txDeleteDC(block);
|
||||
|
@ -167,6 +179,7 @@ void drawMenu()
|
|||
|
||||
drawButton(buttonStart);
|
||||
drawButton(buttonExit);
|
||||
drawButton(buttonPlay);
|
||||
|
||||
txSetColor(TX_BLACK, 3);
|
||||
txSetFillColor(TX_TRANSPARENT);
|
||||
|
@ -174,18 +187,18 @@ void drawMenu()
|
|||
drawButton(buttonHelp);
|
||||
|
||||
txSleep(50);
|
||||
bool flwindow = false;
|
||||
|
||||
while (!GetAsyncKeyState('Q') || !GetAsyncKeyState(VK_ESCAPE)) {
|
||||
if (!gameIsStarted) {
|
||||
if (!lvlCreatingIsStarted && !gameIsStarted) {
|
||||
if (In(txMousePos(), buttonStart.coords) && txMouseButtons() & 1) {
|
||||
while (txMouseButtons() & 1) {
|
||||
txSleep(10);
|
||||
}
|
||||
|
||||
//loadingAnimation(2, 3);
|
||||
loadingAnimation(2, 3);
|
||||
txSleep(50);
|
||||
mainFunc();
|
||||
|
||||
lvlCreatingIsStarted = true;
|
||||
}
|
||||
if (In(txMousePos(), buttonExit.coords) && txMouseButtons() & 1) {
|
||||
while (txMouseButtons() & 1) {
|
||||
|
@ -223,24 +236,16 @@ void drawMenu()
|
|||
|
||||
if (In(txMousePos(), buttonPlay.coords) && txMouseButtons() & 1) {
|
||||
|
||||
MapPart gettedMapParts[MAP_LENGHT + 1];
|
||||
int arrElem = readFile("level1.fslvl", gettedMapParts);
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
gameIsStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (lvlCreatingIsStarted || gameIsStarted) {
|
||||
break;
|
||||
}
|
||||
|
||||
txSleep(10);
|
||||
}
|
||||
}
|
||||
|
@ -268,8 +273,6 @@ void loadingAnimation(int delay, int speed)
|
|||
|
||||
void mainFunc()
|
||||
{
|
||||
gameIsStarted = true;
|
||||
|
||||
int arrElem = 0;
|
||||
int selectedPict = -1;
|
||||
const int BLOCK_SIZE = 120;
|
||||
|
@ -309,7 +312,7 @@ void mainFunc()
|
|||
bool clickedWater = false;
|
||||
bool clickedFire = false;
|
||||
|
||||
while (!GetAsyncKeyState('Q')) {
|
||||
while (!GetAsyncKeyState('Q') || !GetAsyncKeyState(VK_ESCAPE)) {
|
||||
background(TX_WHITE);
|
||||
|
||||
Win32::TransparentBlt(txDC(), blockBut.left, blockBut.top, 120, 120, block,
|
||||
|
@ -390,17 +393,35 @@ void mainFunc()
|
|||
}
|
||||
}
|
||||
|
||||
//round((mapParts[elem].coords.left + 30) / 60) * 60
|
||||
|
||||
//moving picture
|
||||
RECT oldCoords = mapParts[selectedPict].coords;
|
||||
|
||||
if (selectedPict >= 0 && txMouseButtons() & 1) {
|
||||
txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30,
|
||||
|
||||
txBitBlt(txDC(),
|
||||
txMouseX() - 30, txMouseY() - 30,
|
||||
60, 60, mapParts[selectedPict].picture);
|
||||
}
|
||||
if (selectedPict >= 0 && !(txMouseButtons() & 1)) {
|
||||
mapParts[selectedPict].coords = {
|
||||
txMouseX() - 30, txMouseY() - 30,
|
||||
txMouseX() + 30, txMouseY() + 30
|
||||
|
||||
RECT elRectCoords = {
|
||||
(round((txMouseX() - 30) + 30 / 60) * 60),
|
||||
(round((txMouseY() - 30) + 30 / 60) * 60),
|
||||
(round((txMouseX() + 30) - 30 / 60) * 60),
|
||||
(round((txMouseY() + 30) - 30 / 60) * 60)
|
||||
};
|
||||
selectedPict = -1;
|
||||
|
||||
if (!areElemWithTheseCoordsExisting(elRectCoords, mapParts)) {
|
||||
|
||||
mapParts[selectedPict].coords = elRectCoords;
|
||||
selectedPict = -1;
|
||||
}
|
||||
else {
|
||||
mapParts[selectedPict].coords = oldCoords;
|
||||
selectedPict = -1;
|
||||
}
|
||||
}
|
||||
|
||||
//button to complete LevelCreating
|
||||
|
@ -462,6 +483,10 @@ void mainFunc()
|
|||
}
|
||||
|
||||
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 (txMouseX() < txGetExtentX() - BLOCK_SIZE) {
|
||||
RECT elRectCoords = {
|
||||
|
||||
(round((txMouseX() - 30) + 30 / 60) * 60),
|
||||
(round((txMouseY() - 30) + 30 / 60) * 60),
|
||||
(round((txMouseX() + 30) - 30 / 60) * 60),
|
||||
(round((txMouseY() + 30) - 30 / 60) * 60)
|
||||
};
|
||||
|
||||
if ((txMouseX() < txGetExtentX() - BLOCK_SIZE) &&
|
||||
!(areElemWithTheseCoordsExisting(elRectCoords, mapParts)))
|
||||
{
|
||||
cout << !(areElemWithTheseCoordsExisting(elRectCoords, mapParts)) << endl;
|
||||
|
||||
mapParts[*arrElem] = {
|
||||
{
|
||||
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
|
||||
}, true, pic, blocktype
|
||||
elRectCoords, true, pic, blocktype
|
||||
};
|
||||
|
||||
(*arrElem)++;
|
||||
|
@ -572,3 +606,46 @@ int readFile(string file, MapPart gettedMapParts[])
|
|||
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,120,300,180,360
|
||||
Block,480,240,540,300
|
||||
Block,240,120,300,180
|
||||
Block,120,240,180,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
|
||||
Quest,840,240,900,300
|
||||
Fire,840,300,900,360
|
||||
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
|
||||
Block,900,240,960,300
|
||||
Quest,1080,360,1140,420
|
||||
|
|
Loading…
Add table
Reference in a new issue