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