Advertisement
Mysoft

Untitled

Apr 4th, 2024
1,434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "fbgfx.bi"
  2.  
  3. const ScreenWid=640,ScreenHei=480
  4.  
  5. screenres ScreenWid,ScreenHei,8  'setup 640x480x8bpp (256 colors)
  6. width ScreenWid\8,ScreenHei\16   'set font size to 8x16
  7.  
  8. 'iDirX is how many pixels it moves per frame (initially 1 (to the right))
  9. 'since we're going from -10 to 10... that number must be a divisor of 10
  10. 'so must be one of 1,2,5 or 10 (this simplify the check)
  11. dim as integer iOffsetX,iDirX=1
  12. dim as integer iPosX,iPosY
  13. dim as string sSentence = "Hello World"
  14.  
  15. 'calculate center position for sentence
  16. iPosX = (ScreenWid-len(sSentence)*8)\2 'horizontal
  17. iPosY = (ScreenHei-16)\2      'vertical
  18.  
  19. do
  20.  
  21.   screenlock 'block screen from update
  22.     cls 'clears whole screen (could fill just an area)
  23.     'draw centered text over right position (in yellow)
  24.     Draw String ( iPosX+iOffsetX , iPosY ) , sSentence , 14
  25.    
  26.     iOffsetX += iDirX 'change position depending on direction (left/right)
  27.     if iOffsetX = -10 orelse iOffsetX = 10 then
  28.       iDirX = -iDirX 'if it hit side positions invert direction
  29.     end if
  30.   screenunlock 'allow display of the screen
  31.   sleep 30 'waits 30ms... making roughly 30fps
  32.  
  33.   'draw frames until ESC is pressed
  34. loop until multikey(fb.SC_ESCAPE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement