Merge branch 'master' of github.com:Allanis/Unuk

Conflicts:
	Unuk-QT/Makefile
This commit is contained in:
Rtch90 2012-02-01 16:13:22 +00:00
commit 61a6f2202a
6 changed files with 41 additions and 6 deletions

View File

@ -1,6 +1,6 @@
############################################################################# #############################################################################
# Makefile for building: Unuk-QT # Makefile for building: Unuk-QT
# Generated by qmake (2.01a) (Qt 4.7.4) on: Wed Feb 1 16:03:50 2012 # Generated by qmake (2.01a) (Qt 4.7.4) on: Wed Feb 1 16:11:23 2012
# Project: Unuk-QT.pro # Project: Unuk-QT.pro
# Template: app # Template: app
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro # Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by Qt Creator 2.4.0, 2012-02-01T02:13:25. --> <!-- Written by Qt Creator 2.4.0, 2012-02-01T12:52:42. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>ProjectExplorer.Project.ActiveTarget</variable>

View File

@ -18,13 +18,13 @@ public:
string GetName(void) { return _name; } string GetName(void) { return _name; }
void SetLevel(int level); void SetLevel(int level);
int GetLevel() { return _level; } int GetLevel(void) { return _level; }
void SetExp(int exp); void SetExp(int exp);
int GetExp() { return _exp; } int GetExp(void) { return _exp; }
int GetExpNeeded() { return _expNeeded; }
void SetExpNeeded(int expNeeded); void SetExpNeeded(int expNeeded);
int GetExpNeeded(void) { return _expNeeded; }
static const int BASE_EXP_NEEDED; static const int BASE_EXP_NEEDED;

View File

@ -77,7 +77,7 @@ void WorldManager::OnPlayerAttack(Player* player) {
} }
// Distance is greater than 2. // Distance is greater than 2.
if(diffX > 2 || diffY > 2) { if(abs(diffX) > 2 || abs(diffY) > 2) {
++i; ++i;
continue; continue;
} }

View File

@ -125,6 +125,9 @@ void LevelGen::Load(const string filename) {
// </map> // </map>
levelWidth = x * TILE_WIDTH; levelWidth = x * TILE_WIDTH;
levelHeight = y * TILE_HEIGHT; levelHeight = y * TILE_HEIGHT;
// procedural generation
DoMagic();
//character->Load(filename); //character->Load(filename);
@ -204,6 +207,37 @@ void LevelGen::Unload(void) {
_entityTextures.Unload(); _entityTextures.Unload();
} }
void LevelGen::DoMagic(void) {
int nextEntityGen = 1 + (rand() % 20);
const char* entityTextures[6] = {
"../Data/Media/Images/Entities/tree.png",
"../Data/Media/Images/Entities/hedge.png",
"../Data/Media/Images/Entities/barrel.png",
"../Data/Media/Images/Entities/closedChest.png",
"../Data/Media/Images/Entities/closedChestMetal.png",
"../Data/Media/Images/Entities/closedChestMetal2.png",
};
for(int x = 0; x < TILE_ARRAY_SIZE; x++) {
for(int y = 0; y < TILE_ARRAY_SIZE; y++) {
nextEntityGen--;
if(!_tile[x][y].GetTileSolidity() && nextEntityGen <= 0) {
int texId = rand() % 5;
_tile[x][y].SetEntityTexture(_entityTextures.AddAlpha(entityTextures[texId]));
_tile[x][y].SetEntityXY(_tile[x][y].GetTileX() + TILE_WIDTH / 2 - _tile[x][y].GetEntityWidth() / 2,
_tile[x][y].GetTileY() + TILE_HEIGHT / 2 - _tile[x][y].GetEntityHeight() / 2);
_tile[x][y].SetEntitySolidity(true);
nextEntityGen = 1 + (rand() % 10);
}
}
}
}
string LevelGen::GetCurrentMap(void) { string LevelGen::GetCurrentMap(void) {
return _currentMap; return _currentMap;
} }

View File

@ -47,6 +47,7 @@ public:
private: private:
void Unload(void); void Unload(void);
void DoMagic(void);
string _currentMap; string _currentMap;
int x; int x;