Okay. For an unspecified project of mine, I've been toying around with custom "lighting" functions - as in, having one function for drawing holes into an all-black GUI and one for covering up these holes again once it's time. The former works just fine... the latter doesn't seem to run at all. It's probably soul-crushingly simple, but I just can't see what's wrong with the code. So, uh, some help please?

The relevant code:
game_start
[code]
tempsprite=DynamicSprite.CreateFromExistingSprite(gGui1.BackgroundGraphic);
int MNB=0;
while (MNB<MaximumLightSources) {
lightR[MNB]=-1;
MNB++;}
//Other crap
[/code]
repeatedly_execute
[code]
jiji=0;
while (jiji<MaximumLightSources) {
player.SayBackground(String.Format("%d", jiji));
if (lightR[jiji]>-1) {
lightT[jiji]--;
if (lightT[jiji]<=0) RemoveLightSource(jiji);
}
jiji++;
}
//Some stuff about calculating sound[0]
temprad=FloatToInt(sound[0]*2.0);
PlaceLightSource(player.x, player.y, temprad, 1);
//Some stuff about movement
[/code]
The functions in question
[code]
function PlaceLightSource(int x, int y, int radius, int time) {
int countIndex=0;
while ((countIndex<MaximumLightSources)&&(lightR[countIndex]==-1)) countIndex++;
DrawingSurface *lightmap=tempsprite.GetDrawingSurface();
lightX[countIndex]=x;
lightY[countIndex]=y;
lightR[countIndex]=radius+1;
lightT[countIndex]=time+1;
lightmap.DrawingColor=COLOR_TRANSPARENT;
lightmap.DrawCircle(x, y, radius);
lightmap.Release();
gGui1.BackgroundGraphic=tempsprite.Graphic;
}
function RemoveLightSource(int lightSourceNumber) {
DrawingSurface *darkmap=tempsprite.GetDrawingSurface();
darkmap.DrawingColor=33;
darkmap.DrawCircle(lightX[lightSourceNumber], lightY[lightSourceNumber], lightR[lightSourceNumber]+1);
darkmap.Release();
gGui1.BackgroundGraphic=tempsprite.Graphic;
lightX[lightSourceNumber]=-1;
lightY[lightSourceNumber]=-1;
lightR[lightSourceNumber]=-1;
lightT[lightSourceNumber]=-1;
}
[/code]