TGC Codebase Backup



Simple window by DavidO

19th Mar 2005 9:04
Summary

Display a simple window and a button



Description

Please feel free to use this function in your games! Please leave the small comment in the code!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem Simple window; created by freemaan; e-mail:freemaan@gmail.com

sync on
window(150,50,"Hello world!","This is a multi-line window")

function window(x,y,message1$,message2$)
cls
box 0,0,93,27,rgb(200,0,0),rgb(0,0,0),rgb(200,0,0),rgb(0,0,0)
center text 93/2,5,"Exit"
get image 1,0,0,93,27
box 0,0,93,27,rgb(255,0,0),rgb(0,0,0),rgb(255,0,0),rgb(0,0,0)
center text 93/2,5,"Exit"
get image 2,0,0,93,27


cls

x1=screen width()/2-x
y1=screen height()/2-y
x2=screen width()/2+x
y2=screen height()/2+y
r=50
g=100
b=200
rinc=100
ginc=0
binc=0

do
cls

box x1,y1,x2,y2,rgb(0,50,0),rgb(0,150,0),rgb(0,150,0),rgb(0,50,0)
line x1,y1,x1,y2
line x1,y1,x2,y1
line x2,y2,x1-1,y2
line x2,y2,x2,y1-1

center text screen width()/2,y1+7,message1$
center text screen width()/2,y1+27,message2$


if mouseclick()=1
   if screen width()/2-93/2<mousex() AND screen width()/2+93/2>mousex() AND y2-35<mousey() AND y2-35+27>mousey() then exit
endif

if screen width()/2-93/2<mousex() AND screen width()/2+93/2>mousex() AND y2-35<mousey() AND y2-35+27>mousey() then paste image 2,screen width()/2-93/2,y2-35 else paste image 1,screen width()/2-93/2,y2-35

sync
loop

endfunction