Multicolor Scroller

Just starting out? Need help? Post your questions and find answers here.
StarWarsFan
Enthusiast
Enthusiast
Posts: 169
Joined: Sat Mar 14, 2015 11:53 am

Multicolor Scroller

Post by StarWarsFan »

PureBasic ist geil - and I thank you for it!

I am experimenting with smooth scroll texts, just like we had them on C64/Amiga
With monochrome text it works, I got that.

But now I want to take the next step.

I would like to use this font:
Image

Unfortunately - due to forum restrictions! - I cannot show you my whole font (it says the width is max. xxx)
but the example show point clearly to what I mean

Now how do I get this done, anybody got a functionning code yet?
Image - There is usually a lot of "try this, maybe do that" but ONLY an example that one can test for themself and get an immediate result actually brings people forward.
User avatar
Demivec
Addict
Addict
Posts: 4091
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Multicolor Scroller

Post by Demivec »

When you say monochrome text I am assuming you mean a loaded TTF font and using a command such as DrawText(). The difference with using a colored font such as in your image is that you would have to position each character yourself and display them as images or as sprites. Adjust this for the smooth scrolling part would then be just an offset to the display position and then checking for characters that scroll completely off of the visible display area.

With sprites you can clip the image that contains all of your characters to just show the one you need. You will still need to update the display position to use the proper width of the characters. I noticed that in your font image the characters overlap some. You would use DisplaySprite() or one of its variations to render the characters.

If you use images I think you would have to split the font image into separate images with just a single character. You would then use DrawImage() or one of its variations to render them on a screen area.
User avatar
Fig
Enthusiast
Enthusiast
Posts: 351
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: Multicolor Scroller

Post by Fig »

If you upload your font image and give us the link only, someone may give you a complete code to get all sprites and scroll them.
Don't worry, It's not nasa's science. :wink:
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
firace
Addict
Addict
Posts: 903
Joined: Wed Nov 09, 2011 8:58 am

Re: Multicolor Scroller

Post by firace »

Something like this:

(Snippet based on a very old code by padman)

Code: Select all


Global  xres.w , yres.w , loop.w ,xp.w , yp.w , t.s , tptr.w , sco.b


t.s="                     * ARCANE * IS BACK TO PUMP IT UP. THIS WEEKS RELEASE IS A LITTLE COMPILATION......CONTACT US: ARCANE POSTE RESTANTE 2700 BRONSHOJ DENMARK NO 2400 BAUD LAMERS.  MEMBERS OF ARCANE  SCOT EXORBIT GHOUL MIKE ZETRIX JTF MAXITECH.....                                 "    


xres  = 640           
yres  = 480           
sco   = 0
tptr  = 1
FPS = 60
TimerDuration = 1000 / FPS






;#### Init stuff

InitSprite()                     
InitKeyboard()                  

window = OpenScreen( xres , yres , 32 , "Arcane Remake")      



;#### Catch the font pic 


CatchSprite(1,?font)
TransparentSpriteColor(1,$000008)



Repeat
  
  
  
  timer = ElapsedMilliseconds()   
  
  ClearScreen($0)                                       
  
    
  
  ; #### This draws the upper and lower borders
  
  StartDrawing (ScreenOutput())                       
  
  
  Box(0,104,640,2,$ffffff)
  Box(0,392,640,2,$ffffff)
  
  StopDrawing()                                       
  
  
  
  ; #### This draws the scroller
  
  cco = 0
  
  For cc = 0 To 20
    letter   = Asc(UCase(Mid(t.s, tptr+cc, 1)))-31
    
    yCharPos = letter / 10
    xCharPos = letter % 10
    
    If xcharpos= 0: xcharpos = 10 : ycharpos=yCharPos-1  :EndIf
    If xCharPos <- 1: xCharPos = 9
      
    ElseIf xCharPos > 0  : xCharPos = xCharPos - 1
    EndIf
    
    ClipSprite(1, xCharPos*32, yCharPos*44, 32,44)
    
    
    DisplayTransparentSprite(1, (sco+cco),312)
    
    
    cco = cco + 34
  Next
  
  
  sco = sco - 1
  
  If sco < -32
    tptr = tptr + 1
    sco = sco + 34
  EndIf
  
  If tptr > Len(t.s)-16
    tptr = 0
  EndIf 
  
  
  
  TimeGap = TimerDuration - (ElapsedMilliseconds() - Timer)
  
  If TimeGap > 16
    
    Delay( TimeGap - 10 )
  EndIf
  
  
  ExamineKeyboard() 
  
  FlipBuffers()                                        
  
Until KeyboardPushed (#PB_Key_Escape)               



;#### and Adios!
End

DataSection
  font:
  IncludeBinary "font.bmp"
EndDataSection
User avatar
STARGÅTE
Addict
Addict
Posts: 2090
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Multicolor Scroller

Post by STARGÅTE »

You can try my typeface include: Typeface - Sprite-based font include/module

You can import your bitmap characters with the includes editor and you can create the whole font and use it in pure basic.
If you need help, you can send me the font-characters and I create the font.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Post Reply