Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / dbpro button creator

Author
Message
lagmaster
21
Years of Service
User Offline
Joined: 26th Aug 2002
Playing:
Posted: 27th Aug 2002 20:10
nice simple function to create a button

enjoy!


remstart
This information was inbedded from Dark Snippet Pro - universal source info
Real Name: Richard Nash
DarkBASIC Username: Lagmasteruk
E-Mail: r.nash@ntlworld.com
Website: http://www.lagmaster.net
remend

sync on
sync rate 0

` set the button x,y,width and height
XA = 0 : `start x position
XB = 180 : ` end x position
YA = 0 : ` start y position
YB = 70 : ` end y position
CreateButton(XA,YA,XB,YB,"Start Game",200,200,200,150,150,150,255,200,100,"Tahoma",20,1,1)

` grab the button to a image then convert it to a sprite so it can stay on the screen
get image 1, XA,YA,XA+XB+1,YA+YB+1
Sprite 1, Xa, Ya, 1

do
cls
mx = mousex()
my = mousey()

`do a check if the mouse is over the sprite/button's position
if mx => xa and mx = ya and my =
lagmaster
21
Years of Service
User Offline
Joined: 26th Aug 2002
Playing:
Posted: 27th Aug 2002 20:14
hmm didnt work


part 2 continued:
if mx => xa and mx =< xa+xb and my => ya and my =< ya+yb
over = 1
else
over = 0
endif

` check if the mouse has click on the button/sprite and end the demo
if mouseclick() and over = 1 then end

sync
loop

Function CreateButton(x,y,width,height,text$,edgered,edgegreen,edgeblue,centerred,centergreen,centreblue,textred,textgreen,textblue,textfont$,textsize,transparent,bolditalicorbothornone)
`put a border round the button
ink rgb(edgered,edgegreen,edgeblue),0
a = x+width
b = x-width
c = y+height
d = y-height
line x, y, A, y : `works
line x, y+height, x, y : `works
line A, C, x, C : `works
line A, y, A, C : `works

lagmasteruk - http://www.lagmaster.net/ r.nash@ntlworld.com
specs: 1.2ghz athlon, 384mb ram, geforce 2 mx 400 (32mb),win2k
lagmaster
21
Years of Service
User Offline
Joined: 26th Aug 2002
Playing:
Posted: 27th Aug 2002 20:14
part 3 continued:

` fill the button with a color
ink rgb(centerred,centergreen,centreblue),0
box x+1,y+1,a-1,c-1

`put into the box some text
remstart
bolditalicorbothornone results
1 = Bold
2 = Italic
3 = BoldItalic
0 = None
remend
E = width/2
F = height/2
G = xa/2
H = ya/2
ink rgb(textred,textgreen,textblue),0
set text font textfont$
set text size textsize
if transparent = 1
SET TEXT TRANSPARENT
else
SET TEXT OPAQUE
endif
if bolditalicorbothornone = 0 then set text to normal
if bolditalicorbothornone = 1 then set text to bold
if bolditalicorbothornone = 2 then set text to italic
if bolditalicorbothornone = 3 then set text to bolditalic
center text A-E,Height/3,text$ : `centers
endfunction

lagmasteruk - http://www.lagmaster.net/ r.nash@ntlworld.com
specs: 1.2ghz athlon, 384mb ram, geforce 2 mx 400 (32mb),win2k
haggisman
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 27th Aug 2002 20:27
wouldn't this be a better way, btw looks very useful all we need now is DBpro.



Specs:- 1GHZ athlon, Radeon8500, 192mb ram
lagmaster
21
Years of Service
User Offline
Joined: 26th Aug 2002
Playing:
Posted: 27th Aug 2002 23:21
the code button didnt work (i get an error) and it seems there is a limit on the amount you send.

lagmasteruk - http://www.lagmaster.net/ r.nash@ntlworld.com
specs: 1.2ghz athlon, 384mb ram, geforce 2 mx 400 (32mb),win2k
haggisman
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 28th Aug 2002 00:05
what kind of error did you get, i got a page error until i realised you were supposed highlight the text first before clicking code

Specs:- 1GHZ athlon, Radeon8500, 192mb ram
lagmaster
21
Years of Service
User Offline
Joined: 26th Aug 2002
Playing:
Posted: 28th Aug 2002 00:16


i added the code tags but it still didnt work

lagmasteruk - http://www.lagmaster.net/ r.nash@ntlworld.com
specs: 1.2ghz athlon, 384mb ram, geforce 2 mx 400 (32mb),win2k
Mike
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 28th Aug 2002 02:30
Hmm code works for me




Mike

VapourNET.com
Web Technology Experts
ToXic
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Australia
Posted: 13th Sep 2002 03:57
Hmmm.


Login to post a reply

Server time is: 2024-03-28 19:50:31
Your offset time is: 2024-03-28 19:50:31