Hi all! =) I'm new to Blitz3D, and was wondering if anyone would be kind enough to help me fix this to do the following:
1) Text ALWAYS aligned correctly in textbox at the top left, center, or top right corner.
2) The sentence will continue only if you press enter.
3) When the end of the sentence is reached, play a sound like in Zelda.
4) When the entire paragraph is finished, play an end text sound.
5) box fades in after started, and fades out when ended.
6) The box is completely centered in the middle of the screen no matter what graphics mode you're in.
7) If the text goes out of the box, increase the box width & height.
If anyone at all can help, that'd be GREATLY appreciated! =)
Anyway, here is the code:
Thanks again, all! =)
~DarkShadowWing~
1) Text ALWAYS aligned correctly in textbox at the top left, center, or top right corner.
2) The sentence will continue only if you press enter.
3) When the end of the sentence is reached, play a sound like in Zelda.
4) When the entire paragraph is finished, play an end text sound.
5) box fades in after started, and fades out when ended.
6) The box is completely centered in the middle of the screen no matter what graphics mode you're in.
7) If the text goes out of the box, increase the box width & height.
If anyone at all can help, that'd be GREATLY appreciated! =)
Anyway, here is the code:
Graphics3D 800,600,0,2 SetBuffer=BackBuffer() Global box_x Global box_y Global box_width Global box_height Global box_transparent Global box_transparency Global box_solid box_width = GraphicsWidth()/4 box_height = 40 box_x = box_height+GraphicsWidth()/3 box_y = box_width+GraphicsHeight()/3 box_transparent = 0 box_transparency = 0 box_solid = 1 AmbientLight 255, 255, 255 Global type_player = 1 Global type_object = 1 Global cam = CreateCamera() PositionEntity cam, 0, 1, 0 CameraRange cam, .1, 1000000 Global player = CreateCube() EntityRadius player, .1, .7 EntityType player, 1 Global playercollision_sphere = CreateSphere(100) HideEntity playercollision_sphere Global Sky = CreateSphere(100) EntityColor Sky,180,180,245 ScaleEntity Sky, 500000, 500000, 500000 EntityFX Sky, 1 EntityOrder Sky, 9 FlipMesh Sky Global land = CreatePlane() EntityColor land, 127, 127, 127 EntityType land, 1 EntityOrder land, 9 Global block = CreateCube() PositionEntity block, 0, 1, 12 EntityRadius block, .1, .7 EntityType block, 1 Global objcollision_sphere = CreateSphere(100) EntityColor block, 68, 207, 252 ;EntityAlpha block, .7 EntityOrder block, 9 EntityShininess block, 1.0 FlipMesh block Type Letter Field Letter$,Xpos,Ypos,Time#,Sound End Type ;--------------; ; Type Letters ;---------------------------------------------------------- ;--------------; Function textbox(x,y,w,h,transparent,transparency,solid) Rect x,y,w,h,s End Function Function TypeText (Xpos=0,Ypos=0,MaxX=100,MaxY=100,Texts$="",Space=10,Height=12,Time=5,Tolerance=10,Sound=0) Local LR.Letter,A,L For A = 1 To Len (Texts) LR.Letter = New Letter LR\Letter = Mid (Texts,A,1) LR\Xpos = Xpos + (L*Space) LR\Ypos = Ypos LR\Time = A*Time LR\Sound = Sound L = L + 1 If LR\Letter = Chr (13) Or LR\Letter = Chr (10) LR\Xpos = Xpos LR\Ypos = Ypos + Height LR\Letter = " " Ypos = Ypos + Height L = 1 EndIf If LR\Xpos >= (MaxX-Tolerance) If LR\Letter = " " LR\Xpos = Xpos LR\Ypos = Ypos + Height Ypos = Ypos + Height L = 1 EndIf EndIf If LR\Xpos >= MaxX LR\Xpos = Xpos LR\Ypos = Ypos + Height Ypos = Ypos + Height L = 1 EndIf If LR\Xpos = Xpos If LR\Letter = " " Delete LR L = 0 EndIf EndIf Next End Function ;------------------; ; Draw all Letters ;------------------------------------------------------ ;------------------; Function DrawLetters() Local LR.Letter For LR.Letter = Each Letter LR\Time = LR\Time - 1 If LR\Time = 0 And LR\Sound <> 0 PlaySound LR\Sound EndIf If LR\Time <= 0 Text LR\Xpos,LR\Ypos,LR\Letter If LR\Xpos > box_width Then box_width = box_width + 1 If LR\Ypos > box_height Then box_height = box_height + 1 EndIf Next End Function ;--------------------; ; Remove all Letters ;---------------------------------------------------- ;--------------------; Function DeleteLetters() Local LR.Letter For LR.Letter = Each Letter Delete LR Next End Function Function SuperCam(cam,ent,cspeed#,dist#,hite#,xrot#,tilt#) TFormPoint 0,hite#,-dist#,ent,0 cx#=(TFormedX()-EntityX(cam))*cspeed#*2 cy#=(TFormedY()-EntityY(cam))*cspeed#*2 cz#=(TFormedZ()-EntityZ(cam))*cspeed#*2 TranslateEntity cam,cx,cy,cz PointEntity cam,ent RotateEntity cam,xrot#,EntityYaw(cam),tilt# End Function ;---------; ; Example ;--------------------------------------------------------------- ;---------; ; Text from Wikipedia :) ; ; Xpos = Xpos of text start ; Ypos = Ypos of text start ; MaxX = Width of text box ; MaxY = Height of text box ; Texts = Text to type ; Space = Space between letters ; Height = Height of each line ; Time = Delay between letters ; Tolerance = Max word size from end of line (?) ; Sound = Sound to play for each letter Local Txt$ = "The Waterboys are a band formed in 1983 by Mike Scott. The band's membership, past and present, has been composed mainly of musicians from Scotland and Ireland. London, Dublin, Spiddal, New York and Findhorn have all served as a home for the group."+Chr(13)+Chr(13)+"The band has played in a number of different styles, but most often their music can be described as a mix of Celtic folk music with rock and roll, or folk rock. After ten years of recording and touring, the band dissolved in 1993 and Scott pursued a solo career."+Chr(13)+Chr(13)+"The band reformed in 2000, and continues to release albums and tour worldwide. The early Waterboys sound was dubbed `The Big Music' after a song on their second album, A Pagan Place. This musical style was described by Scott as `a metaphor For seeing God's signature in the world'. Their songs, largely written by Scott, often contain literary references And are frequently concerned with spirituality."+Chr(13)+Chr(13)+"Both the group and its members' solo careers have received much praise from both rock and folk music critics, but The Waterboys as a band has never received the commercial success that some of its members have had independently." TypeText (20,20,600,440,Txt,10,12,5,50,0) While Not KeyDown (1) PositionEntity Sky, EntityX(cam), EntityY(cam), EntityZ(cam) cspeed# = .012 cdist# = 8 cheight# = EntityY(player)+2 croll# = 4 cyaw# = 0 SuperCam(cam,player,cspeed#,cdist#,cheight#,croll#,cyaw#) block_rotation_y# = block_rotation_y# + 0.5 If block_rotation_y# > 360.0 Then block_rotation_y# = 0.0 If block_rotation_y# < -360.0 Then block_rotation_y# = 0.0 RotateEntity block, 0, block_rotation_y#, 0 speed# = 0.4 tspeed# = 0.4 MoveEntity player, 0, 0, speed#*(KeyDown(200)-KeyDown(208)) TurnEntity player, 0, tspeed#*(KeyDown(6203)-KeyDown(205)), 0 Collisions type_player, type_object, 1, 1 Collisions type_object, type_player, 1, 1 If EntityCollided(player, type_object) coll_x = CountCollisions(player) coll_y = CountCollisions(player) coll_z = CountCollisions(player) ShowEntity playercollision_sphere PositionEntity playercollision_sphere, CollisionX(player, coll_x), CollisionY(player, coll_y), CollisionZ(player, coll_z) Else HideEntity playercollision_sphere EndIf obj = block If EntityCollided(obj, type_player) coll_x = CountCollisions(obj) coll_y = CountCollisions(obj) coll_z = CountCollisions(obj) ShowEntity objcollision_sphere PositionEntity objcollision_sphere, CollisionX(obj, coll_x), CollisionY(obj, coll_y), CollisionZ(obj, coll_z) Else HideEntity objcollision_sphere EndIf UpdateWorld RenderWorld textbox(box_x, box_y, box_width, box_height, box_transparent, box_transparency, box_solid) DrawLetters() Flip Wend DeleteLetters() End
Thanks again, all! =)
~DarkShadowWing~