Ok I have done this before, but I can't remember exactly how.
I want to be able to render a box of varying sizes(width,height) and also varying scale. Reason for both is to preserve resolution as much as possible.
I have the following variables with are the sprites or images that I want to blit
Code:
hgeSprite* TopLeft;
hgeSprite* TopMiddle;
hgeSprite* TopRight;
hgeSprite* LeftCenter;
hgeSprite* Center;
hgeSprite* RightCenter;
hgeSprite* BottomLeft;
hgeSprite* BottomMiddle;
hgeSprite* BottomRight;
Cleary-
TopLeft-Rendered once per frame
TopMiddle-Rendered as many times as the box is wide
TopRight-Rendered once per frame
LeftCenter-Rendered as many times as the box is high
Center-Rendered before each sprite of the box ( the box's background )
RightCenter-Render as many times as the box is high
BottomLeft-Rendered once per frame
BottomMiddle-Rendered as many times as the box is wide
BottomRight-Rendered once per frame
I thought that I should render the corners first and then fill in the rest in a loop. Unless I am blind mentally and I cant see a way to loop the entire render without a million if statements.
NOTE: I think the main problem is that the windows can be scaled at creation, or runtime. so that also makes the code a little different.
All sprites start at 32x32pixels
This is what I have for rendering the corners-
Code:
//Scaled position
float tpos_x = pos_x*scale_x;
float tpos_y = pos_y*scale_y;
//scaled section size
float section = (32.0f*scale_x);
float linksize_h = ((32.0f*scale_x)*links_h);
float linksize_v = ((32.0f*scale_y)*links_v);
/* Render corners */
//Top Left corner
Center->RenderEx(tpos_x,tpos_y,0,scale_x,scale_y);
TopLeft->RenderEx(tpos_x,tpos_y,0,scale_x,scale_y);
//Top Right corner
Center->RenderEx((tpos_x+section)+linksize_h,tpos_y,0,scale_x,scale_y);
TopRight->RenderEx((tpos_x+section)+linksize_h,tpos_y,0,scale_x,scale_y);
//Bottom Left corner
Center->RenderEx(tpos_x,(tpos_y+section)+linksize_v,0,scale_x,scale_y);
BottomLeft->RenderEx(tpos_x,(tpos_y+section)+linksize_v,0,scale_x,scale_y);
//Bottom Right corner
Center->RenderEx((tpos_x+section)+linksize_h,(tpos_y+section)+linksize_v,0,scale_x,scale_y);
BottomRight->RenderEx((tpos_x+section)+linksize_h,(tpos_y+section)+linksize_v,0,scale_x,scale_y);
so I wrote this so far, but I can seem to get the rest figured out. I was hoping someone could help me with this. I will be extremely grateful for any assistance. Thank you.