Merge branch 'master' of github.com:Allanis/Unuk
Conflicts: Unuk-QT/Makefile
This commit is contained in:
commit
61a6f2202a
@ -1,6 +1,6 @@
|
||||
#############################################################################
|
||||
# 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
|
||||
# Template: app
|
||||
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
|
@ -18,13 +18,13 @@ public:
|
||||
string GetName(void) { return _name; }
|
||||
|
||||
void SetLevel(int level);
|
||||
int GetLevel() { return _level; }
|
||||
int GetLevel(void) { return _level; }
|
||||
|
||||
void SetExp(int exp);
|
||||
int GetExp() { return _exp; }
|
||||
int GetExp(void) { return _exp; }
|
||||
|
||||
int GetExpNeeded() { return _expNeeded; }
|
||||
void SetExpNeeded(int expNeeded);
|
||||
int GetExpNeeded(void) { return _expNeeded; }
|
||||
|
||||
static const int BASE_EXP_NEEDED;
|
||||
|
||||
|
@ -77,7 +77,7 @@ void WorldManager::OnPlayerAttack(Player* player) {
|
||||
}
|
||||
|
||||
// Distance is greater than 2.
|
||||
if(diffX > 2 || diffY > 2) {
|
||||
if(abs(diffX) > 2 || abs(diffY) > 2) {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
|
@ -126,6 +126,9 @@ void LevelGen::Load(const string filename) {
|
||||
levelWidth = x * TILE_WIDTH;
|
||||
levelHeight = y * TILE_HEIGHT;
|
||||
|
||||
// procedural generation
|
||||
DoMagic();
|
||||
|
||||
//character->Load(filename);
|
||||
|
||||
NPC* npc = new NPC(this);
|
||||
@ -204,6 +207,37 @@ void LevelGen::Unload(void) {
|
||||
_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) {
|
||||
return _currentMap;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
|
||||
private:
|
||||
void Unload(void);
|
||||
void DoMagic(void);
|
||||
|
||||
string _currentMap;
|
||||
int x;
|
||||
|
Loading…
Reference in New Issue
Block a user