Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Unhandled Exception  (Read 1254 times)

0 Members and 2 Guests are viewing this topic.

Paki Programmer

  • Newbie
  • *
  • Posts: 31
    • View Profile
Unhandled Exception
« on: January 27, 2012, 02:46:38 am »
I dont know what im doing wrong but for some reason I keep getting an unhandled exception my my entity manager. I try to draw the sprite to the screen and right before the entity manager updates and trys to draw it everything is fine. But as soon as it attempts to draw the sprite i get an exception. Here's the code. Can someone please help me ? This is driving me nuts :( if you need the whole project just let me know and ill email it to you

//Game.cpp

Code: [Select]

#include "EntityManager.h"

void System::Init()
{
engine = new System();

engine -> SetWindow(800, 600, "Test");

Entity player;
player.Load("test.png", 100, 100);

manager.Add(player);
}

void System::Run()
{
sf::Event ev;

while (engine -> window -> IsOpened())
{
engine -> window -> PollEvent(ev);


engine -> window -> Clear();
manager.Update();
engine -> window -> Display();
}
}


//System.cpp

Code: [Select]

#include "System.h"

void System::SetScreenDim(int width, int height)
{
this -> SCREENW = width;
this -> SCREENH = height;
}

void System::SetTitle(std::string title)
{
this -> Title = title;
}

void System::SetWindow(int width, int height, std::string title)
{
this -> SCREENW = width;
this -> SCREENH = height;
this -> window = new sf::RenderWindow(sf::VideoMode(width, height), title.c_str());
}


//EntityManager.cpp

Code: [Select]

#include "EntityManager.h"
#include "System.h"

void Manager::Update()
{
Entity entity;

std::list<Entity>::iterator iter = eList.begin();

while (iter != eList.end())
{
entity = *iter;

entity.GetSprite().SetPosition(entity.GetX(), entity.GetY());

engine -> window -> Draw(entity.GetSprite());

iter++;
}
}

void Manager::Add(Entity entity)
{
eList.push_back(entity);
}


//Entity.cpp

Code: [Select]

#include "Entity.h"

void Entity::Load(std::string filename, float x, float y)
{
this -> Filename = filename;

this -> Image.LoadFromFile(this -> Filename.c_str());
this -> Sprite.SetImage(this -> Image);

this -> posx = x;
this -> posy = y;
}

void Entity::Update()
{
this -> Sprite.SetPosition(this -> posx, this -> posy);
}
[/code]

 

anything