[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.
|
||||
// This should be directed to a collision sheet.
|
||||
_collisionBound = new AABB();
|
||||
_collisionBound->CreateAABBFromSprite("../Data/Img/Player");
|
||||
//_collisionBound = new AABB();
|
||||
//_collisionBound->CreateAABBFromSprite("../Data/Img/Player");
|
||||
|
||||
_environmentCollisionBound = new AABB();
|
||||
_environmentCollisionBound->SetMin(_collisionBound->GetMin().x, _collisionBound->GetMax().y - 50.0f);
|
||||
//_environmentCollisionBound = new AABB();
|
||||
//_environmentCollisionBound->SetMin(_collisionBound->GetMin().x, _collisionBound->GetMax().y - 50.0f);
|
||||
//_environmentCollisionBound->SetMax(_collisionBound->GetMax());
|
||||
}
|
||||
|
||||
@ -23,13 +23,15 @@ Player::~Player(void) {
|
||||
}
|
||||
|
||||
void Player::Update(void) {
|
||||
if(!_player) {
|
||||
_player->LoadSprite("../Data/Img/Player.png");
|
||||
}
|
||||
// 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());
|
||||
|
||||
// Time to process the collisions.
|
||||
ProcessCollisions();
|
||||
//ProcessCollisions();
|
||||
|
||||
// Process events here.
|
||||
ProcessEvents();
|
||||
@ -43,8 +45,8 @@ void Player::Render(void) {
|
||||
void Player::ProcessCollisions(void) {
|
||||
// Process collisions with entities and actors.
|
||||
// We should ensure we are not dead.
|
||||
EntityCollisionTest();
|
||||
ActorCollisionTest();
|
||||
//EntityCollisionTest();
|
||||
//ActorCollisionTest();
|
||||
|
||||
// Set all collision flags to false conditions
|
||||
// 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++) {
|
||||
// FUCKING PAIN IN THE ASS MOTHERFUCKER!!!!
|
||||
DWORD offset = height * screen->pitch + width;
|
||||
if(((DWORD)pixels[offset]) != 0 && !found) {
|
||||
_min = Vec2((float)width, (float)height);
|
||||
found = true;
|
||||
color = ((DWORD)pixels[offset]);
|
||||
// Break out of these god forsaken loops.
|
||||
width = _sprite->GetWidth();
|
||||
height = _sprite->GetHeight();
|
||||
}
|
||||
// if(((DWORD)pixels[offset]) != 0 && !found) {
|
||||
// _min = Vec2((float)width, (float)height);
|
||||
// found = true;
|
||||
// color = ((DWORD)pixels[offset]);
|
||||
// // Break out of these god forsaken loops.
|
||||
// width = _sprite->GetWidth();
|
||||
// height = _sprite->GetHeight();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,10 +87,10 @@ void AABB::CreateAABBFromSprite(const char* filename) {
|
||||
found = false;
|
||||
for(int width = (int)_min.x; width < _sprite->GetWidth(); width++) {
|
||||
DWORD offset = _min.y * screen->pitch + width;
|
||||
if(((DWORD)pixels[offset] != color && !found)) {
|
||||
found = true;
|
||||
_max.x = (float)width;
|
||||
}
|
||||
// if(((DWORD)pixels[offset] != color && !found)) {
|
||||
// found = true;
|
||||
// _max.x = (float)width;
|
||||
// }
|
||||
}
|
||||
|
||||
// Now for the max.y
|
||||
@ -98,11 +98,11 @@ void AABB::CreateAABBFromSprite(const char* filename) {
|
||||
found = false;
|
||||
for(int height = (int)_min.y; height < _sprite->GetWidth(); height++) {
|
||||
DWORD offset = (DWORD)(height * screen->pitch + _min.x);
|
||||
if(((DWORD)pixels[offset]) != color && !found) {
|
||||
found = true;
|
||||
_max.y = (float)height;
|
||||
break;
|
||||
}
|
||||
// if(((DWORD)pixels[offset]) != color && !found) {
|
||||
// found = true;
|
||||
// _max.y = (float)height;
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
_staticMax = _max;
|
||||
_staticMin = _min;
|
||||
|
@ -35,7 +35,7 @@ bool Game::Init(void) {
|
||||
glAlphaFunc(GL_GREATER, 0.1f);
|
||||
|
||||
_level->Load("../Data/Map/Ugly.tmx");
|
||||
|
||||
_player->Update();
|
||||
// Return success.
|
||||
return true;
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ public:
|
||||
float GetX(void) { return position.x; }
|
||||
float GetY(void) { return position.y; }
|
||||
const Vec2& GetSize() const { return size; }
|
||||
float GetWidth() const { return size.x; }
|
||||
float GetHeight() const { return size.y; }
|
||||
float GetWidth() { return size.x; }
|
||||
float GetHeight() { return size.y; }
|
||||
const Vec2& GetScale() const { return scale; }
|
||||
float GetRotation() const { return rotation; }
|
||||
Texture* GetTexture() { return texture; }
|
||||
|
@ -73,10 +73,10 @@ namespace Tmx
|
||||
const std::string &GetName() const { return name; }
|
||||
|
||||
// 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.
|
||||
int GetHeight() const { return height; }
|
||||
float GetHeight() const { return height; }
|
||||
|
||||
// Get the visibility of the layer
|
||||
bool IsVisible() const { return visible; }
|
||||
|
Loading…
Reference in New Issue
Block a user