Thanks,

The program I'm writing is a simple terminal game called snake that was a popular arcade game in the '70s. It has 50x50 grids where the snake-like creature moves around and the player steers it not to hit the blockage or itself. It is intended to run on xterm.

I finished the program, but currently, it refreshes the display every second(and getting faster over the time) with print `clear` and redraws the entire 50x50 grids with the new pattern. However, since all the grids are refreshed every time, the flickering is annoying especially when the snake's move gets faster. Then I realized that only 2 out of 50x50 grids are required to be updated every time(The head and tailend of the snake need to be updated to move forward) and I need to move the cursor to those 2 locations to update it every time. I thought seek() could do that on STDOUT where I got it wrong.

So, basically, like you said, I need to move the cursor to the random points of 50x50 grid on xterm, update them with keeping all the other grids unchanged.

Is ncurses able to do it ?

Thanks for your help..


In reply to Re^2: seek() command on STDOUT by ybnormal
in thread seek() command on STDOUT by ybnormal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.