Solved drawbox always paint in black

Question that is answered or resolved.

dcelso

Member
Hi, I have put a green box to highlight the text but always draw in black, I tried from 0 to 255 index values, and different RGB values with rgbcolor.
update.c
Code:
void main()
{
  if(openborvariant("in_level")==1){
      drawbox(20,20,80,12,rgbcolor(255,0,0),0);
  }
}
[code]
How can I fix it?
 

Attachments

Solution
How can I fix it?
@dcelso: you're missing one parameter: z as the fifth parameter.
drawbox function is: drawbox(x,y,width,height,z,color,alpha)

Because of missing parameter, OpenBoR thinks that you set 0 as color which produces black color.

Simply put, set 5th parameter and it should work :D
Hi, I have put a green box to highlight the text but always draw in black, I tried from 0 to 255 index values, and different RGB values with rgbcolor.
update.c
Code:
void main()
{
  if(openborvariant("in_level")==1){
      drawbox(20,20,80,12,rgbcolor(255,0,0),0);
  }
}
[code]
How can I fix it?

As @Bloodbane points out below (and I missed at first), you are missing the Z parameter. Consequently, your last argument (0) is read into the color parameter, and you get black. I would also suggest for readability you don't nest functions. It's usually good practice to use a variable instead, which also helps avoid the missing parameters.

Note the Z is layering, and you normally want this to be a high number so it overlays over all the game-play elements. 15000 should do it for most projects.

C:
void main()
{
  int box_color = 0;
  int pos_z = 150000;

  if(openborvariant("in_level")==1)
  {
      box_color = rgbcolor(255, 0, 0);

      drawbox(20, 20, 80, 12, pos_z, box_color);
  }
}

HTH,
DC
 
Last edited:
How can I fix it?
@dcelso: you're missing one parameter: z as the fifth parameter.
drawbox function is: drawbox(x,y,width,height,z,color,alpha)

Because of missing parameter, OpenBoR thinks that you set 0 as color which produces black color.

Simply put, set 5th parameter and it should work :D
 
Solution
@dcelso: you're missing one parameter: z as the fifth parameter.
drawbox function is: drawbox(x,y,width,height,z,color,alpha)

Because of missing parameter, OpenBoR thinks that you set 0 as color which produces black color.

Simply put, set 5th parameter and it should work :D

Oh! Nice catch @Bloodbane, I didn't notice that and it changes my whole answer. Reworking my post above to reflect this.

DC
 
Back
Top Bottom