Liberty BASIC Community Forum
« "The Matrix" style clock »

Welcome Guest. Please Login or Register.
Nov 24th, 2017, 10:50am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: "The Matrix" style clock  (Read 239 times)
JohnnyD
Guru
ImageImageImageImageImage


member is offline

Avatar

"If something should, then it doesn't, isn't, can't, hasn't or won't"


Homepage PM

Gender: Male
Posts: 765
xx "The Matrix" style clock
« Thread started on: Jun 8th, 2017, 5:19pm »

Hi all,

Please find below a "Matrix" style clock.

Far from perfect I know, but it's a start. I tried to simulate the changing glyphs by randomly changing the font of the trailing characters but not that convincing but hey!

There may be a better way (API) of selecting the font than shown here.

The delsegment may need addressing as I never understood it fully!

Do with it what you wish. Go forth and play.

John.

Code:
    nomainwin
    f$="Aharoni_Bold,Angsana_New,Browallia_New,Comic_Sans_MS,Cordia_New,Courier_New,Estrangelo_Edessa,Franklin_Gothic_Medium,Iskoola_Pota,"
    f$=f$+"Khmer_UI,Lao_UI,Levenim_MT,Lucida_Console,Lucida_Sans_Unicode,Malgun_Gothic,Meiryo_UI,Microsoft_Himalaya,Microsoft_JhengHei,Microsoft_New_Tai_Lue,"
    f$=f$+"Microsoft_PhagsPa,Microsoft_Sans_Serif,Microsoft_Tai_Le,Microsoft_Uighur,Microsoft_YaHei,Microsoft_Yi_Baiti,Mongolian_Baiti,MS_Gothic,MS_Mincho,"
    f$=f$+"MS_PGothic,MS_PMincho,MS_UI_Gothic,MV_Boli,Palatino_Linotype,Plantagenet_Cherokee,Sakkal_Majalla,Segoe_Print,Segoe_Script,Segoe_UI,Shonar_Bangla,"
    f$=f$+"Simplified_Arabic,Simplified_Arabic_Fixed,Times_New_Roman,Traditional_Arabic,Trebuchet_MS"
    dim tim$(5,200)
    WindowHeight=420
    graphicbox #main.txt,100,5,100,365
    open "Matrix Clock" for window as #main
    #main.txt,"down;fill black;color white; backcolor black"
    #main,"trapclose [quit]"

[loop]
    redim tim$(5,200)
    for a=1 to 5
        for b=1 to 100
            tim$(a,b)="  "
        next b
    next a
    for a=1 to 5
        p=int(rnd(1)*30)+20
        for b=1 to 30
            tim$(a,p+b)=mid$(time$(),a,1)
            lastpos(a)=p
        next b
    next a
    for c=0 to 79
        for d=1 to 20
            scan
            for b=1 to 5
                if c+d-1=lastpos(b) then
                    #main.txt,"color white"
                else
                    #main.txt,"color darkgreen"
                end if
                n=int(rnd(1)*42)
                ff$=word$(f$,n,",")
                #main.txt,"font ";ff$;" 10 bold"
                #main.txt,"place ";(b-1)*12+20;" ";375-(d*18);";\";tim$(b,c+d)
                #main.txt,"delsegment ";segnum-1
                #main.txt,"segment segnum"
                #main.txt,"flush;discard"
            next b
        next d
        calldll #kernel32,"Sleep",100 as ulong,r as void
    next c
    goto[loop]

[quit]
    close #main
    end
 

User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5567
xx Re: "The Matrix" style clock
« Reply #1 on: Jun 9th, 2017, 02:19am »

Since you are redrawing every 100ms you only need to discard the contents of the current segment.

Code:
      
                '#main.txt,"delsegment ";segnum-1
                '#main.txt,"segment segnum"
                '#main.txt,"flush;discard"
                #main.txt "discard"
 


Normally you would flush to create a new segment, get that segment number then delsegment that number minus 1 to get rid of the old segment you don't want.

So by my way of thinking you have the commands in the wrong order.

Also flush ; discard does absolutely nothing the flush saves the segment and starts a new segment which is empty so you are discarding nothing.

Like the concept, probably needs some animation between time displays to hold the attention.
User IP Logged

JohnnyD
Guru
ImageImageImageImageImage


member is offline

Avatar

"If something should, then it doesn't, isn't, can't, hasn't or won't"


Homepage PM

Gender: Male
Posts: 765
xx Re: "The Matrix" style clock
« Reply #2 on: Jun 19th, 2017, 08:53am »

Hi all,

Matrix style clock v2 here, now with added date and a fuller updating of the display:

Code:
    nomainwin
    dim tim(13),tim$(13),mx(13)
    WindowWidth=220
    WindowHeight=370
    graphicbox #main.txt,0,0,200,330
    open "Matrix Clock" for window as #main
    #main.txt,"down;fill black;color darkgreen; backcolor black"
    #main,"trapclose [quit]"
    for num=1 to 13
        gosub[init]
    next num

[loop]
    for num=1 to 13
        tim(num)=tim(num)+1
        if tim(num)>mx(num) then
            tim(num)=1
            gosub[init]
        end if
    next num
    for ptr=1 to 20
        scan
        for p=1 to 13
            if p<6 then
                os=5
            else
                os=43
            end if
            if 21-tim(p)=ptr then
                col$="white"
            else
                col$="darkgreen"
            end if
            #main.txt,"color ";col$;";place ";((p-1)*12)+os;" ";336-(ptr*16);";\";mid$(tim$(p),ptr+tim(p),1)+" "
        next p
    next ptr
    calldll #kernel32,"Sleep",80 as ulong,r as void
    #main.txt,"segment segnum"
    #main.txt,"flush;discard"
    #main.txt,"delsegment ";segnum-1
    goto[loop]

[init]
    d$=date$("mm/dd/yy")
    dat$=mid$(d$,4,2)+"/"+left$(d$,2)+"/"+right$(d$,2)
    tim$(num)=space$(20)
    mx(num)=20
    for a=1 to int(rnd(1)*15)+5
        if num<6 then
            tim$(num)=tim$(num)+mid$(time$(),num,1)
        else
            tim$(num)=tim$(num)+mid$(dat$,num-5,1)
        end if
    next a
    mx(num)=mx(num)+a
    tim$(num)=tim$(num)+space$(19)
    return

[quit]
    close #main
    end
 
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls