Transparent Splash Window / Menu / Loader by TinTin5th Mar 2007 9:42
|
---|
Summary Simple Splash Screen Loader thats Semi Transparent Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com ` Description : Transparent Splash Screen / Menu / Loader ` It's Just an idea that I had for a cool menu screen, I've not optomized ` anything yet and I've removed the graphics ` Author : Alan Barclay ` Splash() End Function Splash() Hide Window Set Window Size 640,480 Set Window Layout 0,0,2||3||4 Load Dll "User32.dll",1 Load Dll "GDI32.dll",2 hDsk = Call Dll(1,"GetDesktopWindow") hDc = Call Dll(1,"GetWindowDC",hDsk) DW = Call Dll(1,"GetSystemMetrics",0) DH = Call Dll(1,"GetSystemMetrics",1) XP = (DW-Screen Width())/2 YP = (DH-Screen Height())/2 Set Window Position XP,YP Create Bitmap 1,Screen Width(),Screen Height() Lock Pixels `Grab Desktop Image Under Window For X=0 to Screen Width()-1 For Y=0 to Screen Height()-1 C=Call Dll(2,"GetPixel",hDc,X+XP,Y+YP) Corner=0 ` Decide if this point is a corner or not and ajust colour to suit IF X<=10 and Y<= 10 and Abs(SQRT((X-10)^2+(Y-10)^2))>10 Then Corner=1 IF X<=10 and Y=> 469 and Abs(SQRT((X-10)^2+(Y-469)^2))>10 Then Corner=1 IF X=>629 and Y<= 10 and Abs(SQRT((X-629)^2+(Y-10)^2))>10 Then Corner=1 IF X=>629 and Y=> 469 and Abs(SQRT((X-629)^2+(Y-469)^2))>10 Then Corner=1 IF Corner Dot X,Y,RGB(RGBB(C),RGBG(C),RGBR(C)) Else Dot X,Y,RGB((RGBB(C)+128)/2,(RGBG(C)+128)/2,(RGBR(C)+128)/2) EndIf Next Next ` Draw a Border Ink RGB(255,255,255),0 Line 10,0,630,0 :Arc(10,10,10,270,360) Line 639,10,639,470 :Arc(629,10,10,0,90) Line 630,479,10,479 :Arc(629,469,10,90,180) Line 0,470,0,10 :Arc(10,469,10,180,270) Unlock Pixels Get Image 1,0,0,Screen Width(),Screen Height(),1 Delete Bitmap 1 ` Game Title ` This should be replaced with a bitmap sporting a transpaqrent backdrop Create Bitmap 1, 600,120 Lock Pixels C=rgb(128,128,128): Box 0,0,600,120,C,C,C,C C=RGB(255,255,255): HBOX(0,0,599,119,C,C) Center Text 300,50,"G a m e T i t l e G r a p h i c s" Unlock Pixels Get Image 2,0,0,600,120,1 Delete Bitmap 1 Delete Dll 1 Delete Dll 2 Show Window X=Screen Width()/2:M=1 Do Paste Image 1,0,0,1 `The Transparent Window Graphic Paste Image 2,20,20,1 `The Game Title Graphics ` The Buttons If But(610,10,630,30,"X") then Exit If But(50,150,250,180,"New Game") then Do_Something=0 If But(50,200,250,230,"Load Game") then Do_Something=0 If But(50,250,250,280,"Save Game") then Do_Something=0 If But(50,300,250,330,"Quit") then Exit ` The Loader C=RGBA(64,64,128,128): P=RGBA(255,0,128,192) Box 10,430,629,449,C,C,C,C X=X+M:IF X=> 629-40 or X<= 10+40 then M=-M Box X-40,430,X,449,C,C,P,P : Box X,430,X+40,449,P,P,C,C HBox(10,430,629,449,RGB(0,0,0),RGB(255,255,255)) Ink RGB(255,255,255),0:Center Text Screen Width()/2,432,"Loading" Text 500,460,"By Alan Barclay" Loop EndFunction Rem Function HBox(X1,Y1,X2,Y2,C1,C2) Ink C1,0: Line X1,Y2,X1,Y1: Line X1,Y1,X2,Y1 Ink C2,0: Line X2,Y1,X2,Y2: Line X2,Y2,X1,Y2 EndFunction Rem Function Arc(X1,Y1,Z1,A1,A2) If A2<A1 then T=A1:A1=A2:A2=T If A1=A2 then A2=A2+360 For A=A1 to A2 X=X1+(Sin(A)*Z1) Y=Y1-(Cos(A)*Z1) Dot X,Y Next EndFunction Rem Function But(X1,Y1,X2,Y2,A$) TH=Text Height(A$): TW=Text Width(A$) MX= MouseX():MY=MouseY() IF MX>X1 and MX<X2 and MY>Y1 and MY<Y2 C=RGBA(0,255,0,128) MB=MouseClick():If MB>0 then C=RGBA(255,255,0,128) Else C=RGBA(0,0,255,128) MB=0 EndIf BOX X1,Y1,X2,Y2,C,C,C,C if MB>0 HBOX(X1,Y1,X2,Y2,RGB(0,0,0),RGB(255,255,255)) Else HBOX(X1,Y1,X2,Y2,RGB(255,255,255),RGB(0,0,0)) EndIf Ink RGB(255,255,255),0:Center text X1+((X2-X1)/2),Y1+((Y2-Y1)/2)-(TH/2),A$ EndFunction MB Rem Function RGBA(R,G,B,A) rD as DWORD rD = (A<<24)||(R<<16)||(G<<8)||(B) EndFunction rD |