[Fix?] Attempting to fix some seg faults. It seems KonoM's recource management is causing problems.

This commit is contained in:
Rtch90 2012-04-12 15:04:46 +01:00
parent 06171f3671
commit 1a2ba29855
5 changed files with 107 additions and 105 deletions

View File

@ -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) {
if(!_player) {
_player->LoadSprite("../Data/Img/Player.png"); _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.

View File

@ -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;

View File

@ -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;
} }

View File

@ -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; }

View File

@ -73,10 +73,10 @@ namespace Tmx
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; }