November 24, 2020, 06:43:05 AM

Author Topic: [bb] TextFader() by n8r2k [ 1+ years ago ]  (Read 781 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] TextFader() by n8r2k [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : TextFader()
Author : n8r2k
Posted : 1+ years ago

Description : Not sure if anyones done sometin like this so feel free to use this code anyway you like
Click here to download current versions of all my codes and games including this one: <a href="http://n8r2k.deviousbytes.com/" target="_blank">http://n8r2k.deviousbytes.com/[/url]


Code :
Code: BlitzBasic
  1. Graphics 800,600,16,2
  2. Global g = 0
  3. Global r = 155
  4. Global bigfont = LoadFont("Arial",50,0,0,0)
  5.  
  6. While Not KeyHit(1)
  7. ClsColor 155,0,0
  8. Cls
  9. textfader()
  10. SetFont bigfont
  11. Color r,g,0
  12. Text 100,100,"Press space to fade in again"             ;Edit this line
  13. If KeyHit(57) resettext()
  14. Flip
  15. Wend
  16.  
  17. Function TextFader()
  18. g = g + 1
  19. r = r - 1
  20. If r < 0
  21.         r = 0
  22. EndIf
  23. If g > 128
  24.         g = 128
  25. EndIf
  26. End Function
  27.  
  28. Function ResetText()
  29. g = 0
  30. r = 155
  31. End Function


Comments :


n8r2k(Posted 1+ years ago)

 In case you were wondering, variables r and g can be messed with and you can even try adding a blue variable


Yo! Wazzup?(Posted 1+ years ago)

 I cleaned up the code a bit, now it doesn't do any of TextFader if it's already done fading, it doesn't set the font every time you loop, and it doesn't set the ClsColor every time you loop. =D
Code: [Select]
Graphics 800,600,16,2
Global g = 0
Global r = 155
Global stopwriting=0
Global bigfont = LoadFont("Arial",50,0,0,0)
SetFont bigfont
ClsColor 155,0,0
While Not KeyHit(1)
Cls
textfader()
Color r,g,0
Text 100,100,"Press space to fade in again"
If KeyHit(57) resettext()
Flip
Wend

Function TextFader()
If stopwriting >< 1
g = g + 1
r = r - 1
If r < 0
r = 0
EndIf
If g > 128
stopwriting = 1
EndIf
EndIf
End Function

Function ResetText()
g = 0
r = 155
stopwriting=0
End Function
It also doesn't blink anymore, as far as I'm aware. [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal