Right, ill start from the beginning so it will be alittle easier to read through,
When ever i run my program it shows everything as it should. i can even walk around with my player for a bit, but suddenly after 10-15 seconds it just dies saying that its out of memory. i have no idea what this means as i have never had this problem before with ealier programs i have made.
here is the code the problem comes from (well that is the code i get shown)
private void Render()
{
dc.DrawImage(Image.FromFile("Graphics/WorldAreas/Starting-room.png"), 0, 0);
foreach (GameObject go in gameWorld)
{
go.Render(dc);
}
bg.Render();
}
After the few seconds it highlights "dc.DrawImage" and says that OutOfMemoryException was unhandled.
before i rewrote this i saw that someone asked for the gameobject so ill add the code for that as well
public abstract class GameObject
{
protected PointF position; //X,Y Position in the Game World
public PointF Position
{
get { return position; }
}
protected Image sprite;
public virtual void Move(float factor)
{
}
public virtual void Render(Graphics dc)
{
dc.DrawImage(sprite, position.X, position.Y, sprite.Width, sprite.Height);
//dc.DrawRectangle(new Pen(Color.Red), CollisionRectangle);
}
}
hopefully this was a better explaination. and hopefully someone can see the error that i cannot.
thanks in advance :)
GameObjectclass as this is where the exception is happening and remove the wall of code you have posted.Starting-room.pngfrom disk in every frame Render for a start.