Add files via upload

Edited main.cpp
This commit is contained in:
Андрей 2019-10-04 15:32:55 +03:00 committed by GitHub
parent 03477fb0be
commit 5820c4e9cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,10 +1,15 @@
#include <TXLib.h> #include <TXLib.h>
#include <iostream> #include <iostream>
#include <fstream>
using namespace std; 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 QUEST_TYPE = 1;
const int WATER_TYPE = 2;
const int FIRE_TYPE = 3;
int middleX; int middleX;
int middleY; int middleY;
@ -20,6 +25,13 @@ struct Button {
HDC picture; HDC picture;
}; };
struct MapPart {
RECT coords;
bool visible;
HDC picture;
int blocktype;
};
HDC block; HDC block;
HDC quest; HDC quest;
HDC orange_but; HDC orange_but;
@ -146,9 +158,8 @@ void drawMenu()
txSleep(10); txSleep(10);
} }
loadingAnimation(2, 3); //loadingAnimation(2, 3);
txSleep(50); txSleep(50);
//txMessageBox("Çàïóñê èãðû ïîêà ÷òî íå ðàáîòàåò!", "Îøèáêà");
mainFunc(); mainFunc();
} }
if (In(txMousePos(), buttonExit.coords) && txMouseButtons() & 1) { if (In(txMousePos(), buttonExit.coords) && txMouseButtons() & 1) {
@ -183,6 +194,8 @@ void loadingAnimation(int delay, int speed)
circle_radius * circle_radius < extentX * extentX + extentY * extentY; circle_radius * circle_radius < extentX * extentX + extentY * extentY;
circle_radius += speed) { circle_radius += speed) {
background(TX_WHITE);
txSetColor(TX_BLACK, 2); txSetColor(TX_BLACK, 2);
txSetFillColor(TX_BLACK); txSetFillColor(TX_BLACK);
@ -198,6 +211,8 @@ void mainFunc()
{ {
gameIsStarted = true; gameIsStarted = true;
int arrElem = 0;
RECT blockBut = { RECT blockBut = {
extentX - 60, 0, extentX, 60 extentX - 60, 0, extentX, 60
}; };
@ -206,16 +221,34 @@ void mainFunc()
extentX - 60, 60, extentX, 120 extentX - 60, 60, extentX, 120
}; };
RECT doneBut = {
extentX - 60, extentY - 60, extentX, extentY
};
MapPart mapParts[12];
bool clickedBlock = false; bool clickedBlock = false;
bool clickedQuest = false; bool clickedQuest = false;
while(!GetAsyncKeyState('Q')) while (!GetAsyncKeyState('Q')) {
{
background(TX_WHITE); background(TX_WHITE);
txBitBlt(txDC(), extentX - 60, 0, 60, 60, block); txBitBlt(txDC(), extentX - 60, 0, 60, 60, block);
txBitBlt(txDC(), extentX - 60, 60, 60, 60, quest); txBitBlt(txDC(), extentX - 60, 60, 60, 60, quest);
for (int elem = 0; elem < 12; elem++) {
if (mapParts[elem].visible) {
txBitBlt(txDC(),
mapParts[elem].coords.left,
mapParts[elem].coords.top,
60, 60,
mapParts[elem].picture
);
}
}
//block "block" //block "block"
if (In(txMousePos(), blockBut) && txMouseButtons() & 1) { if (In(txMousePos(), blockBut) && txMouseButtons() & 1) {
clickedBlock = true; clickedBlock = true;
@ -223,10 +256,16 @@ void mainFunc()
if (txMouseButtons() & 1 && clickedBlock) { if (txMouseButtons() & 1 && clickedBlock) {
txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30, 60, 60, block); txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30, 60, 60, block);
if (!(txMouseButtons() & 1)) {
txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30, 60, 60, block);
clickedBlock = false;
} }
if (!(txMouseButtons() & 1) && clickedBlock) {
mapParts[arrElem] = {
{
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
}, true, block, BLOCK_TYPE
};
arrElem++;
clickedBlock = false;
} }
//block "quest" //block "quest"
@ -235,11 +274,36 @@ void mainFunc()
} }
if (txMouseButtons() & 1 && clickedQuest) { if (txMouseButtons() & 1 && clickedQuest) {
txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30, 60, 60, quest); txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30, 60, 60, quest);
}
if (!(txMouseButtons() & 1) && clickedQuest) {
mapParts[arrElem] = {
{
txMouseX() - 30, txMouseY() - 30, txMouseX() + 30, txMouseY() + 30
}, true, quest, QUEST_TYPE
};
arrElem++;
if (!(txMouseButtons() & 1)) {
txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30, 60, 60, quest);
clickedQuest = false; clickedQuest = false;
} }
//button to complete LevelCreating
if (In(txMousePos(), doneBut) && txMouseButtons() & 1) {
while (txMouseButtons() & 1) {
txSleep(10);
}
ofstream lvlfile;
lvlfile.open("level1.fslvl");
for (int elem = 0; elem < 12; elem++) {
if (mapParts[elem].visible) {
switch(mapParts[elem].blocktype)
{
case BLOCK_TYPE:
lvlfile << "Block"
}
}
}
} }
txSleep(10); txSleep(10);