is this better for setting the color:
[FONT=monospace]
int game_init(void)
{
int result = 0;
/* First open the graphics.library */
GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0L);
/* was the graphics library opened? */
if(GfxBase != NULL)
{
/* Second open the intuition.library. */
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0L);
/* was the library opened? */
if (IntuitionBase != NULL)
{
/* since the was opened, we can open a window. */
GameWindow = (struct Window *)OpenWindowTags(NULL,
WA_Left, 20,
WA_Top, 20,
WA_Width, 200,
WA_Height, 200,
WA_Title, (ULONG)"Omega Space Protons",
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_SizeGadget, TRUE,
WA_DragBar, TRUE,
WA_GimmeZeroZero, TRUE,
WA_ReportMouse, TRUE,
WA_IDCMP, IDCMP_CLOSEWINDOW,
TAG_END);
/* was the window opened? */
if (GameWindow == NULL)
{
/* The window was not opened so display a message. */
printf("Unable to open the window!\n");
result = -1;
}
}
else
{
/* the library was not opened, so display a message */
printf("Unable to open the intuition.library!\n");
result = -2;
}
}
else
{
/* The graphics.library was not opened so display amessage. */
printf("Unable to open the graphics.library!\n");
}
[/FONT]
blue = ObtainBestPenA(GameWindow->WScreen->ViewPort.ColorMap, 0x0, 0x0, 0xFFFFFFFF, NULL);
if(blue = -1)
{
printf("Unable to obtain pen for the color blue!\n");
}
[FONT=monospace]
return result;
}[/FONT]
then inside my game loop:
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;
}
finally in the game loop:
void game_loop(void)
{
ULONG signals;
ULONG window_signal;
struct IntuiMessage *message;
UWORD msg_code;
ULONG msg_class;
BOOL end = FALSE;
LONG pen;
/* define the window signal */
window_signal = 1L << GameWindow->UserPort->mp_SigBit;
/* Main game loop */
/* Wait until the close button is pressed */
while (!end && GameWindow)
{
signals = Wait(window_signal);
/* check the signal bit forour message port. Will be trueif there is a message */
if (signals & ( 1L << GameWindow->UserPort->mp_SigBit))
{
/* there may be more then one message, so keep processing messages until there are no more. */
while (message = (struct IntuiMessage *)GetMsg(GameWindow->UserPort))
{
/* Copy the necessary infomation from the message. */
msg_class = message->Class;
msg_code = message->Code;
/* Reply as soon as possible. */
ReplyMsg( (struct Message *)message) ;
/* Take the proper action in response to the message */
switch(msg_class)
{
/* User pressed the close window gadget */
case IDCMP_CLOSEWINDOW:
end = TRUE;
break;
/* default action */
default:
break;
}
}
}
/* set the pen color to blue */
SetPen(GameWindow->RPort, blue);
/* Draw the ball */
WritePixel(GameWindow->RPort, 100, 100);
}
return;
}