in reply to Re: seek() command on STDOUT
in thread seek() command on STDOUT
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..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: seek() command on STDOUT
by BrowserUk (Patriarch) on Apr 30, 2010 at 21:46 UTC | |
by ybnormal (Novice) on May 01, 2010 at 04:02 UTC |