[Fix?] Attempting to fix some seg faults. It seems KonoM's recource management is causing problems.
This commit is contained in:
parent
06171f3671
commit
1a2ba29855
@ -9,11 +9,11 @@ Player::Player(void) {
|
|||||||
|
|
||||||
// Loading of sprites and collision details.
|
// Loading of sprites and collision details.
|
||||||
// This should be directed to a collision sheet.
|
// This should be directed to a collision sheet.
|
||||||
_collisionBound = new AABB();
|
//_collisionBound = new AABB();
|
||||||
_collisionBound->CreateAABBFromSprite("../Data/Img/Player");
|
//_collisionBound->CreateAABBFromSprite("../Data/Img/Player");
|
||||||
|
|
||||||
_environmentCollisionBound = new AABB();
|
//_environmentCollisionBound = new AABB();
|
||||||
_environmentCollisionBound->SetMin(_collisionBound->GetMin().x, _collisionBound->GetMax().y - 50.0f);
|
//_environmentCollisionBound->SetMin(_collisionBound->GetMin().x, _collisionBound->GetMax().y - 50.0f);
|
||||||
//_environmentCollisionBound->SetMax(_collisionBound->GetMax());
|
//_environmentCollisionBound->SetMax(_collisionBound->GetMax());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,13 +23,15 @@ Player::~Player(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Player::Update(void) {
|
void Player::Update(void) {
|
||||||
_player->LoadSprite("../Data/Img/Player.png");
|
if(!_player) {
|
||||||
|
_player->LoadSprite("../Data/Img/Player.png");
|
||||||
|
}
|
||||||
// Position and collision bound with the player.
|
// Position and collision bound with the player.
|
||||||
_collisionBound->SetPositionOffset(_player->GetX(), _player->GetY());
|
//_collisionBound->SetPositionOffset(_player->GetX(), _player->GetY());
|
||||||
//_environmentCollisionBound->SetPositionOffset(_player->GetX, _player->GetY());
|
//_environmentCollisionBound->SetPositionOffset(_player->GetX, _player->GetY());
|
||||||
|
|
||||||
// Time to process the collisions.
|
// Time to process the collisions.
|
||||||
ProcessCollisions();
|
//ProcessCollisions();
|
||||||
|
|
||||||
// Process events here.
|
// Process events here.
|
||||||
ProcessEvents();
|
ProcessEvents();
|
||||||
@ -43,8 +45,8 @@ void Player::Render(void) {
|
|||||||
void Player::ProcessCollisions(void) {
|
void Player::ProcessCollisions(void) {
|
||||||
// Process collisions with entities and actors.
|
// Process collisions with entities and actors.
|
||||||
// We should ensure we are not dead.
|
// We should ensure we are not dead.
|
||||||
EntityCollisionTest();
|
//EntityCollisionTest();
|
||||||
ActorCollisionTest();
|
//ActorCollisionTest();
|
||||||
|
|
||||||
// Set all collision flags to false conditions
|
// Set all collision flags to false conditions
|
||||||
// then they will need to be proven in the test.
|
// then they will need to be proven in the test.
|
||||||
|
@ -71,14 +71,14 @@ void AABB::CreateAABBFromSprite(const char* filename) {
|
|||||||
for(int height = 0; height < _sprite->GetHeight(); height++) {
|
for(int height = 0; height < _sprite->GetHeight(); height++) {
|
||||||
// FUCKING PAIN IN THE ASS MOTHERFUCKER!!!!
|
// FUCKING PAIN IN THE ASS MOTHERFUCKER!!!!
|
||||||
DWORD offset = height * screen->pitch + width;
|
DWORD offset = height * screen->pitch + width;
|
||||||
if(((DWORD)pixels[offset]) != 0 && !found) {
|
// if(((DWORD)pixels[offset]) != 0 && !found) {
|
||||||
_min = Vec2((float)width, (float)height);
|
// _min = Vec2((float)width, (float)height);
|
||||||
found = true;
|
// found = true;
|
||||||
color = ((DWORD)pixels[offset]);
|
// color = ((DWORD)pixels[offset]);
|
||||||
// Break out of these god forsaken loops.
|
// // Break out of these god forsaken loops.
|
||||||
width = _sprite->GetWidth();
|
// width = _sprite->GetWidth();
|
||||||
height = _sprite->GetHeight();
|
// height = _sprite->GetHeight();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,10 +87,10 @@ void AABB::CreateAABBFromSprite(const char* filename) {
|
|||||||
found = false;
|
found = false;
|
||||||
for(int width = (int)_min.x; width < _sprite->GetWidth(); width++) {
|
for(int width = (int)_min.x; width < _sprite->GetWidth(); width++) {
|
||||||
DWORD offset = _min.y * screen->pitch + width;
|
DWORD offset = _min.y * screen->pitch + width;
|
||||||
if(((DWORD)pixels[offset] != color && !found)) {
|
// if(((DWORD)pixels[offset] != color && !found)) {
|
||||||
found = true;
|
// found = true;
|
||||||
_max.x = (float)width;
|
// _max.x = (float)width;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now for the max.y
|
// Now for the max.y
|
||||||
@ -98,11 +98,11 @@ void AABB::CreateAABBFromSprite(const char* filename) {
|
|||||||
found = false;
|
found = false;
|
||||||
for(int height = (int)_min.y; height < _sprite->GetWidth(); height++) {
|
for(int height = (int)_min.y; height < _sprite->GetWidth(); height++) {
|
||||||
DWORD offset = (DWORD)(height * screen->pitch + _min.x);
|
DWORD offset = (DWORD)(height * screen->pitch + _min.x);
|
||||||
if(((DWORD)pixels[offset]) != color && !found) {
|
// if(((DWORD)pixels[offset]) != color && !found) {
|
||||||
found = true;
|
// found = true;
|
||||||
_max.y = (float)height;
|
// _max.y = (float)height;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
_staticMax = _max;
|
_staticMax = _max;
|
||||||
_staticMin = _min;
|
_staticMin = _min;
|
||||||
|
@ -35,7 +35,7 @@ bool Game::Init(void) {
|
|||||||
glAlphaFunc(GL_GREATER, 0.1f);
|
glAlphaFunc(GL_GREATER, 0.1f);
|
||||||
|
|
||||||
_level->Load("../Data/Map/Ugly.tmx");
|
_level->Load("../Data/Map/Ugly.tmx");
|
||||||
|
_player->Update();
|
||||||
// Return success.
|
// Return success.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ public:
|
|||||||
float GetX(void) { return position.x; }
|
float GetX(void) { return position.x; }
|
||||||
float GetY(void) { return position.y; }
|
float GetY(void) { return position.y; }
|
||||||
const Vec2& GetSize() const { return size; }
|
const Vec2& GetSize() const { return size; }
|
||||||
float GetWidth() const { return size.x; }
|
float GetWidth() { return size.x; }
|
||||||
float GetHeight() const { return size.y; }
|
float GetHeight() { return size.y; }
|
||||||
const Vec2& GetScale() const { return scale; }
|
const Vec2& GetScale() const { return scale; }
|
||||||
float GetRotation() const { return rotation; }
|
float GetRotation() const { return rotation; }
|
||||||
Texture* GetTexture() { return texture; }
|
Texture* GetTexture() { return texture; }
|
||||||
|
@ -34,100 +34,100 @@
|
|||||||
|
|
||||||
class TiXmlNode;
|
class TiXmlNode;
|
||||||
|
|
||||||
namespace Tmx
|
namespace Tmx
|
||||||
{
|
{
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Type used for the encoding of the layer data.
|
// Type used for the encoding of the layer data.
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
enum LayerEncodingType
|
enum LayerEncodingType
|
||||||
{
|
{
|
||||||
TMX_ENCODING_XML,
|
TMX_ENCODING_XML,
|
||||||
TMX_ENCODING_BASE64,
|
TMX_ENCODING_BASE64,
|
||||||
TMX_ENCODING_CSV
|
TMX_ENCODING_CSV
|
||||||
};
|
};
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Type used for the compression of the layer data.
|
// Type used for the compression of the layer data.
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
enum LayerCompressionType
|
enum LayerCompressionType
|
||||||
{
|
{
|
||||||
TMX_COMPRESSION_NONE,
|
TMX_COMPRESSION_NONE,
|
||||||
TMX_COMPRESSION_ZLIB,
|
TMX_COMPRESSION_ZLIB,
|
||||||
TMX_COMPRESSION_GZIP
|
TMX_COMPRESSION_GZIP
|
||||||
};
|
};
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Used for storing information about the tile ids for every layer.
|
// Used for storing information about the tile ids for every layer.
|
||||||
// This class also have a property set.
|
// This class also have a property set.
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
class Layer
|
class Layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Layer();
|
Layer();
|
||||||
~Layer();
|
~Layer();
|
||||||
|
|
||||||
// Parse a layer node.
|
// Parse a layer node.
|
||||||
void Parse(const TiXmlNode *layerNode);
|
void Parse(const TiXmlNode *layerNode);
|
||||||
|
|
||||||
// Get the name of the layer.
|
// Get the name of the layer.
|
||||||
const std::string &GetName() const { return name; }
|
const std::string &GetName() const { return name; }
|
||||||
|
|
||||||
// Get the width of the layer, in tiles.
|
// Get the width of the layer, in tiles.
|
||||||
int GetWidth() const { return width; }
|
float GetWidth() const { return width; }
|
||||||
|
|
||||||
// Get the height of the layer, in tiles.
|
// Get the height of the layer, in tiles.
|
||||||
int GetHeight() const { return height; }
|
float GetHeight() const { return height; }
|
||||||
|
|
||||||
// Get the visibility of the layer
|
// Get the visibility of the layer
|
||||||
bool IsVisible() const { return visible; }
|
bool IsVisible() const { return visible; }
|
||||||
|
|
||||||
// Get the property set.
|
// Get the property set.
|
||||||
const PropertySet &GetProperties() const { return properties; }
|
const PropertySet &GetProperties() const { return properties; }
|
||||||
|
|
||||||
// Pick a specific tile from the list.
|
// Pick a specific tile from the list.
|
||||||
unsigned GetTileGid(int x, int y) const { return tile_map[y * width + x].gid; }
|
unsigned GetTileGid(int x, int y) const { return tile_map[y * width + x].gid; }
|
||||||
|
|
||||||
// Get whether the tile is flipped horizontally.
|
// Get whether the tile is flipped horizontally.
|
||||||
bool IsTileFlippedHorizontally(int x, int y) const
|
bool IsTileFlippedHorizontally(int x, int y) const
|
||||||
{ return tile_map[y * width + x].flippedHorizontally; }
|
{ return tile_map[y * width + x].flippedHorizontally; }
|
||||||
|
|
||||||
// Get whether the tile is flipped vertically.
|
// Get whether the tile is flipped vertically.
|
||||||
bool IsTileFlippedVertically(int x, int y) const
|
bool IsTileFlippedVertically(int x, int y) const
|
||||||
{ return tile_map[y * width + x].flippedVertically; }
|
{ return tile_map[y * width + x].flippedVertically; }
|
||||||
|
|
||||||
// Get whether the tile is flipped diagonally.
|
// Get whether the tile is flipped diagonally.
|
||||||
bool IsTileFlippedDiagonally(int x, int y) const
|
bool IsTileFlippedDiagonally(int x, int y) const
|
||||||
{ return tile_map[y * width + x].flippedDiagonally; }
|
{ return tile_map[y * width + x].flippedDiagonally; }
|
||||||
|
|
||||||
// Get the tile specific to the map.
|
// Get the tile specific to the map.
|
||||||
MapTile GetTile(int x, int y) const { return tile_map[y * width + x]; }
|
MapTile GetTile(int x, int y) const { return tile_map[y * width + x]; }
|
||||||
|
|
||||||
// Get the type of encoding that was used for parsing the layer data.
|
// Get the type of encoding that was used for parsing the layer data.
|
||||||
// See: LayerEncodingType
|
// See: LayerEncodingType
|
||||||
LayerEncodingType GetEncoding() const { return encoding; }
|
LayerEncodingType GetEncoding() const { return encoding; }
|
||||||
|
|
||||||
// Get the type of compression that was used for parsing the layer data.
|
// Get the type of compression that was used for parsing the layer data.
|
||||||
// See: LayerCompressionType
|
// See: LayerCompressionType
|
||||||
LayerCompressionType GetCompression() const { return compression; }
|
LayerCompressionType GetCompression() const { return compression; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ParseXML(const TiXmlNode *dataNode);
|
void ParseXML(const TiXmlNode *dataNode);
|
||||||
void ParseBase64(const std::string &innerText);
|
void ParseBase64(const std::string &innerText);
|
||||||
void ParseCSV(const std::string &innerText);
|
void ParseCSV(const std::string &innerText);
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
|
|
||||||
float opacity;
|
|
||||||
bool visible;
|
|
||||||
|
|
||||||
PropertySet properties;
|
int width;
|
||||||
|
int height;
|
||||||
|
|
||||||
MapTile *tile_map;
|
float opacity;
|
||||||
|
bool visible;
|
||||||
|
|
||||||
LayerEncodingType encoding;
|
PropertySet properties;
|
||||||
LayerCompressionType compression;
|
|
||||||
};
|
MapTile *tile_map;
|
||||||
};
|
|
||||||
|
LayerEncodingType encoding;
|
||||||
|
LayerCompressionType compression;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user