1. help requested

To all Euphoria enthusiasts

I can't understand how to make this watch working good:
in text mode works OK.
in graphics mode (18), wich is what I need, I see a sort of rain (?) over=
 the watch.
Somebody can help me?

include graphics.e
atom i
sequence s,coordinate
i=3Dgraphics_mode (18)
-- cursor(NO_CURSOR)   --needed in text mode
coordinate=3D {{2,78},{2,75},{2,72},{3,72},{3,75},{3,78}}

procedure orologio()
        s =3D date()
        for i=3D1  to 6  do
            position((coordinate[i][1]),(coordinate[i][2]))
            printf (1,"%02d",s[i])
        end for
end procedure

while get_key() !=3D 27 do
    orologio()
end while
i=3Dgraphics_mode(-1)

new topic     » topic index » view message » categorize

2. Re: help requested

The flickering (rain) you indicate is caused by the printf command in
graphics mode being called very rapidly.  I modified your code to return
from orologio if the seconds had not changed yet.  In this way, the watch
is printed only once per second, which will also give your program more
time to do other things.

include graphics.e
atom i
sequence s,coordinate
i=graphics_mode (18)
-- cursor(NO_CURSOR)   --needed in text mode
coordinate= {{2,78},{2,75},{2,72},{3,72},{3,75},{3,78}}

atom prev_sec
prev_sec = 0
procedure orologio()
        s = date()
        if prev_sec = s[6] then
            return
        else
            prev_sec = s[6]
        end if
        for i=1  to 6  do
            position((coordinate[i][1]),(coordinate[i][2]))
            printf (1,"%02d",s[i])
        end for
end procedure

while get_key() != 27 do
    orologio()
end while
i=graphics_mode(-1)


 _______  ______  _______  ______
[    _  \[    _ ][ _   _ ][    _ ]
[/| [_] |[/| [_\][/ | | \][/| [_\]
  |  ___/  |  _]    | |     |  _]
[\| [/]  [\| [_/] [\| |/] [\| [_/]
[_____]  [______] [_____] [______]
xseal at harborside.com  ICQ:13466657
http://www.harborside.com/home/x/xseal/euphoria/

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu