Don't forget to download the media file here:
http://www.realgametools.com/yabbse/attachments/dialog_bubble.zip
RemStart
****************************************************************************************
¤PROGRAM¤ | A DIALOG BUBBLE SNIPPET (Perfect for RPGs or MMORPGs.)
¤DESCRIPTION¤ | Allows you to place a dialog bubble anywhere on the screen
| with up to six lines of any text that you want ( like for
| example the SCREEN X and Y coordinates of your charcter models)
| The bubble will be scaled according to the size of the text.
|
| NOTE: This example requires that "speech.bmp" be in the same folder
|
¤AUTHOR¤ | David Yakobi aka Yarbles
¤DATE¤ | September 25,2002
¤CONTACT¤ | Email: dyakobi@hotmail.com
|
¤CREDITS ¤ | David Smith aka indi for
| DIALOG BUBBLE GRAPHIC
|
****************************************************************************************
RemEnd
sync on
rem Create dialog bubble
make object plain 11,128,128
load image "speech.bmp",11
texture object 11,11
set object 11,1,1,0,0,0,0,0
set object collision off 11
lock object on 11
set text font "Arial"
ink 0,0
line1$="Hear the Rime of the Ancient Mariner:"
line2$=" "
line3$="Day after day, day after day, We stuck, nor breath nor motion;"
line4$="As idle as a painted ship upon a painted ocean."
line5$="Water, water, every where, and all the boards did shrink;"
line6$="Water, water, every where, Nor any drop to drink. "
do
dialog_bubble(mousex(),mousey()-30,1,line1$,line2$,line3$,line4$,line5$,line6$,4)
sync
loop
function dialog_bubble(screenX,screenY,refresh,line1$,line2$,line3$,line4$,line5$,line6$,textStyle)
rem Dialog Bubble by David Yakobi aka Yarbles
rem You will be required to preload a plane with the bubble image
rem In this example I use object id 11 for that plane
rem only refresh scale and font for dialog size when requested
rem this save precious processor cycles when turned off
if refresh=1
rem find the max line width to calcualte dialog width
maxWidth = text width(line1$)
currentWidth = text width(line2$)
if currentWidth>maxWidth then maxWidth=currentWidth
currentWidth = text width(line3$)
if currentWidth>maxWidth then maxWidth=currentWidth
currentWidth = text width(line4$)
if currentWidth>maxWidth then maxWidth=currentWidth
currentWidth = text width(line5$)
if currentWidth>maxWidth then maxWidth=currentWidth
currentWidth = text width(line6$)
if currentWidth>maxWidth then maxWidth=currentWidth
rem calculate
height=0
if line1$"" then height=height+30
if line2$"" then height=height+30
if line3$"" then height=height+30
if line4$"" then height=height+30
if line5$"" then height=height+30
if line6$"" then height=height+30
rem set the text size
set text size 16
rem set the text style
if textStyle=4
set text to bolditalic
else
if textSyle=3
set text to bold
else
if textSyle=2
set text to italic
else
set text to normal
endif
endif
endif
rem scale bubble to the size of the text block
scale object 11,maxWidth,height,1
endif
dialogX=screenX-(screen width()/2)
dialogY=(screen height()/2)-screenY
rem position the dialog bubble
position object 11,dialogX,dialogY,0.625*screen width()
textX=screenX
textY=screenY
offset=(height+10)/-2
rem Display the text in the bubble
if line1$""
center text textX,textY+offset,line1$
offset=offset+15
endif
if line2$""
center text textX,textY+offset,line2$
offset=offset+15
endif
if line3$""
center text textX,textY+offset,line3$
offset=offset+15
endif
if line4$""
center text textX,textY+offset,line4$
offset=offset+15
endif
if line5$""
center text textX,textY+offset,line5$
offset=offset+15
endif
if line6$""
center text textX,textY+offset,line6$
offset=offset+15
endif
endfunction
The Yellow Jester does not play but gently pulls the strings
And smiles as the puppets dance in the court of the Crimson King.