diff --git a/Data/Media/Images/Characters/Reniesta.png b/Data/Media/Images/Characters/Reniesta.png new file mode 100644 index 0000000..5dc7b92 Binary files /dev/null and b/Data/Media/Images/Characters/Reniesta.png differ diff --git a/README b/README index 5bf0e2e..d69a260 100644 --- a/README +++ b/README @@ -1,9 +1,6 @@ Readme plz! ___________ -I have decided to use Git for SCM of this project. -Please see https://github.com/Allanis/Unuk - ################################################## I am currently working on a series of algorithms to show off @@ -11,49 +8,15 @@ for a portfolio piece. I will place this under the GPL licence. ################################################## -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -TODO: +~~Instructions~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -*Menu: -~~~~~ -- New Game -- SaveGame loading - - New screen or make buttons appear on the menu -- SaveGame deleting -- Game Settings - - Keybindings - - Fullscreen - -*Fix NPC animation - -*Map Editor: -~~~~~~~~~~~~ - -- Change the array of tiles into a list of tiles. -- Get a tile selection marker and display the current tile info. - -*Proper collision testing. -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- MapTile objects store a list of character* 's - - The character class will add and remove themselves from the list in the MapTile. - - When the Character class wants to check for collisions it hands a pointer to - itself to the MapTile object, the MapTile will then return true if any - Character in it's list collides with the Character* it just recieved. - - Create the appropriate methods in the MapTile class - - bool CheckCollision(Character *charptr); - - void AddCharacter(Character *charptr); - - void RemoveCharacter(Character *charptr); - -*A way for entities to store information (Like items). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- Sort out how we will read in the information - - A list of present objects that can be referenced with a single word in the map file. +Arrow keys/wasd - Move Player. +'p' - Show debug information. +'Space'/'Left Mouse' - Attack. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Copyright (C) 2011 SaraCraft allanis@saracraft.net diff --git a/Unuk-QT/Unuk-QT.pro b/Unuk-QT/Unuk-QT.pro index 9bbd9a2..a1cac15 100644 --- a/Unuk-QT/Unuk-QT.pro +++ b/Unuk-QT/Unuk-QT.pro @@ -1,5 +1,4 @@ CONFIG -= qt - LIBS += -lGL \ -lSDL \ -lSDL_ttf \ @@ -7,7 +6,6 @@ LIBS += -lGL \ -lSDL_gfx \ -ltinyxml \ -lGLU - HEADERS += ../src/Libs/wglext.h \ ../src/Libs/glxext.h \ ../src/libUnuk/Engine/WorldManager.h \ @@ -47,8 +45,8 @@ HEADERS += ../src/Libs/wglext.h \ ../src/libUnuk/System/Vec2.h \ ../src/libUnuk/System/MathBox.h \ ../src/libUnuk/Engine/Pathfinding.h \ - ../src/libUnuk/UI/SavegameMenu.h - + ../src/libUnuk/UI/SavegameMenu.h \ + ../src/libUnuk/Engine/Spells.h SOURCES += ../src/libUnuk/Engine/WorldManager.cpp \ ../src/libUnuk/Engine/ParticleEmitter.cpp \ ../src/libUnuk/Engine/NPC.cpp \ @@ -82,4 +80,5 @@ SOURCES += ../src/libUnuk/Engine/WorldManager.cpp \ ../src/libUnuk/UI/EventHistory.cpp \ ../src/libUnuk/UI/Bar.cpp \ ../src/libUnuk/System/Vec2.cpp \ - ../src/libUnuk/UI/SavegameMenu.cpp + ../src/libUnuk/UI/SavegameMenu.cpp \ + ../src/libUnuk/Engine/Spells.cpp diff --git a/src/Unuk/Game.cpp b/src/Unuk/Game.cpp index a2129d5..48be3d4 100644 --- a/src/Unuk/Game.cpp +++ b/src/Unuk/Game.cpp @@ -7,7 +7,7 @@ Game::Game(void) { Debug::logger->message("Creating characters.."); _player = new Player(&_map); - _map.SetPlayer(_player); + _map.SetPlayer(_player); _runGameReturnValue = gameMainMenu; } @@ -19,29 +19,29 @@ Game::~Game(void) { } void Game::New(const string& savegameIDArg) { - _saveGameID = savegameIDArg; - NewSavegame(savegameIDArg); - - int spawnX; - int spawnY; - _map.FindSpawnPoint(spawnX, spawnY, 40, 45); - - _player->SetXY((float)spawnX, (float)spawnY); + _saveGameID = savegameIDArg; + NewSavegame(savegameIDArg); + + int spawnX; + int spawnY; + _map.FindSpawnPoint(spawnX, spawnY, 40, 45); + + _player->SetXY((float)spawnX, (float)spawnY); } void Game::Load(const string& savegameIDArg) { - _saveGameID = savegameIDArg; - LoadSavegame(savegameIDArg); - - int spawnX; - int spawnY; - _map.FindSpawnPoint(spawnX, spawnY, 40, 45); - - _player->SetXY((float)spawnX, (float)spawnY); + _saveGameID = savegameIDArg; + LoadSavegame(savegameIDArg); + + int spawnX; + int spawnY; + _map.FindSpawnPoint(spawnX, spawnY, 40, 45); + + _player->SetXY((float)spawnX, (float)spawnY); } gameNavVal_t Game::Run(void) { - _player->LoadSprites("../Data/Media/Images/Characters/Player.png", 40, 45); + _player->LoadSprites("../Data/Media/Images/Characters/Reniesta.png", 40, 45); int fps = 0; int frame = 0; @@ -252,10 +252,10 @@ void Game::Render(void) { } void Game::NewSavegame(const string savegameIDArg) { - string saveFilename = "../Save/" + savegameIDArg; + string saveFilename = "../Save/" + savegameIDArg; - _map.New(); - _map.Save(_saveGameID); + _map.New(); + _map.Save(_saveGameID); TiXmlDocument doc; @@ -266,13 +266,13 @@ void Game::NewSavegame(const string savegameIDArg) { TiXmlElement* nameElement = new TiXmlElement("name"); TiXmlText* nameText = new TiXmlText("Allanis"); //TODO: replace with _player->GetName() when it works. --konom nameElement->LinkEndChild(nameText); - - int spawnX; - int spawnY; - _map.FindSpawnPoint(spawnX, spawnY, 40, 45); - - _player->SetXY(spawnX, spawnY); - + + int spawnX; + int spawnY; + _map.FindSpawnPoint(spawnX, spawnY, 40, 45); + + _player->SetXY(spawnX, spawnY); + std::stringstream xString; xString << spawnX; @@ -286,22 +286,22 @@ void Game::NewSavegame(const string savegameIDArg) { TiXmlElement* yElement = new TiXmlElement("y"); TiXmlText* yText = new TiXmlText(yString.str().c_str()); yElement->LinkEndChild(yText); - - _player->SetLevelLiteral(1); - - TiXmlElement* levelElement = new TiXmlElement("level"); - TiXmlText* levelText = new TiXmlText("1"); - levelElement->LinkEndChild(levelText); - - _player->SetExpLiteral(0); - - TiXmlElement* expElement = new TiXmlElement("exp"); - TiXmlText* expText = new TiXmlText("0"); - expElement->LinkEndChild(expText); - - TiXmlElement* healthElement = new TiXmlElement("health"); - TiXmlText* healthText = new TiXmlText("100"); - healthElement->LinkEndChild(healthText); + + _player->SetLevelLiteral(1); + + TiXmlElement* levelElement = new TiXmlElement("level"); + TiXmlText* levelText = new TiXmlText("1"); + levelElement->LinkEndChild(levelText); + + _player->SetExpLiteral(0); + + TiXmlElement* expElement = new TiXmlElement("exp"); + TiXmlText* expText = new TiXmlText("0"); + expElement->LinkEndChild(expText); + + TiXmlElement* healthElement = new TiXmlElement("health"); + TiXmlText* healthText = new TiXmlText("100"); + healthElement->LinkEndChild(healthText); TiXmlElement* mapElement = new TiXmlElement("map"); TiXmlText* mapText = new TiXmlText("map"); //TODO: replace with actual map name. @@ -310,9 +310,9 @@ void Game::NewSavegame(const string savegameIDArg) { saveElement->LinkEndChild(nameElement); saveElement->LinkEndChild(xElement); saveElement->LinkEndChild(yElement); - saveElement->LinkEndChild(levelElement); - saveElement->LinkEndChild(expElement); - saveElement->LinkEndChild(healthElement); + saveElement->LinkEndChild(levelElement); + saveElement->LinkEndChild(expElement); + saveElement->LinkEndChild(healthElement); saveElement->LinkEndChild(mapElement); doc.LinkEndChild(decl); @@ -327,12 +327,12 @@ void Game::LoadSavegame(const string savegameIDArg) { // Converting to XML ftw! TiXmlDocument mapFile(saveFilename.c_str()); - - // Create new save if can't load file. - if(!mapFile.LoadFile()) { - New(savegameIDArg); - return; - } + + // Create new save if can't load file. + if(!mapFile.LoadFile()) { + New(savegameIDArg); + return; + } TiXmlElement* rootElem = NULL; TiXmlElement* dataElem = NULL; @@ -364,41 +364,41 @@ void Game::LoadSavegame(const string savegameIDArg) { // _player->SetXY((float)playerX, (float)playerY); */ - - // - Parse the player level. - dataElem = dataElem->NextSiblingElement("level"); - assert(dataElem != NULL); - int playerLevel = atoi(dataElem->GetText()); - // - - _player->SetLevelLiteral(playerLevel); - - // - Parse the player exp. - dataElem = dataElem->NextSiblingElement("exp"); - assert(dataElem != NULL); - int playerExp = atoi(dataElem->GetText()); - // - - _player->SetExpLiteral(playerExp); - - // - Parse the player health. - dataElem = dataElem->NextSiblingElement("health"); - assert(dataElem != NULL); - int playerHealth = atoi(dataElem->GetText()); - // - - _player->SetHealthLiteral(playerHealth); + + // - Parse the player level. + dataElem = dataElem->NextSiblingElement("level"); + assert(dataElem != NULL); + int playerLevel = atoi(dataElem->GetText()); + // + + _player->SetLevelLiteral(playerLevel); + + // - Parse the player exp. + dataElem = dataElem->NextSiblingElement("exp"); + assert(dataElem != NULL); + int playerExp = atoi(dataElem->GetText()); + // + + _player->SetExpLiteral(playerExp); + + // - Parse the player health. + dataElem = dataElem->NextSiblingElement("health"); + assert(dataElem != NULL); + int playerHealth = atoi(dataElem->GetText()); + // + + _player->SetHealthLiteral(playerHealth); } // // - - _map.Load(_saveGameID); + + _map.Load(_saveGameID); } void Game::SaveSavegame(void) { string saveFilename = "../Save/" + _saveGameID; - + TiXmlDocument doc; TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", ""); @@ -425,38 +425,38 @@ void Game::SaveSavegame(void) { yElement->LinkEndChild(yText); */ - std::stringstream levelString; - levelString << _player->GetLevel(); - - TiXmlElement* levelElement = new TiXmlElement("level"); - TiXmlText* levelText = new TiXmlText(levelString.str().c_str()); - levelElement->LinkEndChild(levelText); - - std::stringstream expString; - expString << _player->GetExp(); - - TiXmlElement* expElement = new TiXmlElement("exp"); - TiXmlText* expText = new TiXmlText(expString.str().c_str()); - expElement->LinkEndChild(expText); - - std::stringstream healthString; - healthString << _player->GetHealth(); - - TiXmlElement* healthElement = new TiXmlElement("health"); - TiXmlText* healthText = new TiXmlText(healthString.str().c_str()); - healthElement->LinkEndChild(healthText); + std::stringstream levelString; + levelString << _player->GetLevel(); + + TiXmlElement* levelElement = new TiXmlElement("level"); + TiXmlText* levelText = new TiXmlText(levelString.str().c_str()); + levelElement->LinkEndChild(levelText); + + std::stringstream expString; + expString << _player->GetExp(); + + TiXmlElement* expElement = new TiXmlElement("exp"); + TiXmlText* expText = new TiXmlText(expString.str().c_str()); + expElement->LinkEndChild(expText); + + std::stringstream healthString; + healthString << _player->GetHealth(); + + TiXmlElement* healthElement = new TiXmlElement("health"); + TiXmlText* healthText = new TiXmlText(healthString.str().c_str()); + healthElement->LinkEndChild(healthText); saveElement->LinkEndChild(nameElement); //saveElement->LinkEndChild(xElement); //saveElement->LinkEndChild(yElement); - saveElement->LinkEndChild(levelElement); - saveElement->LinkEndChild(expElement); - saveElement->LinkEndChild(healthElement); + saveElement->LinkEndChild(levelElement); + saveElement->LinkEndChild(expElement); + saveElement->LinkEndChild(healthElement); doc.LinkEndChild(decl); doc.LinkEndChild(saveElement); doc.SaveFile(saveFilename.c_str()); - - _map.Save(_saveGameID); + + _map.Save(_saveGameID); } diff --git a/src/Unuk/Game.h b/src/Unuk/Game.h index f393464..e76bfba 100644 --- a/src/Unuk/Game.h +++ b/src/Unuk/Game.h @@ -23,46 +23,46 @@ enum gameNavVal_t { gameMainMenu, gameQuitGame }; class Game { public: - Game(void); - ~Game(void); - - void New(const string& savegameIDArg); - void Load(const string& savegameIDArg); + Game(void); + ~Game(void); + + void New(const string& savegameIDArg); + void Load(const string& savegameIDArg); + + gameNavVal_t Run(void); - gameNavVal_t Run(void); - private: - void HandleInput(void); - void UpdateGame(void); - void Render(void); + void HandleInput(void); + void UpdateGame(void); + void Render(void); - void NewSavegame(const string savegameIDArg); - void LoadSavegame(const string savegameIDArg); - void SaveSavegame(void); + void NewSavegame(const string savegameIDArg); + void LoadSavegame(const string savegameIDArg); + void SaveSavegame(void); static const int MAX_FPS = 200; - static const int GAME_UPDATES_PER_SECOND = 60; - static const int SKIP_TICKS = 1000 / GAME_UPDATES_PER_SECOND; + static const int GAME_UPDATES_PER_SECOND = 60; + static const int SKIP_TICKS = 1000 / GAME_UPDATES_PER_SECOND; - bool _gameRunning; + bool _gameRunning; - gameNavVal_t _runGameReturnValue; + gameNavVal_t _runGameReturnValue; - string _saveGameID; - string _mapID; + string _saveGameID; + string _mapID; - Text _gameUpdateTime; - Text _gameRenderTime; - Text _playerXY; - Text _npcHealth; + Text _gameUpdateTime; + Text _gameRenderTime; + Text _playerXY; + Text _npcHealth; - IngameMenu _ingameMenu; + IngameMenu _ingameMenu; LevelGen _map; - Player* _player; + Player* _player; - Text _playerHealth; - Text _playerExp; - Bar _playerHealthBar; - Bar _playerExpBar; + Text _playerHealth; + Text _playerExp; + Bar _playerHealthBar; + Bar _playerExpBar; }; diff --git a/src/Unuk/Player.cpp b/src/Unuk/Player.cpp index 900ee97..36e5baa 100644 --- a/src/Unuk/Player.cpp +++ b/src/Unuk/Player.cpp @@ -17,23 +17,23 @@ const int Player::EXP_TABLE[MAX_LEVEL] = { 2000, 3500, 5000, - 6500, - 8500, - 10250, - 12000, - 15000, - 25000, - 50000, - 65000, - 80000, - 100000 + 6500, + 8500, + 10250, + 12000, + 15000, + 25000, + 50000, + 65000, + 80000, + 100000 }; Player::Player(LevelGen *mapArg) : Character(mapArg) { _level = 1; _exp = 0; - _lastTileX = 0; - _lastTileY = 0; + _lastTileX = 0; + _lastTileY = 0; } Player::~Player(void) { @@ -101,14 +101,14 @@ void Player::Update(void) { // For now The camera will be static. //SetCamera(); - int tileX = x / TILE_WIDTH; - int tileY = y / TILE_HEIGHT; - if(tileX != _lastTileX || tileY != _lastTileY) { - _lastTileX = tileX; - _lastTileY = tileY; - - map->GetWorld().OnPlayerMove(this); - } + int tileX = x / TILE_WIDTH; + int tileY = y / TILE_HEIGHT; + if(tileX != _lastTileX || tileY != _lastTileY) { + _lastTileX = tileX; + _lastTileY = tileY; + + map->GetWorld().OnPlayerMove(this); + } _healthBar.SetProgress((float)GetHealth() / 100.0f); } @@ -133,8 +133,8 @@ void Player::SetCamera(void) { } void Player::Move() { - map->MoveIfPossible(this, xVel, yVel, true); - Character::HealthBarScroll(); + map->MoveIfPossible(this, xVel, yVel, true); + Character::HealthBarScroll(); } void Player::SetLevel(int level) { @@ -143,10 +143,10 @@ void Player::SetLevel(int level) { if(_exp < 0) { _exp = 0; } - if(_level == MAX_LEVEL) { - eventHistory->LogEvent("YOU BEAT IT! I'M SO PROUD!"); - eventHistory->LogEvent("*Sheds Tear*"); - } + if(_level == MAX_LEVEL) { + eventHistory->LogEvent("YOU BEAT IT! I'M SO PROUD!"); + eventHistory->LogEvent("*Sheds Tear*"); + } } void Player::SetExp(int exp) { diff --git a/src/Unuk/Player.h b/src/Unuk/Player.h index a5bf7f4..253ee06 100644 --- a/src/Unuk/Player.h +++ b/src/Unuk/Player.h @@ -4,46 +4,46 @@ #include "Globals.h" #include "Constants.h" #include "../libUnuk/Engine/Character.h" -#include "../libUnuk//System/Debug.h" +#include "../libUnuk/System/Debug.h" class Player : public Character { public: - Player(LevelGen* mapArg); - ~Player(void); + Player(LevelGen* mapArg); + ~Player(void); - void HandleInput(void); - void Update(void); + void HandleInput(void); + void Update(void); - void SetName(string nameArg); - string GetName(void) { return _name; } - - void SetLevel(int level); - int GetLevel(void) { return _level; } + void SetName(string nameArg); + string GetName(void) { return _name; } - void SetExp(int exp); - int GetExp(void) { return _exp; } - - void SetLevelLiteral(int level) { _level = level; } - void SetExpLiteral(int exp) { _exp = exp; } - void SetHealthLiteral(int health) { _health = health; } + void SetLevel(int level); + int GetLevel(void) { return _level; } + + void SetExp(int exp); + int GetExp(void) { return _exp; } + + void SetLevelLiteral(int level) { _level = level; } + void SetExpLiteral(int exp) { _exp = exp; } + void SetHealthLiteral(int health) { _health = health; } + + void SetXY(float xArg, float yArg) { x = xArg, y = yArg; _lastTileX = xArg / TILE_WIDTH; _lastTileY = yArg / TILE_HEIGHT; } + + static const int MAX_LEVEL = 20; + static const int EXP_TABLE[MAX_LEVEL]; - void SetXY(float xArg, float yArg) { x = xArg, y = yArg; _lastTileX = xArg / TILE_WIDTH; _lastTileY = yArg / TILE_HEIGHT; } - - static const int MAX_LEVEL = 20; - static const int EXP_TABLE[MAX_LEVEL]; - protected: - void Move(void); - void CheckTileCollisions(void); + void Move(void); + void CheckTileCollisions(void); private: - void SetCamera(void); - static const float PLAYER_SPEED; + void SetCamera(void); + static const float PLAYER_SPEED; - string _name; - int _level; - int _exp; + string _name; + int _level; + int _exp; - int _lastTileX; - int _lastTileY; + int _lastTileX; + int _lastTileY; }; diff --git a/src/libUnuk/Engine/Character.h b/src/libUnuk/Engine/Character.h index 587ca38..6843146 100644 --- a/src/libUnuk/Engine/Character.h +++ b/src/libUnuk/Engine/Character.h @@ -45,28 +45,29 @@ public: void OnAttack(void); -// inline void* operator new(size_t size) { -// return gMemManager.Allocate(size); -// } -// -// inline void operator delete(void* object) { -// gMemManager.Free(object); -// } -// -// inline void* operator new [](size_t size) { -// return gMemManager.Allocate(size); -// } -// -// inline void operator delete [](void* object) { -// gMemManager.Free(object); -// } - - enum { - FACING_UP, - FACING_RIGHT, - FACING_DOWN, - FACING_LEFT - }; + // Overload new and delete operators to utilize MemManager. + inline void* operator new(size_t size) { + return gMemManager.Allocate(size); + } + + inline void operator delete(void* object) { + gMemManager.Free(object); + } + + inline void* operator new [](size_t size) { + return gMemManager.Allocate(size); + } + + inline void operator delete [](void* object) { + gMemManager.Free(object); + } + + enum { + FACING_UP, + FACING_RIGHT, + FACING_DOWN, + FACING_LEFT + }; protected: void HealthBarScroll(void); diff --git a/src/libUnuk/Engine/MemManager.cpp b/src/libUnuk/Engine/MemManager.cpp index 57ff900..240ea2a 100644 --- a/src/libUnuk/Engine/MemManager.cpp +++ b/src/libUnuk/Engine/MemManager.cpp @@ -4,203 +4,203 @@ MemManager gMemManager; void BitMapEntry::SetBit(int position, bool flag) { - blocksAvailable += flag ? 1 : -1; - int elementNo = position / INT_SIZE; - int bitNo = position % INT_SIZE; - if(flag) - bitMap[elementNo] = bitMap[elementNo] | (1 << bitNo); - else - bitMap[elementNo] = bitMap[elementNo] & ~(1 << bitNo); + blocksAvailable += flag ? 1 : -1; + int elementNo = position / INT_SIZE; + int bitNo = position % INT_SIZE; + if(flag) + bitMap[elementNo] = bitMap[elementNo] | (1 << bitNo); + else + bitMap[elementNo] = bitMap[elementNo] & ~(1 << bitNo); } void BitMapEntry::SetMultipleBits(int position, bool flag, int count) { - blocksAvailable += flag ? count : -count; - int elementNo = position / INT_SIZE; - int bitNo = position % INT_SIZE; + blocksAvailable += flag ? count : -count; + int elementNo = position / INT_SIZE; + int bitNo = position % INT_SIZE; - int bitSize = (count <= INT_SIZE - bitNo) ? count : INT_SIZE - bitNo; - SetRangeOfInt(&bitMap[elementNo], bitNo + bitSize - 1, bitNo, flag); - count -= bitSize; - if(!count) return; + int bitSize = (count <= INT_SIZE - bitNo) ? count : INT_SIZE - bitNo; + SetRangeOfInt(&bitMap[elementNo], bitNo + bitSize - 1, bitNo, flag); + count -= bitSize; + if(!count) return; - int i = ++elementNo; - while(count >= 0) { - if(count <= INT_SIZE) { - SetRangeOfInt(&bitMap[i], count - 1, 0, flag); - return; - } else - bitMap[i] = flag ? unsigned (-1) : 0; - count -= 32; - i++; - } + int i = ++elementNo; + while(count >= 0) { + if(count <= INT_SIZE) { + SetRangeOfInt(&bitMap[i], count - 1, 0, flag); + return; + } else + bitMap[i] = flag ? unsigned (-1) : 0; + count -= 32; + i++; + } } void BitMapEntry::SetRangeOfInt(int* element, int msb, int lsb, bool flag) { - if(flag) { - int mask = (unsigned(-1) << lsb) & (unsigned(-1) >> (INT_SIZE - msb - 1)); - *element |= mask; - } else { - int mask = (unsigned(-1) << lsb) & (unsigned(-1) >> (INT_SIZE - msb - 1)); - *element &= ~mask; - } + if(flag) { + int mask = (unsigned(-1) << lsb) & (unsigned(-1) >> (INT_SIZE - msb - 1)); + *element |= mask; + } else { + int mask = (unsigned(-1) << lsb) & (unsigned(-1) >> (INT_SIZE - msb - 1)); + *element &= ~mask; + } } MemClass* BitMapEntry::FirstFreeBlock(size_t/* size*/) { - for(int i = 0; i < BIT_MAP_ELEMENTS; i++) { - if(bitMap[i] == 0) - // There aint any bits free. - continue; + for(int i = 0; i < BIT_MAP_ELEMENTS; i++) { + if(bitMap[i] == 0) + // There aint any bits free. + continue; - // Yield the first bit position. This is a 1 - // in an int from the right. - int result = bitMap[i] & -(bitMap[i]); - //void* address = 0; - int basePos = (INT_SIZE * i); + // Yield the first bit position. This is a 1 + // in an int from the right. + int result = bitMap[i] & -(bitMap[i]); + //void* address = 0; + int basePos = (INT_SIZE * i); - switch(result) { - // Make the corresponfing bit 0 so block is no longer free. - case 0x00000001: return ComplexObjectAddress(basePos + 0); - case 0x00000002: return ComplexObjectAddress(basePos + 1); - case 0x00000004: return ComplexObjectAddress(basePos + 2); - case 0x00000008: return ComplexObjectAddress(basePos + 3); - case 0x00000010: return ComplexObjectAddress(basePos + 4); - case 0x00000020: return ComplexObjectAddress(basePos + 5); - case 0x00000040: return ComplexObjectAddress(basePos + 6); - case 0x00000080: return ComplexObjectAddress(basePos + 7); - case 0x00000100: return ComplexObjectAddress(basePos + 8); - case 0x00000200: return ComplexObjectAddress(basePos + 9); - case 0x00000400: return ComplexObjectAddress(basePos + 10); - case 0x00000800: return ComplexObjectAddress(basePos + 11); - case 0x00001000: return ComplexObjectAddress(basePos + 12); - case 0x00002000: return ComplexObjectAddress(basePos + 13); - case 0x00004000: return ComplexObjectAddress(basePos + 14); - case 0x00008000: return ComplexObjectAddress(basePos + 15); - case 0x00010000: return ComplexObjectAddress(basePos + 16); - case 0x00020000: return ComplexObjectAddress(basePos + 17); - case 0x00040000: return ComplexObjectAddress(basePos + 18); - case 0x00080000: return ComplexObjectAddress(basePos + 19); - case 0x00100000: return ComplexObjectAddress(basePos + 20); - case 0x00200000: return ComplexObjectAddress(basePos + 21); - case 0x00400000: return ComplexObjectAddress(basePos + 22); - case 0x00800000: return ComplexObjectAddress(basePos + 23); - case 0x01000000: return ComplexObjectAddress(basePos + 24); - case 0x02000000: return ComplexObjectAddress(basePos + 25); - case 0x04000000: return ComplexObjectAddress(basePos + 26); - case 0x08000000: return ComplexObjectAddress(basePos + 27); - case 0x10000000: return ComplexObjectAddress(basePos + 28); - case 0x20000000: return ComplexObjectAddress(basePos + 29); - case 0x40000000: return ComplexObjectAddress(basePos + 30); - case 0x80000000: return ComplexObjectAddress(basePos + 31); - default: break; - } - } - return 0; + switch(result) { + // Make the corresponfing bit 0 so block is no longer free. + case 0x00000001: return ComplexObjectAddress(basePos + 0); + case 0x00000002: return ComplexObjectAddress(basePos + 1); + case 0x00000004: return ComplexObjectAddress(basePos + 2); + case 0x00000008: return ComplexObjectAddress(basePos + 3); + case 0x00000010: return ComplexObjectAddress(basePos + 4); + case 0x00000020: return ComplexObjectAddress(basePos + 5); + case 0x00000040: return ComplexObjectAddress(basePos + 6); + case 0x00000080: return ComplexObjectAddress(basePos + 7); + case 0x00000100: return ComplexObjectAddress(basePos + 8); + case 0x00000200: return ComplexObjectAddress(basePos + 9); + case 0x00000400: return ComplexObjectAddress(basePos + 10); + case 0x00000800: return ComplexObjectAddress(basePos + 11); + case 0x00001000: return ComplexObjectAddress(basePos + 12); + case 0x00002000: return ComplexObjectAddress(basePos + 13); + case 0x00004000: return ComplexObjectAddress(basePos + 14); + case 0x00008000: return ComplexObjectAddress(basePos + 15); + case 0x00010000: return ComplexObjectAddress(basePos + 16); + case 0x00020000: return ComplexObjectAddress(basePos + 17); + case 0x00040000: return ComplexObjectAddress(basePos + 18); + case 0x00080000: return ComplexObjectAddress(basePos + 19); + case 0x00100000: return ComplexObjectAddress(basePos + 20); + case 0x00200000: return ComplexObjectAddress(basePos + 21); + case 0x00400000: return ComplexObjectAddress(basePos + 22); + case 0x00800000: return ComplexObjectAddress(basePos + 23); + case 0x01000000: return ComplexObjectAddress(basePos + 24); + case 0x02000000: return ComplexObjectAddress(basePos + 25); + case 0x04000000: return ComplexObjectAddress(basePos + 26); + case 0x08000000: return ComplexObjectAddress(basePos + 27); + case 0x10000000: return ComplexObjectAddress(basePos + 28); + case 0x20000000: return ComplexObjectAddress(basePos + 29); + case 0x40000000: return ComplexObjectAddress(basePos + 30); + case 0x80000000: return ComplexObjectAddress(basePos + 31); + default: break; + } + } + return 0; } MemClass* BitMapEntry::ComplexObjectAddress(int pos) { - SetBit(pos, false); - return &((static_cast(Head()) + (pos / INT_SIZE)) [INT_SIZE - (pos % INT_SIZE + 1)]); + SetBit(pos, false); + return &((static_cast(Head()) + (pos / INT_SIZE)) [INT_SIZE - (pos % INT_SIZE + 1)]); } void* BitMapEntry::Head(void) { - return gMemManager.GetMemoryPoolList()[index]; + return gMemManager.GetMemoryPoolList()[index]; } void* MemManager::Allocate(size_t size) { - // None array. - if(size == sizeof(MemClass)) { - set::iterator freeMapI = _freeMapEntries.begin(); - if(freeMapI != _freeMapEntries.end()) { - BitMapEntry* mapEntry = *freeMapI; - return mapEntry->FirstFreeBlock(size); - } else { - AllocateChunkAndInitBitMap(); - _freeMapEntries.insert(&(_bitMapEntryList[_bitMapEntryList.size() - 1])); - return _bitMapEntryList[_bitMapEntryList.size() - 1].FirstFreeBlock(size); - } - } else { - // Array. - if(_arrayMemoryList.empty()) { - return AllocateArrayMemory(size); - } else { - map::iterator infoI = _arrayMemoryList.begin(); - map::iterator infoEndI = _arrayMemoryList.end(); + // None array. + if(size == sizeof(MemClass)) { + set::iterator freeMapI = _freeMapEntries.begin(); + if(freeMapI != _freeMapEntries.end()) { + BitMapEntry* mapEntry = *freeMapI; + return mapEntry->FirstFreeBlock(size); + } else { + AllocateChunkAndInitBitMap(); + _freeMapEntries.insert(&(_bitMapEntryList[_bitMapEntryList.size() - 1])); + return _bitMapEntryList[_bitMapEntryList.size() - 1].FirstFreeBlock(size); + } + } else { + // Array. + if(_arrayMemoryList.empty()) { + return AllocateArrayMemory(size); + } else { + map::iterator infoI = _arrayMemoryList.begin(); + map::iterator infoEndI = _arrayMemoryList.end(); - while(infoI != infoEndI) { - ArrayMemoryInfo info = (*infoI).second; - if(info.StartPosition != 0) - // Only search the memory blocks where allocation - // is done from first byte. - continue; - else { - BitMapEntry* entry = &_bitMapEntryList[info.memPoolListIndex]; - if(entry->blocksAvailable < (size / sizeof(MemClass))) - return AllocateArrayMemory(size); - else { - info.StartPosition = BIT_MAP_SIZE - entry->blocksAvailable; - info.Size = size / sizeof(MemClass); - MemClass* baseAddress = static_cast(_memoryPoolList[info.memPoolListIndex]) + info.StartPosition; + while(infoI != infoEndI) { + ArrayMemoryInfo info = (*infoI).second; + if(info.StartPosition != 0) + // Only search the memory blocks where allocation + // is done from first byte. + continue; + else { + BitMapEntry* entry = &_bitMapEntryList[info.memPoolListIndex]; + if(entry->blocksAvailable < (size / sizeof(MemClass))) + return AllocateArrayMemory(size); + else { + info.StartPosition = BIT_MAP_SIZE - entry->blocksAvailable; + info.Size = size / sizeof(MemClass); + MemClass* baseAddress = static_cast(_memoryPoolList[info.memPoolListIndex]) + info.StartPosition; - _arrayMemoryList[baseAddress] = info; - SetMultipleBlockBits(&info, false); + _arrayMemoryList[baseAddress] = info; + SetMultipleBlockBits(&info, false); - return baseAddress; - } - } - } - } - } - return 0; + return baseAddress; + } + } + } + } + } + return 0; } void* MemManager::AllocateArrayMemory(size_t size) { - void* chunkAddress = AllocateChunkAndInitBitMap(); - ArrayMemoryInfo info; - info.memPoolListIndex = _memoryPoolList.size() - 1; - info.StartPosition = 0; - info.Size = size / sizeof(MemClass); - _arrayMemoryList[chunkAddress] = info; - SetMultipleBlockBits(&info, false); - return chunkAddress; + void* chunkAddress = AllocateChunkAndInitBitMap(); + ArrayMemoryInfo info; + info.memPoolListIndex = _memoryPoolList.size() - 1; + info.StartPosition = 0; + info.Size = size / sizeof(MemClass); + _arrayMemoryList[chunkAddress] = info; + SetMultipleBlockBits(&info, false); + return chunkAddress; } void* MemManager::AllocateChunkAndInitBitMap(void) { - BitMapEntry mapEntry; - MemClass* memoryBeginAddress = reinterpret_cast(new char[sizeof(MemClass) * BIT_MAP_SIZE]); - _memoryPoolList.push_back(memoryBeginAddress); - mapEntry.index = _memoryPoolList.size() - 1; - _bitMapEntryList.push_back(mapEntry); - return memoryBeginAddress; + BitMapEntry mapEntry; + MemClass* memoryBeginAddress = reinterpret_cast(new char[sizeof(MemClass) * BIT_MAP_SIZE]); + _memoryPoolList.push_back(memoryBeginAddress); + mapEntry.index = _memoryPoolList.size() - 1; + _bitMapEntryList.push_back(mapEntry); + return memoryBeginAddress; } void MemManager::Free(void* object) { - if(_arrayMemoryList.find(object) == _arrayMemoryList.end()) - // Simple block deletion. - SetBlockBit(object, true); - else { - // Memory block deletion. - ArrayMemoryInfo *info = &_arrayMemoryList[object]; - SetMultipleBlockBits(info, true); - } + if(_arrayMemoryList.find(object) == _arrayMemoryList.end()) + // Simple block deletion. + SetBlockBit(object, true); + else { + // Memory block deletion. + ArrayMemoryInfo *info = &_arrayMemoryList[object]; + SetMultipleBlockBits(info, true); + } } void MemManager::SetBlockBit(void* object, bool flag) { - int i = _bitMapEntryList.size() - 1; - for(; i >= 0; i--) { - BitMapEntry* bitMap = &_bitMapEntryList[i]; - if((bitMap->Head() <= object) && (&(static_cast(bitMap->Head()))[BIT_MAP_SIZE - 1] >= object)) { - int position = static_cast(object)- static_cast(bitMap->Head()); - bitMap->SetBit(position, flag); - flag ? bitMap->blocksAvailable++ : bitMap->blocksAvailable--; - } - } + int i = _bitMapEntryList.size() - 1; + for(; i >= 0; i--) { + BitMapEntry* bitMap = &_bitMapEntryList[i]; + if((bitMap->Head() <= object) && (&(static_cast(bitMap->Head()))[BIT_MAP_SIZE - 1] >= object)) { + int position = static_cast(object)- static_cast(bitMap->Head()); + bitMap->SetBit(position, flag); + flag ? bitMap->blocksAvailable++ : bitMap->blocksAvailable--; + } + } } void MemManager::SetMultipleBlockBits(ArrayMemoryInfo* info, bool flag) { - BitMapEntry* mapEntry = &_bitMapEntryList[info->memPoolListIndex]; - mapEntry->SetMultipleBits(info->StartPosition, flag, info->Size); + BitMapEntry* mapEntry = &_bitMapEntryList[info->memPoolListIndex]; + mapEntry->SetMultipleBits(info->StartPosition, flag, info->Size); } vector& MemManager::GetMemoryPoolList(void) { - return _memoryPoolList; + return _memoryPoolList; } diff --git a/src/libUnuk/Engine/NPC.cpp b/src/libUnuk/Engine/NPC.cpp index 0aab773..42900e4 100644 --- a/src/libUnuk/Engine/NPC.cpp +++ b/src/libUnuk/Engine/NPC.cpp @@ -17,17 +17,17 @@ void NPC::ForceMove(void) { } void NPC::Update(void) { - // Store the NPC's health. - // int health = GetHealth(); // not referenced + // Store the NPC's health. + // int health = GetHealth(); // not referenced - Move(); + Move(); - if(xVel > 0) directionFacing = FACING_RIGHT; - else if(xVel < 0) directionFacing = FACING_LEFT; - else if(yVel > 0) directionFacing = FACING_DOWN; - else if(yVel < 0) directionFacing = FACING_UP; + if(xVel > 0) directionFacing = FACING_RIGHT; + else if(xVel < 0) directionFacing = FACING_LEFT; + else if(yVel > 0) directionFacing = FACING_DOWN; + else if(yVel < 0) directionFacing = FACING_UP; - _healthBar.SetProgress((float)GetHealth() / 100.0f); + _healthBar.SetProgress((float)GetHealth() / 100.0f); } void NPC::Move(void) { diff --git a/src/libUnuk/Engine/ParticleEmitter.cpp b/src/libUnuk/Engine/ParticleEmitter.cpp index b029fab..7b492c2 100644 --- a/src/libUnuk/Engine/ParticleEmitter.cpp +++ b/src/libUnuk/Engine/ParticleEmitter.cpp @@ -9,72 +9,72 @@ ParticleEmitter::~ParticleEmitter(void) { } void ParticleEmitter::SetXY(int xArg, int yArg) { - x = xArg; - y = yArg; + x = xArg; + y = yArg; } void ParticleEmitter::ForceXY(int xArg, int yArg) { - for(int i = 0; i < _particleCount; i++) { - m_particle[i].x = (float)xArg; - m_particle[i].y = (float)yArg; - } + for(int i = 0; i < _particleCount; i++) { + m_particle[i].x = (float)xArg; + m_particle[i].y = (float)yArg; + } } void ParticleEmitter::SetParticleCount(int countArg) { - _particleCount = countArg; - m_particle.resize(_particleCount); + _particleCount = countArg; + m_particle.resize(_particleCount); - for(int i = 0; i < _particleCount; i++) { - m_particle[i].startTime = SDL_GetTicks(); - } + for(int i = 0; i < _particleCount; i++) { + m_particle[i].startTime = SDL_GetTicks(); + } } void ParticleEmitter::SetParticleSpeed(float speedArg) { - _particleSpeed = speedArg; + _particleSpeed = speedArg; } void ParticleEmitter::SetParticleType(string typeArg) { - if(!_particleTexture) { - SDL_FreeSurface(_particleTexture); - } + if(!_particleTexture) { + SDL_FreeSurface(_particleTexture); + } - string textureFilename = "../Data/Media/Images/Particles/" + typeArg + ".png"; - _particleTexture = LoadImageAlpha(textureFilename.c_str()); + string textureFilename = "../../Data/Media/Images/Particles/" + typeArg + ".png"; + _particleTexture = LoadImageAlpha(textureFilename.c_str()); } void ParticleEmitter::SetParticleLifetime(int lifetimeArg) { - _particleLifetime = lifetimeArg; + _particleLifetime = lifetimeArg; - for(int i = 0; i < _particleCount; i++) { - m_particle[i].lifetime = rand() % _particleLifetime + _particleLifetime / 4; - } + for(int i = 0; i < _particleCount; i++) { + m_particle[i].lifetime = rand() % _particleLifetime + _particleLifetime / 4; + } } void ParticleEmitter::Render(void) { - for(int i = 0; i < _particleCount; i++) { - ApplySurface((int)m_particle[i].x, (int)m_particle[i].y, _particleTexture, screen); - } + for(int i = 0; i < _particleCount; i++) { + ApplySurface((int)m_particle[i].x, (int)m_particle[i].y, _particleTexture, screen); + } } void ParticleEmitter::Update(void) { - for(int i = 0; i < _particleCount; i++) { - if((int)SDL_GetTicks() - m_particle[i].startTime > m_particle[i].lifetime) { - // Reset the x and y coords. - m_particle[i].x = (float)x; - m_particle[i].y = (float)y; + for(int i = 0; i < _particleCount; i++) { + if((int)SDL_GetTicks() - m_particle[i].startTime > m_particle[i].lifetime) { + // Reset the x and y coords. + m_particle[i].x = (float)x; + m_particle[i].y = (float)y; - m_particle[i].xVel = (float)(rand() % 360); - m_particle[i].yVel = (float)(rand() % 360); + m_particle[i].xVel = (float)(rand() % 360); + m_particle[i].yVel = (float)(rand() % 360); - if(rand() % 2) - m_particle[i].xVel = m_particle[i].xVel * -1.0f; - if(rand() % 2) - m_particle[i].yVel = m_particle[i].yVel * -1.0f; + if(rand() % 2) + m_particle[i].xVel = m_particle[i].xVel * -1.0f; + if(rand() % 2) + m_particle[i].yVel = m_particle[i].yVel * -1.0f; - m_particle[i].startTime = SDL_GetTicks(); - } else { - m_particle[i].x += m_particle[i].xVel * _particleSpeed; - m_particle[i].y += m_particle[i].yVel * _particleSpeed; - } - } + m_particle[i].startTime = SDL_GetTicks(); + } else { + m_particle[i].x += m_particle[i].xVel * _particleSpeed; + m_particle[i].y += m_particle[i].yVel * _particleSpeed; + } + } } diff --git a/src/libUnuk/Engine/Spells.cpp b/src/libUnuk/Engine/Spells.cpp new file mode 100644 index 0000000..9de8469 --- /dev/null +++ b/src/libUnuk/Engine/Spells.cpp @@ -0,0 +1,17 @@ +#include "Spells.h" + +Spells::Spells(void) { + +} + +Spells::~Spells(void) { + +} + +void Spells::CastSpell() { + +} + +void Spells::Render(void) { + //_particle->Render(); +} diff --git a/src/libUnuk/Engine/Spells.h b/src/libUnuk/Engine/Spells.h new file mode 100644 index 0000000..b7fc547 --- /dev/null +++ b/src/libUnuk/Engine/Spells.h @@ -0,0 +1,22 @@ +#pragma once +#include "../../Unuk/Player.h" +#include "../System/Timer.h" +#include "ParticleEmitter.h" + +class Spells { +public: + Spells(void); + ~Spells(void); + + enum { + FIREBALL, + ICE + }; + + void CastSpell(/*Player* player*/); + void Render(void); + +private: + Timer* _timeBetweenCast; + ParticleEmitter* _particle; +}; diff --git a/src/libUnuk/Engine/WorldManager.cpp b/src/libUnuk/Engine/WorldManager.cpp index 05bb3b5..23c2806 100644 --- a/src/libUnuk/Engine/WorldManager.cpp +++ b/src/libUnuk/Engine/WorldManager.cpp @@ -188,7 +188,7 @@ void WorldManager::OnPlayerAttack(Player* player) { } void WorldManager::OnPlayerMove(Player* player) { - for(std::list::iterator i = _npcs.begin(); i != _npcs.end(); ++i) { - (*i)->OnPlayerMove(player); - } + for(std::list::iterator i = _npcs.begin(); i != _npcs.end(); ++i) { + (*i)->OnPlayerMove(player); + } } diff --git a/src/libUnuk/Engine/WorldManager.h b/src/libUnuk/Engine/WorldManager.h index 5833abf..9ef2132 100644 --- a/src/libUnuk/Engine/WorldManager.h +++ b/src/libUnuk/Engine/WorldManager.h @@ -1,6 +1,6 @@ #pragma once #include - +#include "MemClass.h" class Character; class NPC; class Player; @@ -10,26 +10,26 @@ class LevelGen; class WorldManager { public: - WorldManager(LevelGen* level); - ~WorldManager(void); + WorldManager(LevelGen* level); + ~WorldManager(void); - void Update(void); - void Render(void); + void Update(void); + void Render(void); - void AddNPC(NPC* npc); - void RemoveNPC(int index); - NPC* GetNPC(int index); - NPC* GetNPCAt(int xArg, int yArg); - void CreateNPC(int x, int y); - - bool CheckCollision(const SDL_Rect& charRect, Character* exclude); + void AddNPC(NPC* npc); + void RemoveNPC(int index); + NPC* GetNPC(int index); + NPC* GetNPCAt(int xArg, int yArg); + void CreateNPC(int x, int y); - int GetNPCCount() { return _npcs.size(); } + bool CheckCollision(const SDL_Rect& charRect, Character* exclude); - void OnPlayerAttack(Player* player); - void OnPlayerMove(Player* player); + int GetNPCCount() { return _npcs.size(); } + + void OnPlayerAttack(Player* player); + void OnPlayerMove(Player* player); private: - LevelGen* _level; - std::list _npcs; + LevelGen* _level; + std::list _npcs; }; diff --git a/src/libUnuk/LevelGen/LevelGen.h b/src/libUnuk/LevelGen/LevelGen.h index e64746e..41a93fb 100644 --- a/src/libUnuk/LevelGen/LevelGen.h +++ b/src/libUnuk/LevelGen/LevelGen.h @@ -15,6 +15,7 @@ #include "../LevelGen/AStarTile.h" #include "../System/Debug.h" #include "../Engine/WorldManager.h" +#include "../Engine/MemClass.h" using namespace std; class Character; @@ -53,8 +54,8 @@ public: WorldManager& GetWorld(void) { return _world; } - void SetPlayer(Player* player) { _player = player; } - + void SetPlayer(Player* player) { _player = player; } + private: void Unload(void); void DoMagic(void); diff --git a/src/libUnuk/LevelGen/MapTile.cpp b/src/libUnuk/LevelGen/MapTile.cpp new file mode 100644 index 0000000..3a461d4 --- /dev/null +++ b/src/libUnuk/LevelGen/MapTile.cpp @@ -0,0 +1,66 @@ +#include "MapTile.h" +#include "LevelGen.h" + +MapTile::MapTile(const MapTile& source) { + _level = source._level; + _tile = source._tile; + _entity = source._entity; + _zLevel = source._zLevel; +} + +bool MapTile::IsSameState(MapTile& tile) { + return (tile.GetTileX() == _tile.GetX()) && (tile.GetTileY() == _tile.GetY()); +} + +bool MapTile::IsGoal(MapTile& tile) { + return IsSameState(tile); +} + +float MapTile::GoalDistanceEstimate(MapTile& goal) { + Vec2 thisPos(_tile.GetX(), _tile.GetY()); + Vec2 goalPos(goal.GetTileX(), goal.GetTileY()); + return fabs(Vec2::DistanceSquared(thisPos, goalPos)); +} + +float MapTile::GetCost(MapTile& goal) { + return 64.0f*64.0f; +} + +bool MapTile::GetSuccessors(AStarSearch* search, MapTile* parent) { + int tileX = _tile.GetX() / TILE_WIDTH; + int tileY = _tile.GetY() / TILE_HEIGHT; + + // Add tile to the left if possible. + if(tileX > 0) { + MapTile& successor = _level->GetTile(tileX - 1, tileY); + if(successor.GetTileSolidity() || successor.GetEntitySolitity()) { + search->AddSuccessor(successor); + } + } + + // Add tile to the right if possible + if(tileX < TILE_WIDTH) { + MapTile& successor = _level->GetTile(tileX + 1, tileY); + if(successor.GetTileSolidity() || successor.GetEntitySolitity()) { + search->AddSuccessor(successor); + } + } + + // Add tile to the bottom if possible + if(tileY > 0) { + MapTile& successor = _level->GetTile(tileX, tileY - 1); + if(successor.GetTileSolidity() || successor.GetEntitySolitity()) { + search->AddSuccessor(successor); + } + } + + // Add tile to the top if possible + if(tileY < TILE_HEIGHT) { + MapTile& successor = _level->GetTile(tileX, tileY + 1); + if(successor.GetTileSolidity() || successor.GetEntitySolitity()) { + search->AddSuccessor(successor); + } + } + + return true; +} diff --git a/src/libUnuk/LevelGen/MapTile.h b/src/libUnuk/LevelGen/MapTile.h index 10682e4..3196e34 100644 --- a/src/libUnuk/LevelGen/MapTile.h +++ b/src/libUnuk/LevelGen/MapTile.h @@ -14,7 +14,7 @@ public: MapTile(void) { } ~MapTile(void) { } - void Render(void) { _tile.Render(), _entity.Render(); } + void Render(void) { _tile.Render(), _entity.Render(); } // Tile Mutators. SDL_Surface* SetTileTexture(SDL_Surface* arg) { _tile.SetTexture(arg); return NULL; } @@ -29,29 +29,30 @@ public: int GetTileX(void) { return _tile.GetX(); } int GetTileY(void) { return _tile.GetY(); } - // Entity Mutators. - void SetEntityTexture(SDL_Surface* arg) { _entity.SetTexture(arg); } - void SetEntityTextureName(string path) { _entity.SetTextureName(path); } - void SetEntityXY(int xArg, int yArg) { _entity.SetXY(xArg, yArg); } - void SetEntitySolidity(bool arg) { _entity.SetSolidity(arg); } - bool GetEntitySolitity(void) { return _entity.GetSolidity(); } - // Entity Mutators. - int GetEntityX(void) { return _entity.GetX(); } - int GetEntityY(void) { return _entity.GetY(); } - int GetEntityWidth(void) { return _entity.GetWidth(); } - int GetEntityHeight(void) { return _entity.GetHeight(); } - string GetEntityTextureName(void) { return _entity.GetTextureName(); } + // Entity Mutators. + void SetEntityTexture(SDL_Surface* arg) { _entity.SetTexture(arg); } + void SetEntityTextureName(string path) { _entity.SetTextureName(path); } + void SetEntityXY(int xArg, int yArg) { _entity.SetXY(xArg, yArg); } + void SetEntitySolidity(bool arg) { _entity.SetSolidity(arg); } + bool GetEntitySolitity(void) { return _entity.GetSolidity(); } + + // Entity Mutators. + int GetEntityX(void) { return _entity.GetX(); } + int GetEntityY(void) { return _entity.GetY(); } + int GetEntityWidth(void) { return _entity.GetWidth(); } + int GetEntityHeight(void) { return _entity.GetHeight(); } + string GetEntityTextureName(void) { return _entity.GetTextureName(); } // ZLevel Mutators. - void SetZLevel(int arg) { _zLevel = arg; } - int GetZLevel(void) { return _zLevel; } + void SetZLevel(int arg) { _zLevel = arg; } + int GetZLevel(void) { return _zLevel; } private: MapElement _tile; MapEntityGeneric _entity; - // -1 is a 'special' tile, the next tile that the player walks - // on is the players new zlevel. - int _zLevel; + // -1 is a 'special' tile, the next tile that the player walks + // on is the players new zlevel. + int _zLevel; };