Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7649329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:56:16+00:00 2026-05-31T10:56:16+00:00

I’m trying to make a text animation for an application made in ncurses. User

  • 0

I’m trying to make a text animation for an application made in ncurses.

User presses a key, selects a direction and an object in a text grid should move from one cell of the grid to the next in the given direction, waiting 500ms before it moves. The code I used is

while (!checkcollisions(pos_f, input)) { // Checks if it can move to next grid
    pos_f = moveobject(pos_f, input, ".."); // Moves object to next cell
    usleep(50000);
}

But when I execute it, instead of moving, waiting and moving again, it waits a long time, and the object suddenly appears at the final cell of the grid, without showing the animation.

Is this because of how ncurses work? I already tried using other solutions like the select() stalling function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:56:18+00:00Added an answer on May 31, 2026 at 10:56 am

    You need to call refresh() (before the usleep).


    Update: the new pastebin-ed code segments (in several comments) point to the real problem, which is the same one in ncurses-refresh: mixing stdscr (implied by the next two calls) and getch and refresh with newwin and wrefresh.


    Update 2: using the full code, plus some hacking, I got it to work (for some value of “work”, I’m clearly not calling printmap() correctly, and I made up a bogus “map” file).

    Without looking closely, I just changed all occurrences of getch() to wgetch(win.window), all mvprintw calls to mvwprintw (to use that same window), and removed at least one unneeded getch/wgetch. Then the heart of the problem:

                    while (!checkcollisions(pos_f, input)) {
    -                       pos_f = moveobject(pos_f, input, "..");
    -                       // sleep + wrefresh(win.window) doesn't work, neither does refresh()
    +                       struct position new_pos = moveobject(pos_f, input, "..");
    +                       printmap(pos_f, new_pos);
    +                       pos_f = new_pos;
    +                       wrefresh(win.window);
    +                       fflush(stdout);
    +                       usleep(50000);
                    }
    

    The above call to printmap is definitely wrong, but still you definitely need to do something in the loop to change what’s in win.window (or stdscr or some other window you put up or whatever); and then you need to force it to refresh, and force the output to stdout with fflush(stdout), before sleeping.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.