[Add] Initial procedural generation stuff.
This commit is contained in:
parent
dfa2d88008
commit
d6027ce0f9
@ -1,6 +1,6 @@
|
|||||||
#############################################################################
|
#############################################################################
|
||||||
# Makefile for building: Unuk-QT
|
# Makefile for building: Unuk-QT
|
||||||
# Generated by qmake (2.01a) (Qt 4.7.4) on: Mon Jan 30 01:06:11 2012
|
# Generated by qmake (2.01a) (Qt 4.7.4) on: Wed Feb 1 03:55:02 2012
|
||||||
# Project: Unuk-QT.pro
|
# Project: Unuk-QT.pro
|
||||||
# Template: app
|
# Template: app
|
||||||
# Command: /home/kono/QtSDK/Desktop/Qt/474/gcc/bin/qmake -spec ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
# Command: /home/kono/QtSDK/Desktop/Qt/474/gcc/bin/qmake -spec ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
||||||
@ -269,7 +269,8 @@ WorldManager.o: ../src/libUnuk/Engine/WorldManager.cpp ../src/libUnuk/Engine/Wor
|
|||||||
../src/libUnuk/UI/Bar.h \
|
../src/libUnuk/UI/Bar.h \
|
||||||
../src/libUnuk/System/Rect.h \
|
../src/libUnuk/System/Rect.h \
|
||||||
../src/libUnuk/Engine/AStar.h \
|
../src/libUnuk/Engine/AStar.h \
|
||||||
../src/libUnuk/Engine/AStarBase.h
|
../src/libUnuk/Engine/AStarBase.h \
|
||||||
|
../src/Unuk/Player.h
|
||||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o WorldManager.o ../src/libUnuk/Engine/WorldManager.cpp
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o WorldManager.o ../src/libUnuk/Engine/WorldManager.cpp
|
||||||
|
|
||||||
ParticleEmitter.o: ../src/libUnuk/Engine/ParticleEmitter.cpp ../src/libUnuk/Engine/ParticleEmitter.h \
|
ParticleEmitter.o: ../src/libUnuk/Engine/ParticleEmitter.cpp ../src/libUnuk/Engine/ParticleEmitter.h \
|
||||||
|
@ -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-01T04:05:23. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -126,6 +126,9 @@ void LevelGen::Load(const string filename) {
|
|||||||
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);
|
||||||
|
|
||||||
NPC* npc = new NPC(this);
|
NPC* npc = new NPC(this);
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void Unload(void);
|
void Unload(void);
|
||||||
|
void DoMagic(void);
|
||||||
|
|
||||||
string _currentMap;
|
string _currentMap;
|
||||||
int x;
|
int x;
|
||||||
|
Loading…
Reference in New Issue
Block a user