avatar_Mr.Kernighan

Mu Online: Как начать игру и сыграть в SimpleRPG на консоли

Автор Mr.Kernighan, 2012 Сен. 14, 15:29

« назад - далее »

0 Пользователи и 1 гость просматривают эту тему.

Ключевые слова [SEO] mu onlinesimplerpgконсоль

Mr.Kernighan

Как играть?
1) Распаковать и запустить SimpleRpg.exe и папку Data тоже
2) Кнопки управления на стрелках
3) Пробел использовать супер удар (каждый 20-ый уровень игрок получает усовершенствованный супер удар)

Примечание:
Не работает на X64

Смысл игры
1) Убить 60 монстров

Ссылки для скачивания
https://rghost.ru/40358308

ОУ.ВАЙТЕ! :D

Profesor08

1 - Can't play Music01.mp3
2 - Дальше ничего. Любой ввод - закрытие программы.

Mr.Kernighan

Папку Data положи рядом с *.exe

Profesor08

#3
Ээээ папку Дата лежит рядос с ехе..

[SimpleRPG]
Data
SimpleRPG.exe
SimpleRPG.pdb

N.Art


dn0

Тоже эта ошибка.
Windows XP SP3

Ember

Всё работает, до 19 уровня дошел.

Santyaga

Цитата: Profesor08 от 2012 Сен. 14, 16:18  1 - Can't play Music01.mp3
2 - Дальше ничего. Любой ввод - закрытие программы.
тоже самое...

Sweng

#8
Работает на W7 x64  

NZK

#9
епать  *censored*ня  

кодер, а таким страдать  

TiTANiUM


Profesor08

вот если бы сурс выложил бы.

Mr.Kernighan

#pragma once

#define CHECK_MAP_RANGE(x, y) (x >= 0 && x < TX - 1 && y >= 0 && y < TY - 1)

//--------------------------------------------------

namespace DIR
{
enum
{
WEST   = 0,
NORTH  = 1,
EAST   = 2,
SOURTH = 3,
};
};

namespace MAP_ATTR
{
enum
{
TERRAIN   = '#',
QUEST = '$',
PLAYER = 'P',
MONSTER   = 'M',
EMPTY = ' ',
PLAYER_SKILL  = '*',
MONSTER_SKILL = '+'
};
};

const int TX = 15, TY = 25;

char Terrain[TX][TY] =
{
"########################",
"#  #",
"#####  #",
"#   #  #",
"#   #  #",
"#   #####  #",
"#   #  #",
"# ###  #",
"#  ######  #",
"#  #   #",
"#  #   #",
"#########  #   #",
"#  #   #",
"#  #   #",
"########################",
};

class CSimpleRpg
{
public:
CSimpleRpg(); virtual ~CSimpleRpg();

static CSimpleRpg *GetInstance();

static unsigned __stdcall RenderingThread(LPVOID lpParam);

static unsigned __stdcall ObjAttackThread(LPVOID lpParam);

static unsigned __stdcall ObjTarAttackThread(LPVOID lpParam);

void RenderingScene();

private:
int iObjTar; int iQuest; int iLevel;
bool b_ObjAttackThreadActivity;

//-------------------------

bool GetCurObjMapCrd(int& x, int& y, char object);
void ClrCurObjMapCrd(int x, int y, char object);
void SetNewObjMapCrd(int x, int y, char object);
bool CheckPolySurrObj(int x, int y, int dir);

bool PlayMusic(char *szName);

//-------------------------

void ObjAttack(int x, int y);
void ObjClrAttack(char object, char replace);

//-------------------------

bool ObjTarAttack();
void ObjTarClrAttack(char object, char replace);
static unsigned __stdcall ObjTarRespawn(LPVOID lpParam);

//-------------------------

protected:

};

#define g_pSimpleRpg CSimpleRpg::GetInstance()

void MsgBox(char *szMsg, ...);

//--------------------------------------------------

#include "StdAfx.h"

#include "SimpleRpg.h"

#include <iostream>

struct _tagCHARACTER_DATA
{
int X;
int Y;
int iSkillInUse;
};

CSimpleRpg::CSimpleRpg()
{
this->iObjTar = 0; this->iQuest = 0; this->iLevel = 0;

this->b_ObjAttackThreadActivity = 0;

Terrain[13][22] = MAP_ATTR::PLAYER;

unsigned int x, newx; unsigned int y, newy; int iCount = 0;

srand(time(0));

while (true)
{
newx = rand() % 9; newy = rand() % 19;

if (Terrain[newx][newy] != MAP_ATTR::TERRAIN)
{
Terrain[newx][newy] = MAP_ATTR::QUEST; ++iCount;
}

if (iCount >= 3)
break;
}
};

CSimpleRpg::~CSimpleRpg()
{
};

CSimpleRpg *CSimpleRpg::GetInstance()
{
static CSimpleRpg pInstance; return &pInstance;
};

//--------------------------------------------------

unsigned __stdcall CSimpleRpg::RenderingThread(LPVOID lpParam)
{
HANDLE hProcess;
unsigned int ProcessID;

int x; int y;

if (!g_pSimpleRpg->GetCurObjMapCrd(x, y, MAP_ATTR::PLAYER))
{
MessageBoxA(NULL, "Can't found player on map.", "Error", MB_ICONERROR);
_endthreadex(0); return 0;
}

hProcess = (HANDLE)_beginthreadex(NULL, 0, g_pSimpleRpg->ObjTarRespawn, NULL, 0, &ProcessID);
CloseHandle(hProcess);

if (!g_pSimpleRpg->PlayMusic("\Data\Music\Music01.mp3"))
{
MessageBoxA(NULL, "Can't play Music01.mp3.", "Error", MB_ICONERROR);
_endthreadex(0); return 0;
}

while (true)
{
system("CLS");

g_pSimpleRpg->RenderingScene();

printf("n Your current position [x:%d][y:%d]n", x, y);
printf("n - You killed [%d] monstern", g_pSimpleRpg->iObjTar);
printf(" - You collected [%d] questn", g_pSimpleRpg->iQuest);
printf(" - Your have reached [%d] level", g_pSimpleRpg->iLevel);

if (GetAsyncKeyState(VK_LEFT))
{
if (g_pSimpleRpg->CheckPolySurrObj(x, y, DIR::WEST))
{
g_pSimpleRpg->ClrCurObjMapCrd(x, y, MAP_ATTR::PLAYER); g_pSimpleRpg->SetNewObjMapCrd(x, --y, MAP_ATTR::PLAYER);
}
}

if (GetAsyncKeyState(VK_UP))
{
if (g_pSimpleRpg->CheckPolySurrObj(x, y, DIR::NORTH))
{
g_pSimpleRpg->ClrCurObjMapCrd(x, y, MAP_ATTR::PLAYER); g_pSimpleRpg->SetNewObjMapCrd(--x, y, MAP_ATTR::PLAYER);
}
};

if (GetAsyncKeyState(VK_RIGHT))
{
if (g_pSimpleRpg->CheckPolySurrObj(x, y, DIR::EAST))
{
g_pSimpleRpg->ClrCurObjMapCrd(x, y, MAP_ATTR::PLAYER); g_pSimpleRpg->SetNewObjMapCrd(x, ++y, MAP_ATTR::PLAYER);
}
}

if (GetAsyncKeyState(VK_DOWN))
{
if (g_pSimpleRpg->CheckPolySurrObj(x, y, DIR::SOURTH))
{
g_pSimpleRpg->ClrCurObjMapCrd(x, y, MAP_ATTR::PLAYER); g_pSimpleRpg->SetNewObjMapCrd(++x, y, MAP_ATTR::PLAYER);
}
}

if (GetAsyncKeyState(VK_SPACE))
{
if (!g_pSimpleRpg->PlayMusic("\Data\Sound\Attack.wav"))
{
MessageBoxA(NULL, "Can't play Attack.wav.", "Error", MB_ICONERROR);
_endthreadex(0); return 0;
}

_tagCHARACTER_DATA pCharData;
pCharData.X = x; pCharData.Y = y;
pCharData.iSkillInUse = TRUE;
hProcess = (HANDLE)_beginthreadex(NULL, 0, g_pSimpleRpg->ObjAttackThread, &pCharData, 0, &ProcessID);
CloseHandle(hProcess);
}

if (GetAsyncKeyState(VK_ESCAPE))
{
_endthreadex(0); return 0;
}

Sleep(75);

if (!g_pSimpleRpg->b_ObjAttackThreadActivity)
{
hProcess = (HANDLE)_beginthreadex(NULL, 0, g_pSimpleRpg->ObjTarAttackThread, NULL, 0, &ProcessID);
CloseHandle(hProcess);
}
}
}

unsigned __stdcall CSimpleRpg::ObjAttackThread(LPVOID lpParam)
{
_tagCHARACTER_DATA *pCharData = static_cast<_tagCHARACTER_DATA*>(lpParam);

while (true)
{
if (pCharData->iSkillInUse)
{
g_pSimpleRpg->ObjAttack(pCharData->X, pCharData->Y); pCharData->iSkillInUse = 0;
}

Sleep(150);

g_pSimpleRpg->ObjClrAttack(MAP_ATTR::PLAYER_SKILL, MAP_ATTR::EMPTY);

_endthreadex(0); return 0;
}
};

unsigned __stdcall CSimpleRpg::ObjTarAttackThread(LPVOID lpParam)
{
while (true)
{
if (!g_pSimpleRpg->ObjTarAttack())
{
::ExitProcess(0);
}

Sleep(150); // Скорость выстрела

g_pSimpleRpg->ObjClrAttack(MAP_ATTR::MONSTER_SKILL, MAP_ATTR::EMPTY);

Sleep(3000); // Задержка выстрела
}
};

//--------------------------------------------------

void CSimpleRpg::RenderingScene()
{
for (int x = 0; x < TX; x++) std::cout << Terrain[x] << std::endl;
};

//--------------------------------------------------

bool CSimpleRpg::GetCurObjMapCrd(int& x, int& y, char object)
{
for (int i = 0; i < TX; i++)
{
for (int j = 0; j < TY; j++)
{
if (Terrain[i][j] == object)
{
x = i;

y = j;

return true;
}
}
}
return false;
}

void CSimpleRpg::ClrCurObjMapCrd(int x, int y, char object)
{
Terrain[x][y] = MAP_ATTR::EMPTY;
};

void CSimpleRpg::SetNewObjMapCrd(int x, int y, char object)
{
if (!this->GetCurObjMapCrd(x, y, MAP_ATTR::PLAYER))
Terrain[x][y] = object;
};

bool CSimpleRpg::CheckPolySurrObj(int x, int y, int dir)
{
switch (dir)
{
case DIR::WEST:

if (Terrain[x][y - 1] == MAP_ATTR::QUEST)
{
this->PlayMusic("\Data\Sound\Bonus.wav"); this->iQuest++;
}

if (Terrain[x][y - 1] == MAP_ATTR::MONSTER)
{
MessageBoxA(NULL, "You lose.", "Msg", MB_OK); _endthreadex(0); return false;
}

if (Terrain[x][y - 1] == MAP_ATTR::TERRAIN) return false;

if (Terrain[x][y - 1] == MAP_ATTR::TERRAIN && Terrain[x][y - 2] == MAP_ATTR::EMPTY) return false;
break;

case DIR::NORTH:
if (Terrain[x - 1][y] == MAP_ATTR::QUEST)
{
this->PlayMusic("\Data\Sound\Bonus.wav"); this->iQuest++;
}

if (Terrain[x - 1][y] == MAP_ATTR::MONSTER)
{
MessageBoxA(NULL, "You lose.", "Msg", MB_OK); _endthreadex(0); return false;
}

if (Terrain[x - 1][y] == MAP_ATTR::TERRAIN) return false;

if (Terrain[x - 1][y] == MAP_ATTR::TERRAIN && Terrain[x - 2][y] == MAP_ATTR::EMPTY) return false;
break;

case DIR::EAST:
if (Terrain[x][y + 1] == MAP_ATTR::QUEST)
{
this->PlayMusic("\Data\Sound\Bonus.wav"); this->iQuest++;
}

if (Terrain[x][y + 1] == MAP_ATTR::MONSTER)
{
MessageBoxA(NULL, "You lose.", "Msg", MB_OK); _endthreadex(0); return false;
}

if (Terrain[x][y + 1] == MAP_ATTR::TERRAIN) return false;

if (Terrain[x][y + 1] == MAP_ATTR::TERRAIN && Terrain[x][y + 2] == MAP_ATTR::EMPTY) return false;
break;

case DIR::SOURTH:
if (Terrain[x][y - 1] == MAP_ATTR::QUEST)
{
this->PlayMusic("\Data\Sound\Bonus.wav"); this->iQuest++;
}

if (Terrain[x][y - 1] == MAP_ATTR::MONSTER)
{
MessageBoxA(NULL, "You lose.", "Msg", MB_OK); _endthreadex(0); return false;
}

if (Terrain[x + 1][y] == MAP_ATTR::TERRAIN) return false;

if (Terrain[x + 1][y] == MAP_ATTR::TERRAIN && Terrain[x + 2][y] == MAP_ATTR::EMPTY) return false;
break;

default:
break;
}

return true;
}

bool CSimpleRpg::PlayMusic(char *szName)
{
DWORD nBufferLenght = 2048;
char szTemp[2048]; char szBuffer[2048];

if (!GetCurrentDirectory(nBufferLenght, szTemp)) return false;

strcat(szTemp, szName);
strcpy(szBuffer, "play ");
strcat(szBuffer, szTemp);

if (mciSendString(szBuffer, NULL, 0, NULL)) return false;

return true;
};

//--------------------------------------------------

void CSimpleRpg::ObjAttack(int x, int y)
{
switch (this->iLevel)
{
case 0:

//----------------------------------------

if (Terrain[x - 1][y] == MAP_ATTR::EMPTY) Terrain[x - 1][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 1][y] == MAP_ATTR::MONSTER) { Terrain[x - 1][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 1][y + 1] == MAP_ATTR::EMPTY) Terrain[x - 1][y + 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 1][y + 1] == MAP_ATTR::MONSTER) { Terrain[x - 1][y + 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y + 1] == MAP_ATTR::EMPTY) Terrain[x][y + 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y + 1] == MAP_ATTR::MONSTER) { Terrain[x][y + 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 1][y + 1] == MAP_ATTR::EMPTY) Terrain[x + 1][y + 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 1][y + 1] == MAP_ATTR::MONSTER) { Terrain[x + 1][y + 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 1][y] == MAP_ATTR::EMPTY) Terrain[x + 1][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 1][y] == MAP_ATTR::MONSTER) { Terrain[x + 1][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 1][y - 1] == MAP_ATTR::EMPTY) Terrain[x + 1][y - 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 1][y - 1] == MAP_ATTR::MONSTER) { Terrain[x + 1][y - 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y - 1] == MAP_ATTR::EMPTY) Terrain[x][y - 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y - 1] == MAP_ATTR::MONSTER) { Terrain[x][y - 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 1][y - 1] == MAP_ATTR::EMPTY) Terrain[x - 1][y - 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 1][y - 1] == MAP_ATTR::MONSTER) { Terrain[x - 1][y - 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

//----------------------------------------

break;

case 1:

//----------------------------------------

if (Terrain[x - 1][y] == MAP_ATTR::EMPTY) Terrain[x - 1][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 1][y] == MAP_ATTR::MONSTER) { Terrain[x - 1][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 1][y + 1] == MAP_ATTR::EMPTY) Terrain[x - 1][y + 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 1][y + 1] == MAP_ATTR::MONSTER) { Terrain[x - 1][y + 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y + 1] == MAP_ATTR::EMPTY) Terrain[x][y + 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y + 1] == MAP_ATTR::MONSTER) { Terrain[x][y + 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 1][y + 1] == MAP_ATTR::EMPTY) Terrain[x + 1][y + 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 1][y + 1] == MAP_ATTR::MONSTER) { Terrain[x + 1][y + 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 1][y] == MAP_ATTR::EMPTY) Terrain[x + 1][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 1][y] == MAP_ATTR::MONSTER) { Terrain[x + 1][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 1][y - 1] == MAP_ATTR::EMPTY) Terrain[x + 1][y - 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 1][y - 1] == MAP_ATTR::MONSTER) { Terrain[x + 1][y - 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y - 1] == MAP_ATTR::EMPTY) Terrain[x][y - 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y - 1] == MAP_ATTR::MONSTER) { Terrain[x][y - 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 1][y - 1] == MAP_ATTR::EMPTY) Terrain[x - 1][y - 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 1][y - 1] == MAP_ATTR::MONSTER) { Terrain[x - 1][y - 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

//----------------------------------------

if (Terrain[x - 2][y] == MAP_ATTR::EMPTY) Terrain[x - 2][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 2][y] == MAP_ATTR::MONSTER) { Terrain[x - 2][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 2][y + 2] == MAP_ATTR::EMPTY) Terrain[x - 2][y + 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 2][y + 2] == MAP_ATTR::MONSTER) { Terrain[x - 2][y + 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y + 2] == MAP_ATTR::EMPTY) Terrain[x][y + 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y + 2] == MAP_ATTR::MONSTER) { Terrain[x][y + 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 2][y + 2] == MAP_ATTR::EMPTY) Terrain[x + 2][y + 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 2][y + 2] == MAP_ATTR::MONSTER) { Terrain[x + 2][y + 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 2][y] == MAP_ATTR::EMPTY) Terrain[x + 2][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 2][y] == MAP_ATTR::MONSTER) { Terrain[x + 2][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 2][y - 2] == MAP_ATTR::EMPTY) Terrain[x + 2][y - 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 2][y - 2] == MAP_ATTR::MONSTER) { Terrain[x + 2][y - 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y - 2] == MAP_ATTR::EMPTY) Terrain[x][y - 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y - 2] == MAP_ATTR::MONSTER) { Terrain[x][y - 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 2][y - 2] == MAP_ATTR::EMPTY) Terrain[x - 2][y - 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 2][y - 2] == MAP_ATTR::MONSTER) { Terrain[x - 2][y - 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

//----------------------------------------

break;

case 2:

//----------------------------------------

if (Terrain[x - 1][y] == MAP_ATTR::EMPTY) Terrain[x - 1][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 1][y] == MAP_ATTR::MONSTER) { Terrain[x - 1][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 1][y + 1] == MAP_ATTR::EMPTY) Terrain[x - 1][y + 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 1][y + 1] == MAP_ATTR::MONSTER) { Terrain[x - 1][y + 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y + 1] == MAP_ATTR::EMPTY) Terrain[x][y + 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y + 1] == MAP_ATTR::MONSTER) { Terrain[x][y + 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 1][y + 1] == MAP_ATTR::EMPTY) Terrain[x + 1][y + 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 1][y + 1] == MAP_ATTR::MONSTER) { Terrain[x + 1][y + 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 1][y] == MAP_ATTR::EMPTY) Terrain[x + 1][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 1][y] == MAP_ATTR::MONSTER) { Terrain[x + 1][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 1][y - 1] == MAP_ATTR::EMPTY) Terrain[x + 1][y - 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 1][y - 1] == MAP_ATTR::MONSTER) { Terrain[x + 1][y - 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y - 1] == MAP_ATTR::EMPTY) Terrain[x][y - 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y - 1] == MAP_ATTR::MONSTER) { Terrain[x][y - 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 1][y - 1] == MAP_ATTR::EMPTY) Terrain[x - 1][y - 1] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 1][y - 1] == MAP_ATTR::MONSTER) { Terrain[x - 1][y - 1] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

//----------------------------------------

if (Terrain[x - 2][y] == MAP_ATTR::EMPTY) Terrain[x - 2][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 2][y] == MAP_ATTR::MONSTER) { Terrain[x - 2][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 2][y + 2] == MAP_ATTR::EMPTY) Terrain[x - 2][y + 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 2][y + 2] == MAP_ATTR::MONSTER) { Terrain[x - 2][y + 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y + 2] == MAP_ATTR::EMPTY) Terrain[x][y + 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y + 2] == MAP_ATTR::MONSTER) { Terrain[x][y + 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 2][y + 2] == MAP_ATTR::EMPTY) Terrain[x + 2][y + 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 2][y + 2] == MAP_ATTR::MONSTER) { Terrain[x + 2][y + 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 2][y] == MAP_ATTR::EMPTY) Terrain[x + 2][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 2][y] == MAP_ATTR::MONSTER) { Terrain[x + 2][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 2][y - 2] == MAP_ATTR::EMPTY) Terrain[x + 2][y - 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 2][y - 2] == MAP_ATTR::MONSTER) { Terrain[x + 2][y - 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y - 2] == MAP_ATTR::EMPTY) Terrain[x][y - 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y - 2] == MAP_ATTR::MONSTER) { Terrain[x][y - 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 2][y - 2] == MAP_ATTR::EMPTY) Terrain[x - 2][y - 2] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 2][y - 2] == MAP_ATTR::MONSTER) { Terrain[x - 2][y - 2] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

//----------------------------------------

if (Terrain[x - 3][y] == MAP_ATTR::EMPTY) Terrain[x - 3][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 3][y] == MAP_ATTR::MONSTER) { Terrain[x - 3][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 3][y + 3] == MAP_ATTR::EMPTY) Terrain[x - 3][y + 3] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 3][y + 3] == MAP_ATTR::MONSTER) { Terrain[x - 3][y + 3] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y + 3] == MAP_ATTR::EMPTY) Terrain[x][y + 3] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y + 3] == MAP_ATTR::MONSTER) { Terrain[x][y + 3] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 1][y + 3] == MAP_ATTR::EMPTY) Terrain[x + 3][y + 3] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 1][y + 3] == MAP_ATTR::MONSTER) { Terrain[x + 3][y + 3] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 3][y] == MAP_ATTR::EMPTY) Terrain[x + 3][y] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 3][y] == MAP_ATTR::MONSTER) { Terrain[x + 3][y] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x + 3][y - 3] == MAP_ATTR::EMPTY) Terrain[x + 3][y - 3] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x + 3][y - 3] == MAP_ATTR::MONSTER) { Terrain[x + 3][y - 3] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x][y - 3] == MAP_ATTR::EMPTY) Terrain[x][y - 3] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x][y - 3] == MAP_ATTR::MONSTER) { Terrain[x][y - 3] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

if (Terrain[x - 3][y - 3] == MAP_ATTR::EMPTY) Terrain[x - 3][y - 3] = MAP_ATTR::PLAYER_SKILL;
if (Terrain[x - 3][y - 3] == MAP_ATTR::MONSTER) { Terrain[x - 3][y - 3] = MAP_ATTR::EMPTY; this->iObjTar++; this->PlayMusic("\Data\Sound\TarDeath.wav"); }

//----------------------------------------

break;

default:
break;
}

if (this->iObjTar >= 20)
{
this->iLevel = 1;

if (this->iObjTar >= 40)
{
this->iLevel = 2;

if (this->iObjTar >= 60)
{
this->iLevel = 3;

MsgBox("You win. Congratulation... Monster Killed [%d] / Collected Quests [%d] .  ", this->iObjTar, this->iQuest);
::ExitProcess(0);
}
}
}
};

void CSimpleRpg::ObjClrAttack(char object, char replace)
{
for (int x = 0; x < TX; x++)
{
for (int y = 0; y < TY; y++)
{
if (Terrain[x][y] == object)
{
Terrain[x][y] = replace;
}
}
}
};

//--------------------------------------------------

//Uncompleted
bool CSimpleRpg::ObjTarAttack()
{
this->b_ObjAttackThreadActivity = true;

for (int x = 0; x < TX; x++)
{
for (int y = 0; y < TY; y++)
{
if (Terrain[x][y] == MAP_ATTR::MONSTER)
{
if (Terrain[x - 1][y] == MAP_ATTR::EMPTY || Terrain[x - 1][y] == MAP_ATTR::PLAYER)
{
if (Terrain[x - 1][y] == MAP_ATTR::PLAYER)
{
this->PlayMusic("\Data\Sound\TarAttack.wav");
MsgBox("You lose! You had killed by monster."); return false;
}
Terrain[x - 1][y] = MAP_ATTR::MONSTER_SKILL;
}

if (Terrain[x - 1][y + 1] == MAP_ATTR::EMPTY || Terrain[x - 1][y + 1] == MAP_ATTR::PLAYER)
{
if (Terrain[x - 1][y + 1] == MAP_ATTR::PLAYER)
{
this->PlayMusic("\Data\Sound\TarAttack.wav");
MsgBox("You lose! You had killed by monster."); return false;
}
Terrain[x - 1][y + 1] = MAP_ATTR::MONSTER_SKILL;
}

if (Terrain[x][y + 1] == MAP_ATTR::EMPTY || Terrain[x][y + 1] == MAP_ATTR::PLAYER)
{
if (Terrain[x][y + 1] == MAP_ATTR::PLAYER)
{
this->PlayMusic("\Data\Sound\TarAttack.wav");
MsgBox("You lose! You had killed by monster."); return false;
}
Terrain[x][y + 1] = MAP_ATTR::MONSTER_SKILL;
}

if (Terrain[x + 1][y + 1] == MAP_ATTR::EMPTY || Terrain[x + 1][y + 1] == MAP_ATTR::PLAYER)
{
if (Terrain[x + 1][y + 1] == MAP_ATTR::PLAYER)
{
this->PlayMusic("\Data\Sound\TarAttack.wav");
MsgBox("You lose! You had killed by monster."); return false;
}
Terrain[x + 1][y + 1] = MAP_ATTR::MONSTER_SKILL;
}

if (Terrain[x + 1][y] == MAP_ATTR::EMPTY || Terrain[x + 1][y] == MAP_ATTR::PLAYER)
{
if (Terrain[x + 1][y] == MAP_ATTR::PLAYER)
{
this->PlayMusic("\Data\Sound\TarAttack.wav");
MsgBox("You lose! You had killed by monster."); return false;
}
Terrain[x + 1][y] = MAP_ATTR::MONSTER_SKILL;
}

if (Terrain[x + 1][y - 1] == MAP_ATTR::EMPTY || Terrain[x + 1][y - 1] == MAP_ATTR::PLAYER)
{
if (Terrain[x + 1][y - 1] == MAP_ATTR::PLAYER)
{
this->PlayMusic("\Data\Sound\TarAttack.wav");
MsgBox("You lose! You had killed by monster."); return false;
}
Terrain[x + 1][y - 1] = MAP_ATTR::MONSTER_SKILL;
}

if (Terrain[x][y - 1] == MAP_ATTR::EMPTY || Terrain[x][y - 1] == MAP_ATTR::PLAYER)
{
if (Terrain[x][y - 1] == MAP_ATTR::PLAYER)
{
this->PlayMusic("\Data\Sound\TarAttack.wav");
MsgBox("You lose! You had killed by monster."); return false;
}
Terrain[x][y - 1] = MAP_ATTR::MONSTER_SKILL;
}

if (Terrain[x - 1][y - 1] == MAP_ATTR::EMPTY || Terrain[x - 1][y - 1] == MAP_ATTR::PLAYER)
{
if (Terrain[x - 1][y - 1] == MAP_ATTR::PLAYER)
{
this->PlayMusic("\Data\Sound\TarAttack.wav");
MsgBox("You lose! You had killed by monster."); return false;
}
Terrain[x - 1][y - 1] = MAP_ATTR::MONSTER_SKILL;
}
}
}
}
return true;
};

void CSimpleRpg::ObjTarClrAttack(char object, char replace)
{
for (int x = 0; x < TX; x++)
{
for (int y = 0; y < TY; y++)
{
if (Terrain[x][y] == object)
{
Terrain[x][y] = replace;
}
}
}
};

unsigned __stdcall CSimpleRpg::ObjTarRespawn(LPVOID lpParam)
{
int iCount = 0;

while (true)
{
if ((iCount++) > TX * TY) break;

srand(time(0));

int x, y, rx, ry;
g_pSimpleRpg->GetCurObjMapCrd(x, y, MAP_ATTR::PLAYER);

if (x != (rx = rand() % 9) && y != (ry = rand() % 19))
{
Terrain[rx][ry] = MAP_ATTR::MONSTER;
}

g_pSimpleRpg->GetCurObjMapCrd(x, y, MAP_ATTR::QUEST);

if (x != (rx =rand() % 9) && y != (ry = rand() % 19))
{
Terrain[rx][ry] = MAP_ATTR::MONSTER;
}

g_pSimpleRpg->GetCurObjMapCrd(x, y, MAP_ATTR::TERRAIN);

if (x != (rx =rand() % 9) && y != (ry = rand() % 19))
{
Terrain[rx][ry] = MAP_ATTR::MONSTER;
}

Sleep(1500);
}

_endthreadex(0); return 0;
};

//--------------------------------------------------

int main()
{
HANDLE hProcess;
unsigned int ProcessID;
hProcess = (HANDLE)_beginthreadex(NULL, 0, g_pSimpleRpg->RenderingThread, NULL, 0, &ProcessID);
WaitForSingleObject(hProcess, INFINITE);
CloseHandle(hProcess);
std::cin.get(); return 0;
}

//--------------------------------------------------

void MsgBox(char *pArg, ...)
{
char szBuf[MAX_PATH];
va_list pArguments;
va_start(pArguments, pArg);
vsprintf(szBuf, pArg, pArguments);
va_end(pArguments);
MessageBox(NULL, szBuf, "Msg", MB_OK | MB_APPLMODAL);
}

Похожие темы (5)