UnderwareDESIGN

PlayBASIC => Resources => Source Codes => Topic started by: kevin on November 04, 2017, 06:45:44 AM

Title: Simple Scrolling Text Message
Post by: kevin on November 04, 2017, 06:45:44 AM
 Simple Scrolling Text Message



[pbcode]

; Load a new version of the arial font into font #1..
   loadfont  "arial",1,96,0,8


; This is the string that holds the scrolling message.
   Scrolltext$="This is scroll text.... Once upon a time..  PlayBASIC Scroller......"


; compute width of Scrolling Text message in pixels
; using the current output font
   ScrollSizeInPixels=GetTextWidth(ScrollText$)
   

; Set the scroller starting position
; to beyond the right hand side of screen

   ScrollX   =GetScreenWidth()

; Limit the speed of the program to 30 frames per second
   SETFPS 30


; MAIN LOOP
   do

      ; Clear the screen to Black  RGB(0,0,0)
      CLS

      ; Draw the swcroller in the current font as the current scroller position   
      Text ScrollX,100,ScrollText$   


      ; Move the scroll position to the left by 2 pixels
      ScrollX-=2


      ; check if the scroll position is lower than the messages absolute size
      ; if it is, then it's completely scrolled off the left hand side
      ; of the screen
      if ScrollX< (-ScrollSizeInPixels)
            ; reset the scroller position back to the right hand side of the screem
            ScrollX=GetScreenWidth()
         
      endif   
   
      ; flip the back buffer to the fron, so the view can see the newly drawn screen
      sync
   
   
      ; loop (jump) back to the DO statement above to keep this section of code
      ; running
   loop esckey()=true


[/pbcode]