and in the cleanup function:
void clean_up(void)
{
/* If thw window is open, close it */
if(GameWindow != NULL)
{
CloseWindow(GameWindow);
}
/* If the intuition.library is open, close it */
if(IntuitionBase != NULL)
{
CloseLibrary((struct Library *)IntuitionBase);
}
/* If the graphics.library is open, close it */
if(GfxBase != NULL)
{
CloseLibrary((struct Library *)GfxBase);
}
ReleasePen(GameWindow->WScreen->ViewPort.ColorMap, blue);
return;
}
You're referencing a dangling pointer here. GameWindow is a pointer to released memory (CloseWindow() has already released the memory at this point). Thus you will get a random WScreen pointer and further pain.
Depending on your luck it might crash only occasionally. It much depends on how busy your system is.