how to move text continuously inside a window

Advanced game related topics
yabune
User
User
Posts: 65
Joined: Mon Aug 22, 2005 2:31 pm

how to move text continuously inside a window

Post by yabune »

hi,

I would like to create a moving marquee inside a window (like we have in html).

Any tips on this?

Thanks!
Last edited by yabune on Mon Sep 15, 2008 5:17 pm, edited 1 time in total.
yabune
User
User
Posts: 65
Joined: Mon Aug 22, 2005 2:31 pm

Post by yabune »

ok, I have a solution:

Code: Select all

x = 0
y = 0

If OpenWindow(0, 100, 200, 300, 260, "Marquee")

  CreateImage(0, 300, 20)
  CreateGadgetList(WindowID(0))
  ImageGadget(0, 0, 100, 0, 0, ImageID(0))

  last = ElapsedMilliseconds()
  

  Repeat
    EventID = WindowEvent()

    If EventID = #PB_Event_CloseWindow
      Quit = 1
    Else
      Delay(1)
    EndIf
    
    current = ElapsedMilliseconds()
    If(current - last >= 20)
      x = x + 1
      CreateImage(0, 300, 20)
      StartDrawing(ImageOutput(0))
      
      DrawingMode(1)
      
      BackColor(RGB(0,155,155))
      FrontColor(RGB(255,255,255))
      DrawText(x,y,"Hello, this is a test")
      
      StopDrawing()
      
      SetGadgetState(0, ImageID(0))
      
      last = ElapsedMilliseconds()
    EndIf

  Until Quit = 1



EndIf

End

But I can't make it move smoothly...

Anyone knows how to make the animation more smooth?

Thanks
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Post by citystate »

the search function is your friend (of course it helps that I remember coding something along these lines :P)

http://www.purebasic.fr/english/viewtopic.php?t=22826
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
Post Reply