UnderwareDesign
November 24, 2017, 05:06:20 AM *
News: PlayBASIC V1.65B _Retail Upgrade_ Now Available (23rd, June, 2017)
   Home    
Pages: [1]
 
Author Topic: Simple Scrolling Text Message  (Read 73 times)
Member
Development Team


WWW
« on: November 04, 2017, 06:45:44 AM »


 Simple Scrolling Text Message



PlayBASIC Code:
; 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



Logged

Pages: [1]
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2009, Simple Machines LLC | Privacy Policy Valid XHTML 1.0! Valid CSS!