TGC Codebase Backup



Button maker by Brux

19th Jan 2012 8:43
Summary

U can create buttons any size, any colors with shadow and with anim effect, when push it! No media needed



Description

U can create buttons any size, any colors.with shadow or border and with
anim effect when U push it!
Simple, call function define color, size,position x,y
U can write any phrase,centered within the button, in any color
No media needed !



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem ************************************
Rem * Title  : Button  Maker           *
Rem * Author : Ermanno Manzoni -ITALY- *
Rem * Date   : 10-01-2012              *
Rem * e-mail: me52@libero.it           *
Rem ************************************
Sync On : Sync Rate 30
Rem Define some colors
yellow=rgb(232,232,0)
red=Rgb(255,0,0)
sky=Rgb(0,160,255)
darkgray=Rgb(140,140,140)
gray=Rgb(200,200,200)
white=Rgb(255,255,255)
green=Rgb(0,200,60)
orange=rgb(224,128,64)
violet=rgb(160,0,192)

Ink gray,gray
Box 0,0,639,479
Rem Creo primo bottone animato

Rem Primo bottone rosso
Make_Button(red,10,10,340,50,white,2)
Intesto(10,10,340,20,"BUTTON MAKER",white)

Rem Bottone centrale viola
Make_Button(violet,100,100,250,250,white,2)
Intesto(100,100,250,210,"PASTE IMAGE",white)
Intesto(100,100,250,240,"HERE!",white)

Rem Lungo bottone grigio scuro
Make_Button(darkgray,20,370,620,400,white,1)
Intesto(20,370,620,370,"SECONDO LUNGO BOTTONE",yellow)

Rem azzurri
Make_Button(sky,400,40,600,90,white,1)
Make_Button(sky,400,91,600,141,white,1)
Make_Button(sky,400,142,600,192,white,1)
Make_Button(sky,400,193,600,243,white,1)

Rem Verticale
Make_Button(green,280,80,360,270,black,0)
Make_Button(sky,300,100,340,250,black,1)
Intesto(300,30,340,250,"P",black):Intesto(300,60,340,250,"U",black)
Intesto(300,90,340,250,"S",black):Intesto(300,120,340,250,"H",black)

Rem Gray button

Make_Button(darkgray,320,290,410,330,white,1):Intesto(340,260,390,330,"CLICK",black)

Do

mx=Mousex()
my=Mousey()

If Mouseclick()=1

If mx>320 and mx<410 and my>290 and my<330
   Make_Button(yellow,320,290,410,330,white,1):Intesto(320,260,410,330,"OOOPS!",black)
   _messaggio("Bottoncino grigio")
   Anim_Button(320,290,410,330)
   Make_Button(darkgray,320,290,410,330,white,1):Intesto(320,260,410,330,"CLICK",black)
EndIf

 If mx>10 And mx<340 And my>10 And my<50
   _messaggio("BUTTON MAKER")
   Anim_Button(10,10,340,50)
 EndIf
 If mx>400 And mx<600 And my>40 And my<90
   _messaggio("Primo bottone azzurro")
   Anim_Button(400,40,600,90)

 EndIf
 If mx>400 And mx<600 And my>91 And my<141
   _messaggio("Secondo bottone azzurro")
   Anim_Button(400,91,600,141)

 EndIf
 If mx>400 And mx<600 And my>142 And my<192
   _messaggio("Terzo bottone azzurro")
   Anim_Button(400,142,600,192)
 EndIf
 If mx>400 And mx<600 And my>193 And my<243
   _messaggio("Quarto bottone azzurro")
   Anim_Button(400,193,600,243)
 EndIf
 If mx>100 And mx<250 And my>100 And my<250
    _messaggio("Paste Image Here!")
    Anim_Button(100,100,250,250)
 endIf
 If mx>20 And mx<620 And my>370 And my<400
    _messaggio("Secondo lungo bottone")
    Anim_Button(20,370,620,400)
 EndIf
 If mx>300 And mx<340 And my>100 And my<250
   _messaggio("Bottone azzurro verticale")
   Anim_Button(300,100,340,250)
 EndIf
EndIf
Sync
Loop


Function _messaggio(testo$)
Ink Rgb(200,200,200),0
Box 10,440,600,470
Ink black,black
Center Text 320,450,testo$
EndFunction

Function Make_Button(co1,Left,Top,Right,Bottom,co2,shadow)
 Ink 0,0
 If shadow=1 Then Box left,top,right,bottom
 If shadow=2 Then Box left-2,top-2,right+2,bottom+2
 Ink co1,co1
 Box left+1,top+1,right-1,bottom-1
 Ink co2,co2
 Line Left,Bottom,Left,Top : Line Left,Top,Right,Top
 Ink 0,0
 Line Right,Top,Right,Bottom : Line Right,Bottom,Left,Bottom
EndFunction


Function Intesto(x,y,x1,y1,txt$,ct)

 Ink ct,ct
 c=((x1-x)/2)-((8*Len(txt$))/2)
 Text x+c,y1-((y1-y)/2)+8,txt$
EndFunction

Function Anim_Button(Ax,Ay,Bx,By)

    Copy Bitmap 0,Ax-1,Ay-1,Bx,By,0,Ax,Ay,Bx+1,By+1
    While MouseClick()=1 : Sync : EndWhile
    Copy Bitmap 0,Ax,Ay,Bx+1,By+1,0,Ax-1,Ay-1,Bx,By

EndFunction