simple window drawing command

Talk about making games.

simple window drawing command

Postby Game A Gogo » Wed Jun 23, 2010 11:35 pm

here is a simple window drawing command I created in the last 2 hours.
What it does is it collects data (window position, is it the current window, window size) and draw a simple window off that collected data.
the visual is pretty much simple, a blue color theme with a white border and a black one.
I made this for my oncoming project, and though I should share this with everyone :O

Code: Select all
void DW_TLC(int W_Xo, int W_Yo, int W_Act) //Top Left Corner
{
    if(W_Act)setpen(0,0,0,0,1);
    else setpen(64,64,64,0,1);
    moveto(4+W_Xo,1+W_Yo);
    lineto(1+W_Xo,4+W_Yo);
    if(W_Act)setpen(256,256,256,0,1);
    else setpen(127,127,127,0,1);
    moveto(4+W_Xo,2+W_Yo);
    lineto(2+W_Xo,4+W_Yo);
    setpen(0,0,255,0,1);
    moveto(4+W_Xo,3+W_Yo);
    lineto(3+W_Xo,4+W_Yo);
    setpen(0,0,127,0,1);
    putpixel(4+W_Xo,4+W_Yo);
    putpixel(5+W_Xo,4+W_Yo);
}
void DW_TTB(int W_Xo, int W_Yo, int W_Act, int W_WWidth) //Top Title Bar
{
    double i1;
    if(W_Act)setpen(0,0,0,0,1);
    else setpen(64,64,64,0,1);
    moveto(5+W_Xo,1+W_Yo);
    lineto(5+W_WWidth+W_Xo,1+W_Yo);
    if(W_Act)setpen(256,256,256,0,1);
    else setpen(127,127,127,0,1);
    moveto(5+W_Xo,2+W_Yo);
    lineto(5+W_WWidth+W_Xo,2+W_Yo);
    setpen(0,0,255,0,1);
    moveto(5+W_Xo,3+W_Yo);
    lineto(5+W_WWidth+W_Xo,3+W_Yo);
    for(i1=0; i1<W_WWidth; i1++)
    {
        if(W_Act)setpen((i1/W_WWidth)*255,(i1/W_WWidth)*255,(i1/W_WWidth)*255,0,1);
        else setpen((i1/W_WWidth)*127,(i1/W_WWidth)*127,(i1/W_WWidth)*127,0,1);
        moveto(5+W_Xo+(W_WWidth-i1),4+W_Yo);
        lineto(5+W_Xo+(W_WWidth-i1),18+W_Yo);
    }
}
void DW_TRC(int W_Xo, int W_Yo, int W_Act, int W_WWidth) //Top Right Corner
{
    if(W_Act)setpen(0,0,0,0,1);
    else setpen(64,64,64,0,1);
    moveto(5+W_WWidth+W_Xo+1,1+W_Yo);
    lineto(5+W_WWidth+W_Xo+4,4+W_Yo);
    if(W_Act)setpen(256,256,256,0,1);
    else setpen(127,127,127,0,1);
    moveto(5+W_WWidth+W_Xo+1,2+W_Yo);
    lineto(5+W_WWidth+W_Xo+3,4+W_Yo);
    setpen(0,0,255,0,1);
    moveto(5+W_WWidth+W_Xo+1,3+W_Yo);
    lineto(5+W_WWidth+W_Xo+2,4+W_Yo);
    setpen(0,0,127,0,1);
    putpixel(5+W_WWidth+W_Xo+1,4+W_Yo);
    putpixel(4+W_WWidth+W_Xo+1,4+W_Yo);
}
void DW_LSB(int W_Xo, int W_Yo, int W_Act, int W_WHeight) //Left Side Border
{
    double i2;
    if(W_Act)setpen(0,0,0,0,1);
    else setpen(64,64,64,0,1);
    moveto(1+W_Xo,5+W_Yo);
    lineto(1+W_Xo,5+W_Yo+W_WHeight);
    for(i2=0; i2<W_WHeight+1; i2++)
    {
        if(W_Act)setpen(127+(i2/W_WHeight)*127,127+(i2/W_WHeight)*127,127+(i2/W_WHeight)*127,0,1);
        else setpen(64+(i2/W_WHeight)*64,64+(i2/W_WHeight)*64,64+(i2/W_WHeight)*64,0,1);
        putpixel(2+W_Xo,5+W_Yo+(W_WHeight-i2));
    }
    setpen(0,0,255,0,1);
    moveto(3+W_Xo,5+W_Yo);
    lineto(3+W_Xo,5+W_Yo+W_WHeight);
    setpen(0,0,127,0,1);
    moveto(4+W_Xo,5+W_Yo);
    lineto(4+W_Xo,5+W_Yo+W_WHeight);
    moveto(5+W_Xo,5+W_Yo);
    lineto(5+W_Xo,5+W_Yo+W_WHeight);
}
void DW_RSB(int W_Xo, int W_Yo, int W_Act, int W_WWidth, int W_WHeight) //Right Side Border
{
    double i2;
    if(W_Act)setpen(0,0,0,0,1);
    else setpen(64,64,64,0,1);
    moveto(9+W_Xo+W_WWidth,5+W_Yo);
    lineto(9+W_Xo+W_WWidth,5+W_Yo+W_WHeight);
    for(i2=0; i2<W_WHeight+1; i2++)
    {
        if(W_Act)setpen(127+(i2/W_WHeight)*127,127+(i2/W_WHeight)*127,127+(i2/W_WHeight)*127,0,1);
        else setpen(64+(i2/W_WHeight)*64,64+(i2/W_WHeight)*64,64+(i2/W_WHeight)*64,0,1);
        putpixel(8+W_Xo+W_WWidth,5+W_Yo+(W_WHeight-i2));
    }
    setpen(0,0,255,0,1);
    moveto(7+W_Xo+W_WWidth,5+W_Yo);
    lineto(7+W_Xo+W_WWidth,5+W_Yo+W_WHeight);
    setpen(0,0,127,0,1);
    moveto(6+W_Xo+W_WWidth,5+W_Yo);
    lineto(6+W_Xo+W_WWidth,5+W_Yo+W_WHeight);
    moveto(5+W_Xo+W_WWidth,5+W_Yo);
    lineto(5+W_Xo+W_WWidth,5+W_Yo+W_WHeight);
}
void DW_BLC(int W_Xo, int W_Yo, int W_Act, int W_WHeight) //Bottom Left Corner
{
    if(W_Act)setpen(0,0,0,0,1);
    else setpen(64,64,64,0,1);
    moveto(1+W_Xo,1+W_Yo+W_WHeight+5);
    lineto(4+W_Xo,4+W_Yo+W_WHeight+5);
    if(W_Act)setpen(127,127,127,0,1);
    else setpen(64,64,64,0,1);
    moveto(2+W_Xo,1+W_Yo+W_WHeight+5);
    lineto(4+W_Xo,3+W_Yo+W_WHeight+5);
    setpen(0,0,255,0,1);
    moveto(3+W_Xo,1+W_Yo+W_WHeight+5);
    lineto(4+W_Xo,2+W_Yo+W_WHeight+5);
    setpen(0,0,127,0,1);
    putpixel(4+W_Xo,1+W_Yo+W_WHeight+5);
}
void DW_BRC(int W_Xo, int W_Yo, int W_Act, int W_WWidth, int W_WHeight) //Bottom Right Corner
{
    if(W_Act)setpen(0,0,0,0,1);
    else setpen(64,64,64,0,1);
    moveto(4+W_Xo+W_WWidth+5,1+W_Yo+W_WHeight+5);
    lineto(1+W_Xo+W_WWidth+5,4+W_Yo+W_WHeight+5);
    if(W_Act)setpen(127,127,127,0,1);
    else setpen(64,64,64,0,1);
    moveto(3+W_Xo+W_WWidth+5,1+W_Yo+W_WHeight+5);
    lineto(1+W_Xo+W_WWidth+5,3+W_Yo+W_WHeight+5);
    setpen(0,0,255,0,1);
    moveto(2+W_Xo+W_WWidth+5,1+W_Yo+W_WHeight+5);
    lineto(1+W_Xo+W_WWidth+5,2+W_Yo+W_WHeight+5);
    setpen(0,0,127,0,1);
    putpixel(1+W_Xo+W_WWidth+5,1+W_Yo+W_WHeight+5);
}
void DW_BBL(int W_Xo, int W_Yo, int W_Act, int W_WWidth, int W_WHeight) //Bottom Border Line
{
    if(W_Act)setpen(0,0,0,0,1);
    else setpen(64,64,64,0,1);
    moveto(5+W_Xo,4+W_Yo+W_WHeight+5);
    lineto(5+W_Xo+W_WWidth,4+W_Yo+W_WHeight+5);
    if(W_Act)setpen(127,127,127,0,1);
    else setpen(64,64,64,0,1);
    moveto(5+W_Xo,3+W_Yo+W_WHeight+5);
    lineto(5+W_Xo+W_WWidth,3+W_Yo+W_WHeight+5);
    setpen(0,0,255,0,1);
    moveto(5+W_Xo,2+W_Yo+W_WHeight+5);
    lineto(5+W_Xo+W_WWidth,2+W_Yo+W_WHeight+5);
    setpen(0,0,127,0,1);
    moveto(5+W_Xo,1+W_Yo+W_WHeight+5);
    lineto(5+W_Xo+W_WWidth,1+W_Yo+W_WHeight+5);
}
void DW_WA(int W_Xo, int W_Yo, int W_WWidth, int W_WHeight) //Working Area
{
    int i3;
    setpen(0,0,127,0,1);
    for(i3=0; i3<W_WWidth; i3++)
    {
        moveto(5+W_Xo+i3,19+W_Yo);
        lineto(5+W_Xo+i3,5+W_Yo+W_WHeight);
    }
}
void DW_Main(int W_Xo, int W_Yo, int W_Act, int W_WWidth, int W_WHeight)
{
    DW_TLC(W_Xo,W_Yo,W_Act);
    DW_TTB(W_Xo,W_Yo,W_Act,W_WWidth);
    DW_TRC(W_Xo,W_Yo,W_Act,W_WWidth);
    DW_LSB(W_Xo,W_Yo,W_Act,W_WHeight);
    DW_RSB(W_Xo,W_Yo,W_Act,W_WWidth,W_WHeight);
    DW_BLC(W_Xo,W_Yo,W_Act,W_WHeight);
    DW_BRC(W_Xo,W_Yo,W_Act,W_WWidth,W_WHeight);
    DW_BBL(W_Xo,W_Yo,W_Act,W_WWidth,W_WHeight);
    DW_WA(W_Xo,W_Yo,W_WWidth,W_WHeight);
}


place that code in a GLOBAL SCRIPT, then use the function DW_Main(X offset, Y offset, Active Window, Working Width, Working Height)

EDIT: Almost forgot to mention, use this only in a canvas actor!

I'm pretty sure anyone can fiddle with my code to change it's color/total look!

Anyhow, enjoy this rather small contribution of mine :)
Last edited by Game A Gogo on Wed Jun 23, 2010 11:36 pm, edited 1 time in total.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: simple window drawing command

Postby Hblade » Wed Jun 23, 2010 11:36 pm

Welcome back, dude :D!
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: simple window drawing command

Postby Game A Gogo » Wed Jun 23, 2010 11:39 pm

Hblade wrote:Welcome back, dude :D!

Thanks! but I'll probably end up lost again O:

Also, if anyone wants me to do this so it loads a Bitmap file and display it as a window, let me know, it'll be easy as anything for me :)
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: simple window drawing command

Postby Hblade » Wed Jun 23, 2010 11:44 pm

Wow that'd be awesome :D!

I made one too, heres a link:
viewtopic.php?f=4&t=8149&p=56839&hilit=Window#p56839

Heres a screenshot :D
Image
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: simple window drawing command

Postby Game A Gogo » Wed Jun 23, 2010 11:52 pm

That's pretty nice as well!
And very nifty for RPG and similar stuff

Mine is basically only good for the way it draws the window, it divides it into 9 section, 5 of which are strechable, hence why it'd be easy to make it read bmp files!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: simple window drawing command

Postby Hblade » Thu Jun 24, 2010 3:34 am

Yeah I love how yours is so able to resize or make even an opening effect :D Maybe we can team up and make the ultimate windows? xD
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: simple window drawing command

Postby lcl » Thu Jun 24, 2010 8:13 am

This is great! :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: simple window drawing command

Postby Game A Gogo » Thu Jun 24, 2010 12:26 pm

I decided I'm just gonna go ahead and make the bmp version
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: simple window drawing command

Postby Game A Gogo » Thu Jun 24, 2010 6:22 pm

just to say the bitmap version of this can be found in the demo section! :D
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest