Add files via upload

Михаил, помогите пожалуйста! Опять у меня ничего не получается...
Я немножко изменил именно игру. Затем решил разбить код на библиотеки.
Попробуйте скомпилировать, если Вам интересно...

Вылезает ошибка (только в самих библиотеках) - "#include nested too deeply" (или что-то подобное).
На русском звучит как - "include вложены слишком глубоко". Шо делать?..
This commit is contained in:
Андрей 2019-12-07 14:47:15 +03:00 committed by GitHub
parent 7626d5e569
commit 5fbb88820b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 9828 additions and 596 deletions

View file

@ -33,6 +33,10 @@
<Add option="-fexceptions" />
</Compiler>
<Unit filename="FallSimulation.cpp" />
<Unit filename="lib/Consts.h" />
<Unit filename="lib/ElemFunctions.h" />
<Unit filename="lib/ModesFunctions.h" />
<Unit filename="lib/TXLib.h" />
<Extensions>
<code_completion />
<envvars />

View file

@ -1,65 +1,13 @@
#include <TXLib.h>
#include "lib\\Consts.h"
#include "lib\\ElemFunctions.h"
#include "lib\\ModesFunctions.h"
#include <iostream>
#include <fstream>
using namespace std;
const COLORREF MY_LIGHTBLUE = RGB(75, 127, 196);
const COLORREF MY_BISQUE = RGB(255, 214, 89);
const int BLOCK_SIZE = 120;
const int BLOCK_TYPE = 0;
const int QUEST_TYPE = 1;
const int WATER_TYPE = 2;
const int FIRE_TYPE = 3;
const int MAP_LENGHT = 15;
int middleX;
int middleY;
int extentX;
int extentY;
bool lvlCreatingIsStarted = false;
bool gameIsStarted = false;
struct Button {
RECT coords;
const char* text;
HDC picture;
};
struct MapPart {
RECT coords;
bool visible;
HDC picture;
int blocktype;
};
MapPart gettedMapParts[MAP_LENGHT + 1];
HDC block;
HDC quest;
HDC water;
HDC fire;
HDC light_stone;
HDC dark_stone;
HDC vdark_stone;
void background(COLORREF color);
void drawMenu();
void drawButton(Button but);
void loadingAnimation(int delay, int speed);
void mainFunc();
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()
{
@ -123,530 +71,3 @@ void background(COLORREF color)
txClear();
}
void drawButton(Button but)
{
//drawing button
txRectangle(but.coords.left,
but.coords.top,
but.coords.right,
but.coords.bottom);
//drawing text
txDrawText (but.coords.left,
but.coords.top,
but.coords.right,
but.coords.bottom,
but.text,
DT_CENTER | DT_VCENTER);
}
void drawMenu()
{
//button "Start" (to start level creating)
Button buttonStart = {
{
middleX - 100, extentY / 3 - 50,
middleX + 100, extentY / 3 + 50
}, "Start"
};
//button "Exit"
Button buttonExit = {
{
middleX - 100, extentY / 2 - 50,
middleX + 100, extentY / 2 + 50
}, "Exit"
};
//button "Help"
Button buttonHelp = {
{
extentX - 100, 0,
extentX , 50
}, "? Help"
};
//button "Play" (to play on created level)
Button buttonPlay = {
{
extentX - 100, extentY - 60,
extentX, extentY
}, "Play"
};
txSetColor(TX_BLACK, 3);
txSetFillColor(TX_WHITE);
drawButton(buttonStart);
drawButton(buttonExit);
drawButton(buttonPlay);
txSetColor(TX_BLACK, 3);
txSetFillColor(TX_TRANSPARENT);
drawButton(buttonHelp);
txSleep(50);
while (!GetAsyncKeyState('Q') || !GetAsyncKeyState(VK_ESCAPE)) {
if (!lvlCreatingIsStarted && !gameIsStarted) {
if (In(txMousePos(), buttonStart.coords) && txMouseButtons() & 1) {
while (txMouseButtons() & 1) {
txSleep(10);
}
loadingAnimation(2, 7);
txSleep(50);
lvlCreatingIsStarted = true;
}
if (In(txMousePos(), buttonExit.coords) && txMouseButtons() & 1) {
while (txMouseButtons() & 1) {
txSleep(10);
}
break;
}
if (In(txMousePos(), buttonHelp.coords)) {
txSetColor(TX_BLACK);
txDrawText(buttonHelp.coords.left - 130,
buttonHelp.coords.bottom + 10,
txGetExtentX() - 10,
buttonHelp.coords.bottom + 100,
"This hyperlink will be\nopen in browser");
}
else {
txSetColor(TX_WHITE);
txSetFillColor(TX_WHITE);
txRectangle(buttonHelp.coords.left - 130,
buttonHelp.coords.bottom + 10,
txGetExtentX() - 10,
buttonHelp.coords.bottom + 100);
}
if (In(txMousePos(), buttonHelp.coords) && txMouseButtons() & 1) {
while(txMouseButtons() & 1) {
txSleep(10);
}
system("start help\\index.html");
}
if (In(txMousePos(), buttonPlay.coords) && txMouseButtons() & 1) {
int arrElem = readFile("level1.fslvl", gettedMapParts);
gameIsStarted = true;
}
}
if (lvlCreatingIsStarted || gameIsStarted) {
break;
}
txSleep(10);
}
}
void loadingAnimation(int delay, int speed)
{
background(TX_WHITE);
for (int circle_radius = 0;
circle_radius * circle_radius < extentX * extentX + extentY * extentY;
circle_radius += speed) {
background(TX_WHITE);
txSetColor(TX_BLACK, 2);
txSetFillColor(TX_BLACK);
txCircle(0, 0, circle_radius);
txSleep(delay);
}
background(TX_WHITE);
}
void mainFunc()
{
int arrElem = 0;
int selectedPict = -1;
const int BLOCK_SIZE = 120;
RECT blockBut = {
extentX - BLOCK_SIZE, 0, extentX, BLOCK_SIZE
};
RECT questBut = {
extentX - BLOCK_SIZE, BLOCK_SIZE, extentX, 2 * BLOCK_SIZE
};
RECT waterBut = {
extentX - BLOCK_SIZE, 2 * BLOCK_SIZE, extentX, 3 * BLOCK_SIZE
};
RECT fireBut = {
extentX - BLOCK_SIZE, 3* BLOCK_SIZE, extentX, 4 * BLOCK_SIZE
};
RECT doneBut = {
extentX - 120, extentY - 120, extentX, extentY
};
MapPart mapParts[MAP_LENGHT + 1];
txSetColor(TX_BLACK, 3);
txSetFillColor(TX_WHITE);
Button completeButton = {doneBut, "\n\nSave\n\nFile"};
for (int elem = 0; elem < MAP_LENGHT; elem++) {
mapParts[elem].visible = false;
}
bool clickedBlock = false;
bool clickedQuest = false;
bool clickedWater = false;
bool clickedFire = false;
while (!GetAsyncKeyState('Q') || !GetAsyncKeyState(VK_ESCAPE)) {
background(TX_WHITE);
Win32::TransparentBlt(txDC(), blockBut.left, blockBut.top, 120, 120, block,
0, 0, 60, 60, -1);
Win32::TransparentBlt(txDC(), questBut.left, questBut.top, 120, 120, quest,
0, 0, 60, 60, -1);
Win32::TransparentBlt(txDC(), waterBut.left, waterBut.top, 120, 120, water,
0, 0, 60, 60, -1);
Win32::TransparentBlt(txDC(), fireBut.left, fireBut.top, 120, 120, fire,
0, 0, 60, 60, -1);
drawButton(completeButton);
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
);
}
}
//blocks
clickedBlock = addingBlock(clickedBlock, blockBut, block, BLOCK_TYPE, &arrElem, mapParts);
clickedQuest = addingBlock(clickedQuest, questBut, quest, QUEST_TYPE, &arrElem, mapParts);
clickedWater = addingBlock(clickedWater, waterBut, water, WATER_TYPE, &arrElem, mapParts);
clickedFire = addingBlock(clickedFire, fireBut, fire, FIRE_TYPE, &arrElem, mapParts);
//checking
if (clickedBlock)
{
clickedQuest = false;
clickedWater = false;
clickedFire = false;
}
else if (clickedQuest)
{
clickedWater = false;
clickedFire = false;
}
else if (clickedWater)
{
clickedFire = false;
}
//selecting block
for (int i = 0; i < arrElem; i++) {
if (selectedPict < 0 &&
In(txMousePos(), mapParts[i].coords) && txMouseButtons() & 1 &&
!(clickedBlock || clickedQuest || clickedWater || clickedFire)) {
selectedPict = i;
}
}
//deleting picture
for (int i = 0; i < arrElem; i++) {
if (selectedPict < 0 &&
In(txMousePos(), mapParts[i].coords) && txMouseButtons() & 2 &&
!(clickedBlock || clickedQuest || clickedWater || clickedFire)) {
selectedPict = i;
mapParts[selectedPict] = mapParts[arrElem - 1];
mapParts[arrElem - 1].visible = false;
arrElem--;
selectedPict = -1;
}
}
//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,
60, 60, mapParts[selectedPict].picture);
}
if (selectedPict >= 0 && !(txMouseButtons() & 1)) {
RECT elRectCoords = {
(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;
}
else {
mapParts[selectedPict].coords = oldCoords;
selectedPict = -1;
}
}
//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 < arrElem; elem++) {
if (mapParts[elem].visible) {
switch(mapParts[elem].blocktype)
{
case BLOCK_TYPE:
lvlfile << "Block,";
break;
case QUEST_TYPE:
lvlfile << "Quest,";
break;
case WATER_TYPE:
lvlfile << "Water,";
break;
case FIRE_TYPE:
lvlfile << "Fire,";
break;
default:
lvlfile << "Null,";
break;
}
mapParts[elem].coords.left =
round((mapParts[elem].coords.left + 30) / 60) * 60;
mapParts[elem].coords.top =
round((mapParts[elem].coords.top + 30) / 60) * 60;
mapParts[elem].coords.right =
round((mapParts[elem].coords.right + 30) / 60) * 60;
mapParts[elem].coords.bottom =
round((mapParts[elem].coords.bottom + 30) / 60) * 60;
lvlfile << mapParts[elem].coords.left;
lvlfile << ",";
lvlfile << mapParts[elem].coords.top;
lvlfile << ",";
lvlfile << mapParts[elem].coords.right;
lvlfile << ",";
lvlfile << mapParts[elem].coords.bottom;
lvlfile << "\n";
lvlfile << "";
}
}
txMessageBox("Level File created!", "Information");
}
txSleep(10);
if (GetAsyncKeyState('Q') || GetAsyncKeyState(VK_ESCAPE)) {
break;
}
}
}
bool addingBlock(bool clicked, RECT blockBut, HDC pic,
int blocktype, int* arrElem, MapPart mapParts[])
{
if (In(txMousePos(), blockBut) && txMouseButtons() & 1) {
clicked = true;
}
if (txMouseButtons() & 1 && clicked) {
txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30, 60, 60, pic);
}
if (!(txMouseButtons() & 1) && clicked) {
if (*arrElem < MAP_LENGHT) {
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] = {
elRectCoords, true, pic, blocktype
};
(*arrElem)++;
}
}
else {
char maplen_str[50];
sprintf(maplen_str, "You cannot add more than %d blocks", MAP_LENGHT);
txMessageBox(maplen_str, "Error");
(*arrElem)--;
}
clicked = false;
}
return clicked;
}
int readFile(string file, MapPart gettedMapParts[])
{
for (int i = 0; i < MAP_LENGHT; i++) {
gettedMapParts[i].visible = false;
}
int arrElem = 0;
ifstream lvlfile(file);
string buff;
while (lvlfile.good()) {
getline(lvlfile, buff);
if (buff.size() > 5) {
int posComma = buff.find(",");
int posComma2 = buff.find(",", posComma + 1);
int posComma3 = buff.find(",", posComma2 + 1);
int posComma4 = buff.find(",", posComma3 + 1);
string buff1 = buff.substr(0, posComma);
string buff2 = buff.substr(posComma + 1, posComma2 - posComma - 1);
string buff3 = buff.substr(posComma2 + 1, posComma3 - posComma2 - 1);
string buff4 = buff.substr(posComma3 + 1, posComma4 - posComma3 - 1);
string buff5 = buff.substr(posComma4 + 1, buff.size() - posComma4 - 1);
gettedMapParts[arrElem].coords = {
atoi(buff2.c_str()), atoi(buff3.c_str()),
atoi(buff4.c_str()), atoi(buff5.c_str())
};
gettedMapParts[arrElem].visible = true;
if (buff1 == "Block") {
gettedMapParts[arrElem].blocktype = BLOCK_TYPE;
gettedMapParts[arrElem].picture = block;
}
else if (buff1 == "Quest") {
gettedMapParts[arrElem].blocktype = QUEST_TYPE;
gettedMapParts[arrElem].picture = quest;
}
else if (buff1 == "Water") {
gettedMapParts[arrElem].blocktype = WATER_TYPE;
gettedMapParts[arrElem].picture = water;
}
else if (buff1 == "Fire") {
gettedMapParts[arrElem].blocktype = FIRE_TYPE;
gettedMapParts[arrElem].picture = fire;
}
else {
gettedMapParts[arrElem].blocktype = 0;
gettedMapParts[arrElem].visible = false;
}
arrElem++;
}
}
lvlfile.close();
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;
}

View file

@ -1,13 +1,12 @@
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
Block,900,240,960,300
Quest,1080,360,1140,420
Block,120,420,180,480
Block,300,360,360,420
Quest,420,360,480,420
Block,600,300,660,360
Block,720,360,780,420
Block,900,360,960,420
Quest,1080,420,1140,480
Fire,420,420,480,480
Water,840,420,900,480
Water,780,420,840,480
Fire,1020,480,1080,540
Block,480,180,540,240

57
lib/Consts.h Normal file
View file

@ -0,0 +1,57 @@
#include <TXLib.h>
#include "ElemFunctions.h"
#include "ModesFunctions.h"
#pragma once
//This library containing constants, global variables and structures
const COLORREF MY_LIGHTBLUE = RGB(75, 127, 196);
const COLORREF MY_BISQUE = RGB(255, 214, 89);
const COLORREF MY_RED = RGB(237, 28, 36);
const int BLOCK_SIZE = 120;
const int PLAYER_SIZE = BLOCK_SIZE / 5;
const int BLOCK_TYPE = 0;
const int QUEST_TYPE = 1;
const int WATER_TYPE = 2;
const int FIRE_TYPE = 3;
const int MAP_LENGHT = 15;
int middleX;
int middleY;
int extentX;
int extentY;
int arrElem = 0;
bool lvlCreatingIsStarted = false;
bool gameIsStarted = false;
struct Button {
RECT coords;
const char* text;
HDC picture;
};
struct MapPart {
RECT coords;
bool visible;
HDC picture;
int blocktype;
};
MapPart gettedMapParts[MAP_LENGHT + 1];
HDC block;
HDC quest;
HDC water;
HDC fire;
HDC light_stone;
HDC dark_stone;
HDC vdark_stone;

57
lib/Consts.h.save Normal file
View file

@ -0,0 +1,57 @@
#include <TXLib.h>
#include "ElemFunctions.h"
#include "ModesFunctions.h"
#pragma once
//This library containing constants, global variables and structures
const COLORREF MY_LIGHTBLUE = RGB(75, 127, 196);
const COLORREF MY_BISQUE = RGB(255, 214, 89);
const COLORREF MY_RED = RGB(237, 28, 36);
const int BLOCK_SIZE = 120;
const int PLAYER_SIZE = BLOCK_SIZE / 5;
const int BLOCK_TYPE = 0;
const int QUEST_TYPE = 1;
const int WATER_TYPE = 2;
const int FIRE_TYPE = 3;
const int MAP_LENGHT = 15;
int middleX;
int middleY;
int extentX;
int extentY;
int arrElem = 0;
bool lvlCreatingIsStarted = false;
bool gameIsStarted = false;
struct Button {
RECT coords;
const char* text;
HDC picture;
};
struct MapPart {
RECT coords;
bool visible;
HDC picture;
int blocktype;
};
MapPart gettedMapParts[MAP_LENGHT + 1];
HDC block;
HDC quest;
HDC water;
HDC fire;
HDC light_stone;
HDC dark_stone;
HDC vdark_stone;

167
lib/ElemFunctions.h Normal file
View file

@ -0,0 +1,167 @@
#include <TXLib.h>
#include "Consts.h"
#include "ModesFunctions.h"
#include <iostream>
#include <fstream>
#pragma once
//This library containing functions for work with the elements
void drawButton(Button but);
bool addingBlock(bool clicked, RECT blockBut, HDC pic,
int blocktype, int* arrElem, MapPart mapParts[]);
int readFile(string file, MapPart gettedMapParts[]);
void checkElem(MapPart mapParts[]);
void drawButton(Button but)
{
//drawing button
txRectangle(but.coords.left,
but.coords.top,
but.coords.right,
but.coords.bottom);
//drawing text
txDrawText (but.coords.left,
but.coords.top,
but.coords.right,
but.coords.bottom,
but.text,
DT_CENTER | DT_VCENTER);
}
bool addingBlock(bool clicked, RECT blockBut, HDC pic,
int blocktype, int* arrElem, MapPart mapParts[])
{
if (In(txMousePos(), blockBut) && txMouseButtons() & 1) {
clicked = true;
}
if (txMouseButtons() & 1 && clicked) {
txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30, 60, 60, pic);
}
if (!(txMouseButtons() & 1) && clicked) {
if (*arrElem < MAP_LENGHT) {
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)
{
mapParts[*arrElem] = {
elRectCoords, true, pic, blocktype
};
checkElem(mapParts);
(*arrElem)++;
}
}
else {
char maplen_str[50];
sprintf(maplen_str, "You cannot add more than %d blocks", MAP_LENGHT);
txMessageBox(maplen_str, "Error");
(*arrElem)--;
}
clicked = false;
}
return clicked;
}
int readFile(string file, MapPart gettedMapParts[])
{
for (int i = 0; i < MAP_LENGHT; i++) {
gettedMapParts[i].visible = false;
}
int arrElem = 0;
ifstream lvlfile(file);
string buff;
while (lvlfile.good()) {
getline(lvlfile, buff);
if (buff.size() > 5) {
int posComma = buff.find(",");
int posComma2 = buff.find(",", posComma + 1);
int posComma3 = buff.find(",", posComma2 + 1);
int posComma4 = buff.find(",", posComma3 + 1);
string buff1 = buff.substr(0, posComma);
string buff2 = buff.substr(posComma + 1, posComma2 - posComma - 1);
string buff3 = buff.substr(posComma2 + 1, posComma3 - posComma2 - 1);
string buff4 = buff.substr(posComma3 + 1, posComma4 - posComma3 - 1);
string buff5 = buff.substr(posComma4 + 1, buff.size() - posComma4 - 1);
gettedMapParts[arrElem].coords = {
atoi(buff2.c_str()), atoi(buff3.c_str()),
atoi(buff4.c_str()), atoi(buff5.c_str())
};
gettedMapParts[arrElem].visible = true;
if (buff1 == "Block") {
gettedMapParts[arrElem].blocktype = BLOCK_TYPE;
gettedMapParts[arrElem].picture = block;
}
else if (buff1 == "Quest") {
gettedMapParts[arrElem].blocktype = QUEST_TYPE;
gettedMapParts[arrElem].picture = quest;
}
else if (buff1 == "Water") {
gettedMapParts[arrElem].blocktype = WATER_TYPE;
gettedMapParts[arrElem].picture = water;
}
else if (buff1 == "Fire") {
gettedMapParts[arrElem].blocktype = FIRE_TYPE;
gettedMapParts[arrElem].picture = fire;
}
else {
gettedMapParts[arrElem].blocktype = 0;
gettedMapParts[arrElem].visible = false;
}
arrElem++;
}
}
lvlfile.close();
return arrElem;
}
void checkElem(MapPart mapParts[])
{
for (int elem = 0; elem < MAP_LENGHT; elem++) {
for (int elem2 = 0; elem2 < MAP_LENGHT; elem2++) {
if (elem2 != elem &&
mapParts[elem].coords.left == mapParts[elem2].coords.left &&
mapParts[elem].coords.top == mapParts[elem2].coords.top) {
mapParts[elem].coords.left = mapParts[elem].coords.left + 60;
mapParts[elem].coords.right = mapParts[elem].coords.right + 60;
}
}
}
}

167
lib/ElemFunctions.h.save Normal file
View file

@ -0,0 +1,167 @@
#include "TXLib.h"
#include "Consts.h"
#include "ModesFunctions.h"
#include <iostream>
#include <fstream>
#pragma once
//This library containing functions for work with the elements
void drawButton(Button but);
bool addingBlock(bool clicked, RECT blockBut, HDC pic,
int blocktype, int* arrElem, MapPart mapParts[]);
int readFile(string file, MapPart gettedMapParts[]);
void checkElem(MapPart mapParts[]);
void drawButton(Button but)
{
//drawing button
txRectangle(but.coords.left,
but.coords.top,
but.coords.right,
but.coords.bottom);
//drawing text
txDrawText (but.coords.left,
but.coords.top,
but.coords.right,
but.coords.bottom,
but.text,
DT_CENTER | DT_VCENTER);
}
bool addingBlock(bool clicked, RECT blockBut, HDC pic,
int blocktype, int* arrElem, MapPart mapParts[])
{
if (In(txMousePos(), blockBut) && txMouseButtons() & 1) {
clicked = true;
}
if (txMouseButtons() & 1 && clicked) {
txBitBlt(txDC(), txMouseX() - 30, txMouseY() - 30, 60, 60, pic);
}
if (!(txMouseButtons() & 1) && clicked) {
if (*arrElem < MAP_LENGHT) {
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)
{
mapParts[*arrElem] = {
elRectCoords, true, pic, blocktype
};
checkElem(mapParts);
(*arrElem)++;
}
}
else {
char maplen_str[50];
sprintf(maplen_str, "You cannot add more than %d blocks", MAP_LENGHT);
txMessageBox(maplen_str, "Error");
(*arrElem)--;
}
clicked = false;
}
return clicked;
}
int readFile(string file, MapPart gettedMapParts[])
{
for (int i = 0; i < MAP_LENGHT; i++) {
gettedMapParts[i].visible = false;
}
int arrElem = 0;
ifstream lvlfile(file);
string buff;
while (lvlfile.good()) {
getline(lvlfile, buff);
if (buff.size() > 5) {
int posComma = buff.find(",");
int posComma2 = buff.find(",", posComma + 1);
int posComma3 = buff.find(",", posComma2 + 1);
int posComma4 = buff.find(",", posComma3 + 1);
string buff1 = buff.substr(0, posComma);
string buff2 = buff.substr(posComma + 1, posComma2 - posComma - 1);
string buff3 = buff.substr(posComma2 + 1, posComma3 - posComma2 - 1);
string buff4 = buff.substr(posComma3 + 1, posComma4 - posComma3 - 1);
string buff5 = buff.substr(posComma4 + 1, buff.size() - posComma4 - 1);
gettedMapParts[arrElem].coords = {
atoi(buff2.c_str()), atoi(buff3.c_str()),
atoi(buff4.c_str()), atoi(buff5.c_str())
};
gettedMapParts[arrElem].visible = true;
if (buff1 == "Block") {
gettedMapParts[arrElem].blocktype = BLOCK_TYPE;
gettedMapParts[arrElem].picture = block;
}
else if (buff1 == "Quest") {
gettedMapParts[arrElem].blocktype = QUEST_TYPE;
gettedMapParts[arrElem].picture = quest;
}
else if (buff1 == "Water") {
gettedMapParts[arrElem].blocktype = WATER_TYPE;
gettedMapParts[arrElem].picture = water;
}
else if (buff1 == "Fire") {
gettedMapParts[arrElem].blocktype = FIRE_TYPE;
gettedMapParts[arrElem].picture = fire;
}
else {
gettedMapParts[arrElem].blocktype = 0;
gettedMapParts[arrElem].visible = false;
}
arrElem++;
}
}
lvlfile.close();
return arrElem;
}
void checkElem(MapPart mapParts[])
{
for (int elem = 0; elem < MAP_LENGHT; elem++) {
for (int elem2 = 0; elem2 < MAP_LENGHT; elem2++) {
if (elem2 != elem &&
mapParts[elem].coords.left == mapParts[elem2].coords.left &&
mapParts[elem].coords.top == mapParts[elem2].coords.top) {
mapParts[elem].coords.left = mapParts[elem].coords.left + 60;
mapParts[elem].coords.right = mapParts[elem].coords.right + 60;
}
}
}
}

424
lib/ModesFunctions.h Normal file
View file

@ -0,0 +1,424 @@
#include <TXLib.h>
#include "Consts.h"
#include "ElemFunctions.h"
#include <iostream>
#include <fstream>
#pragma once
//This library containing game mode functions
void drawMenu();
void loadingAnimation(int delay, int speed);
void mainFunc();
void playGame(MapPart gettedMapParts[]);
void drawMenu()
{
//button "Start" (to start level creating)
Button buttonStart = {
{
middleX - 100, extentY / 3 - 50,
middleX + 100, extentY / 3 + 50
}, "Start"
};
//button "Exit"
Button buttonExit = {
{
middleX - 100, extentY / 2 - 50,
middleX + 100, extentY / 2 + 50
}, "Exit"
};
//button "Help"
Button buttonHelp = {
{
extentX - 100, 0,
extentX , 50
}, "? Help"
};
//button "Play" (to play on created level)
Button buttonPlay = {
{
extentX - 100, extentY - 60,
extentX, extentY
}, "Play"
};
txSetColor(TX_BLACK, 3);
txSetFillColor(TX_WHITE);
drawButton(buttonStart);
drawButton(buttonExit);
drawButton(buttonPlay);
txSetColor(TX_BLACK, 3);
txSetFillColor(TX_TRANSPARENT);
drawButton(buttonHelp);
txSleep(50);
while (!GetAsyncKeyState('Q') && !GetAsyncKeyState(VK_ESCAPE)) {
if (!lvlCreatingIsStarted && !gameIsStarted) {
if (In(txMousePos(), buttonStart.coords) && txMouseButtons() & 1) {
while (txMouseButtons() & 1) {
txSleep(10);
}
loadingAnimation(2, 7);
txSleep(50);
lvlCreatingIsStarted = true;
}
if (In(txMousePos(), buttonExit.coords) && txMouseButtons() & 1) {
while (txMouseButtons() & 1) {
txSleep(10);
}
break;
}
if (In(txMousePos(), buttonHelp.coords)) {
txSetColor(TX_BLACK);
txDrawText(buttonHelp.coords.left - 130,
buttonHelp.coords.bottom + 10,
txGetExtentX() - 10,
buttonHelp.coords.bottom + 100,
"This hyperlink will be\nopen in browser");
}
else {
txSetColor(TX_WHITE);
txSetFillColor(TX_WHITE);
txRectangle(buttonHelp.coords.left - 130,
buttonHelp.coords.bottom + 10,
txGetExtentX() - 10,
buttonHelp.coords.bottom + 100);
}
if (In(txMousePos(), buttonHelp.coords) && txMouseButtons() & 1) {
while(txMouseButtons() & 1) {
txSleep(10);
}
system("start help\\index.html");
}
if (In(txMousePos(), buttonPlay.coords) && txMouseButtons() & 1) {
int arrElem = readFile("level1.fslvl", gettedMapParts);
gameIsStarted = true;
}
}
if (lvlCreatingIsStarted || gameIsStarted) {
break;
}
txSleep(10);
}
}
void loadingAnimation(int delay, int speed)
{
background(TX_WHITE);
for (int circle_radius = 0;
circle_radius * circle_radius < extentX * extentX + extentY * extentY;
circle_radius += speed) {
background(TX_WHITE);
txSetColor(TX_BLACK, 2);
txSetFillColor(TX_BLACK);
txCircle(0, 0, circle_radius);
txSleep(delay);
}
background(TX_WHITE);
}
void mainFunc()
{
int selectedPict = -1;
const int BLOCK_SIZE = 120;
RECT blockBut = {
extentX - BLOCK_SIZE, 0, extentX, BLOCK_SIZE
};
RECT questBut = {
extentX - BLOCK_SIZE, BLOCK_SIZE, extentX, 2 * BLOCK_SIZE
};
RECT waterBut = {
extentX - BLOCK_SIZE, 2 * BLOCK_SIZE, extentX, 3 * BLOCK_SIZE
};
RECT fireBut = {
extentX - BLOCK_SIZE, 3* BLOCK_SIZE, extentX, 4 * BLOCK_SIZE
};
RECT doneBut = {
extentX - 120, extentY - 120, extentX, extentY
};
MapPart mapParts[MAP_LENGHT + 1];
txSetColor(TX_BLACK, 3);
txSetFillColor(TX_WHITE);
Button completeButton = {doneBut, "\n\nSave\n\nFile"};
for (int elem = 0; elem < MAP_LENGHT; elem++) {
mapParts[elem].visible = false;
}
bool clickedBlock = false;
bool clickedQuest = false;
bool clickedWater = false;
bool clickedFire = false;
while (!GetAsyncKeyState('Q') || !GetAsyncKeyState(VK_ESCAPE)) {
background(TX_WHITE);
Win32::TransparentBlt(txDC(), blockBut.left, blockBut.top, 120, 120, block,
0, 0, 60, 60, -1);
Win32::TransparentBlt(txDC(), questBut.left, questBut.top, 120, 120, quest,
0, 0, 60, 60, -1);
Win32::TransparentBlt(txDC(), waterBut.left, waterBut.top, 120, 120, water,
0, 0, 60, 60, -1);
Win32::TransparentBlt(txDC(), fireBut.left, fireBut.top, 120, 120, fire,
0, 0, 60, 60, -1);
drawButton(completeButton);
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
);
}
}
//blocks
clickedBlock = addingBlock(clickedBlock, blockBut, block, BLOCK_TYPE, &arrElem, mapParts);
clickedQuest = addingBlock(clickedQuest, questBut, quest, QUEST_TYPE, &arrElem, mapParts);
clickedWater = addingBlock(clickedWater, waterBut, water, WATER_TYPE, &arrElem, mapParts);
clickedFire = addingBlock(clickedFire, fireBut, fire, FIRE_TYPE, &arrElem, mapParts);
//checking
if (clickedBlock)
{
clickedQuest = false;
clickedWater = false;
clickedFire = false;
}
else if (clickedQuest)
{
clickedWater = false;
clickedFire = false;
}
else if (clickedWater)
{
clickedFire = false;
}
//selecting block
for (int i = 0; i < arrElem; i++) {
if (selectedPict < 0 &&
In(txMousePos(), mapParts[i].coords) && txMouseButtons() & 1 &&
!(clickedBlock || clickedQuest || clickedWater || clickedFire)) {
selectedPict = i;
}
}
//deleting picture
for (int i = 0; i < arrElem; i++) {
if (selectedPict < 0 &&
In(txMousePos(), mapParts[i].coords) && txMouseButtons() & 2 &&
!(clickedBlock || clickedQuest || clickedWater || clickedFire)) {
selectedPict = i;
mapParts[selectedPict] = mapParts[arrElem - 1];
mapParts[arrElem - 1].visible = false;
arrElem--;
selectedPict = -1;
}
}
//moving picture
if (selectedPict >= 0 && txMouseButtons() & 1) {
txBitBlt(txDC(),
txMouseX() - 30, txMouseY() - 30,
60, 60, mapParts[selectedPict].picture);
}
if (selectedPict >= 0 && !(txMouseButtons() & 1)) {
RECT elRectCoords = {
(round((txMouseX() - 30) / 60) * 60),
(round((txMouseY() - 30) / 60) * 60),
(round((txMouseX() + 30) / 60) * 60),
(round((txMouseY() + 30) / 60) * 60)
};
mapParts[selectedPict].coords = elRectCoords;
checkElem(mapParts);
selectedPict = -1;
}
//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 < arrElem; elem++) {
if (mapParts[elem].visible) {
switch(mapParts[elem].blocktype)
{
case BLOCK_TYPE:
lvlfile << "Block,";
break;
case QUEST_TYPE:
lvlfile << "Quest,";
break;
case WATER_TYPE:
lvlfile << "Water,";
break;
case FIRE_TYPE:
lvlfile << "Fire,";
break;
default:
lvlfile << "Null,";
break;
}
mapParts[elem].coords.left =
round((mapParts[elem].coords.left + 30) / 60) * 60;
mapParts[elem].coords.top =
round((mapParts[elem].coords.top + 30) / 60) * 60;
mapParts[elem].coords.right =
round((mapParts[elem].coords.right + 30) / 60) * 60;
mapParts[elem].coords.bottom =
round((mapParts[elem].coords.bottom + 30) / 60) * 60;
lvlfile << mapParts[elem].coords.left;
lvlfile << ",";
lvlfile << mapParts[elem].coords.top;
lvlfile << ",";
lvlfile << mapParts[elem].coords.right;
lvlfile << ",";
lvlfile << mapParts[elem].coords.bottom;
lvlfile << "\n";
lvlfile << "";
}
}
txMessageBox("Level File created!", "Information");
}
txSleep(10);
if (GetAsyncKeyState('Q') || GetAsyncKeyState(VK_ESCAPE)) {
break;
}
}
}
void playGame(MapPart gettedMapParts[])
{
int minX = gettedMapParts[0].coords.left;
int iMin = 0;
for (int i = 0; i < arrElem; i++) {
if (gettedMapParts[i].coords.left < minX)
{
minX = gettedMapParts[i].coords.left;
iMin = i;
}
}
int player_x = gettedMapParts[iMin].coords.left;
int player_y = gettedMapParts[iMin].coords.top - (PLAYER_SIZE + 5);
int player_speed = PLAYER_SIZE;
while (!GetAsyncKeyState('Q') && !GetAsyncKeyState(VK_ESCAPE)) {
background(TX_WHITE);
txSetColor(MY_RED, 3);
txSetFillColor(MY_RED);
txRectangle(player_x,
player_y,
player_x + PLAYER_SIZE,
player_y + PLAYER_SIZE);
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
);
}
}
if (GetAsyncKeyState('W') || GetAsyncKeyState(VK_UP)) {
player_y -= player_speed;
}
if (GetAsyncKeyState('A') || GetAsyncKeyState(VK_LEFT)) {
player_x -= player_speed;
}
if (GetAsyncKeyState('S') || GetAsyncKeyState(VK_DOWN)) {
player_y += player_speed;
}
if (GetAsyncKeyState('D') || GetAsyncKeyState(VK_RIGHT)) {
player_x += player_speed;
}
if (GetAsyncKeyState(VK_OEM_PLUS)) {
player_speed += BLOCK_SIZE / 10;
}
if (GetAsyncKeyState(VK_OEM_MINUS)) {
player_speed -= BLOCK_SIZE / 10;
}
txSleep(50);
}
}

424
lib/ModesFunctions.h.save Normal file
View file

@ -0,0 +1,424 @@
#include "TXLib.h"
#include "lib\\Consts.h"
#include "lib\\ElemFunctions.h"
#include <iostream>
#include <fstream>
#pragma once
//This library containing game mode functions
void drawMenu();
void loadingAnimation(int delay, int speed);
void mainFunc();
void playGame(MapPart gettedMapParts[]);
void drawMenu()
{
//button "Start" (to start level creating)
Button buttonStart = {
{
middleX - 100, extentY / 3 - 50,
middleX + 100, extentY / 3 + 50
}, "Start"
};
//button "Exit"
Button buttonExit = {
{
middleX - 100, extentY / 2 - 50,
middleX + 100, extentY / 2 + 50
}, "Exit"
};
//button "Help"
Button buttonHelp = {
{
extentX - 100, 0,
extentX , 50
}, "? Help"
};
//button "Play" (to play on created level)
Button buttonPlay = {
{
extentX - 100, extentY - 60,
extentX, extentY
}, "Play"
};
txSetColor(TX_BLACK, 3);
txSetFillColor(TX_WHITE);
drawButton(buttonStart);
drawButton(buttonExit);
drawButton(buttonPlay);
txSetColor(TX_BLACK, 3);
txSetFillColor(TX_TRANSPARENT);
drawButton(buttonHelp);
txSleep(50);
while (!GetAsyncKeyState('Q') && !GetAsyncKeyState(VK_ESCAPE)) {
if (!lvlCreatingIsStarted && !gameIsStarted) {
if (In(txMousePos(), buttonStart.coords) && txMouseButtons() & 1) {
while (txMouseButtons() & 1) {
txSleep(10);
}
loadingAnimation(2, 7);
txSleep(50);
lvlCreatingIsStarted = true;
}
if (In(txMousePos(), buttonExit.coords) && txMouseButtons() & 1) {
while (txMouseButtons() & 1) {
txSleep(10);
}
break;
}
if (In(txMousePos(), buttonHelp.coords)) {
txSetColor(TX_BLACK);
txDrawText(buttonHelp.coords.left - 130,
buttonHelp.coords.bottom + 10,
txGetExtentX() - 10,
buttonHelp.coords.bottom + 100,
"This hyperlink will be\nopen in browser");
}
else {
txSetColor(TX_WHITE);
txSetFillColor(TX_WHITE);
txRectangle(buttonHelp.coords.left - 130,
buttonHelp.coords.bottom + 10,
txGetExtentX() - 10,
buttonHelp.coords.bottom + 100);
}
if (In(txMousePos(), buttonHelp.coords) && txMouseButtons() & 1) {
while(txMouseButtons() & 1) {
txSleep(10);
}
system("start help\\index.html");
}
if (In(txMousePos(), buttonPlay.coords) && txMouseButtons() & 1) {
int arrElem = readFile("level1.fslvl", gettedMapParts);
gameIsStarted = true;
}
}
if (lvlCreatingIsStarted || gameIsStarted) {
break;
}
txSleep(10);
}
}
void loadingAnimation(int delay, int speed)
{
background(TX_WHITE);
for (int circle_radius = 0;
circle_radius * circle_radius < extentX * extentX + extentY * extentY;
circle_radius += speed) {
background(TX_WHITE);
txSetColor(TX_BLACK, 2);
txSetFillColor(TX_BLACK);
txCircle(0, 0, circle_radius);
txSleep(delay);
}
background(TX_WHITE);
}
void mainFunc()
{
int selectedPict = -1;
const int BLOCK_SIZE = 120;
RECT blockBut = {
extentX - BLOCK_SIZE, 0, extentX, BLOCK_SIZE
};
RECT questBut = {
extentX - BLOCK_SIZE, BLOCK_SIZE, extentX, 2 * BLOCK_SIZE
};
RECT waterBut = {
extentX - BLOCK_SIZE, 2 * BLOCK_SIZE, extentX, 3 * BLOCK_SIZE
};
RECT fireBut = {
extentX - BLOCK_SIZE, 3* BLOCK_SIZE, extentX, 4 * BLOCK_SIZE
};
RECT doneBut = {
extentX - 120, extentY - 120, extentX, extentY
};
MapPart mapParts[MAP_LENGHT + 1];
txSetColor(TX_BLACK, 3);
txSetFillColor(TX_WHITE);
Button completeButton = {doneBut, "\n\nSave\n\nFile"};
for (int elem = 0; elem < MAP_LENGHT; elem++) {
mapParts[elem].visible = false;
}
bool clickedBlock = false;
bool clickedQuest = false;
bool clickedWater = false;
bool clickedFire = false;
while (!GetAsyncKeyState('Q') || !GetAsyncKeyState(VK_ESCAPE)) {
background(TX_WHITE);
Win32::TransparentBlt(txDC(), blockBut.left, blockBut.top, 120, 120, block,
0, 0, 60, 60, -1);
Win32::TransparentBlt(txDC(), questBut.left, questBut.top, 120, 120, quest,
0, 0, 60, 60, -1);
Win32::TransparentBlt(txDC(), waterBut.left, waterBut.top, 120, 120, water,
0, 0, 60, 60, -1);
Win32::TransparentBlt(txDC(), fireBut.left, fireBut.top, 120, 120, fire,
0, 0, 60, 60, -1);
drawButton(completeButton);
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
);
}
}
//blocks
clickedBlock = addingBlock(clickedBlock, blockBut, block, BLOCK_TYPE, &arrElem, mapParts);
clickedQuest = addingBlock(clickedQuest, questBut, quest, QUEST_TYPE, &arrElem, mapParts);
clickedWater = addingBlock(clickedWater, waterBut, water, WATER_TYPE, &arrElem, mapParts);
clickedFire = addingBlock(clickedFire, fireBut, fire, FIRE_TYPE, &arrElem, mapParts);
//checking
if (clickedBlock)
{
clickedQuest = false;
clickedWater = false;
clickedFire = false;
}
else if (clickedQuest)
{
clickedWater = false;
clickedFire = false;
}
else if (clickedWater)
{
clickedFire = false;
}
//selecting block
for (int i = 0; i < arrElem; i++) {
if (selectedPict < 0 &&
In(txMousePos(), mapParts[i].coords) && txMouseButtons() & 1 &&
!(clickedBlock || clickedQuest || clickedWater || clickedFire)) {
selectedPict = i;
}
}
//deleting picture
for (int i = 0; i < arrElem; i++) {
if (selectedPict < 0 &&
In(txMousePos(), mapParts[i].coords) && txMouseButtons() & 2 &&
!(clickedBlock || clickedQuest || clickedWater || clickedFire)) {
selectedPict = i;
mapParts[selectedPict] = mapParts[arrElem - 1];
mapParts[arrElem - 1].visible = false;
arrElem--;
selectedPict = -1;
}
}
//moving picture
if (selectedPict >= 0 && txMouseButtons() & 1) {
txBitBlt(txDC(),
txMouseX() - 30, txMouseY() - 30,
60, 60, mapParts[selectedPict].picture);
}
if (selectedPict >= 0 && !(txMouseButtons() & 1)) {
RECT elRectCoords = {
(round((txMouseX() - 30) / 60) * 60),
(round((txMouseY() - 30) / 60) * 60),
(round((txMouseX() + 30) / 60) * 60),
(round((txMouseY() + 30) / 60) * 60)
};
mapParts[selectedPict].coords = elRectCoords;
checkElem(mapParts);
selectedPict = -1;
}
//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 < arrElem; elem++) {
if (mapParts[elem].visible) {
switch(mapParts[elem].blocktype)
{
case BLOCK_TYPE:
lvlfile << "Block,";
break;
case QUEST_TYPE:
lvlfile << "Quest,";
break;
case WATER_TYPE:
lvlfile << "Water,";
break;
case FIRE_TYPE:
lvlfile << "Fire,";
break;
default:
lvlfile << "Null,";
break;
}
mapParts[elem].coords.left =
round((mapParts[elem].coords.left + 30) / 60) * 60;
mapParts[elem].coords.top =
round((mapParts[elem].coords.top + 30) / 60) * 60;
mapParts[elem].coords.right =
round((mapParts[elem].coords.right + 30) / 60) * 60;
mapParts[elem].coords.bottom =
round((mapParts[elem].coords.bottom + 30) / 60) * 60;
lvlfile << mapParts[elem].coords.left;
lvlfile << ",";
lvlfile << mapParts[elem].coords.top;
lvlfile << ",";
lvlfile << mapParts[elem].coords.right;
lvlfile << ",";
lvlfile << mapParts[elem].coords.bottom;
lvlfile << "\n";
lvlfile << "";
}
}
txMessageBox("Level File created!", "Information");
}
txSleep(10);
if (GetAsyncKeyState('Q') || GetAsyncKeyState(VK_ESCAPE)) {
break;
}
}
}
void playGame(MapPart gettedMapParts[])
{
int minX = gettedMapParts[0].coords.left;
int iMin = 0;
for (int i = 0; i < arrElem; i++) {
if (gettedMapParts[i].coords.left < minX)
{
minX = gettedMapParts[i].coords.left;
iMin = i;
}
}
int player_x = gettedMapParts[iMin].coords.left;
int player_y = gettedMapParts[iMin].coords.top - (PLAYER_SIZE + 5);
int player_speed = PLAYER_SIZE;
while (!GetAsyncKeyState('Q') && !GetAsyncKeyState(VK_ESCAPE)) {
background(TX_WHITE);
txSetColor(MY_RED, 3);
txSetFillColor(MY_RED);
txRectangle(player_x,
player_y,
player_x + PLAYER_SIZE,
player_y + PLAYER_SIZE);
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
);
}
}
if (GetAsyncKeyState('W') || GetAsyncKeyState(VK_UP)) {
player_y -= player_speed;
}
if (GetAsyncKeyState('A') || GetAsyncKeyState(VK_LEFT)) {
player_x -= player_speed;
}
if (GetAsyncKeyState('S') || GetAsyncKeyState(VK_DOWN)) {
player_y += player_speed;
}
if (GetAsyncKeyState('D') || GetAsyncKeyState(VK_RIGHT)) {
player_x += player_speed;
}
if (GetAsyncKeyState(VK_OEM_PLUS)) {
player_speed += BLOCK_SIZE / 10;
}
if (GetAsyncKeyState(VK_OEM_MINUS)) {
player_speed -= BLOCK_SIZE / 10;
}
txSleep(50);
}
}

8499
lib/TXLib.h Normal file

File diff suppressed because it is too large Load diff

13
mylvl.fslvl Normal file
View file

@ -0,0 +1,13 @@
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
Block,900,240,960,300
Quest,1080,360,1140,420