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 7551035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:22:30+00:00 2026-05-30T10:22:30+00:00

I have been experimenting with the devkitARM toolchain for NDS homebrew recently. Something I

  • 0

I have been experimenting with the devkitARM toolchain for NDS homebrew recently. Something I would like better understand, however, is how to control sprite animation speeds. The only way I know of doing this is by ‘counting frames’. For example, the following code could be placed into the “animate_simple” example included with devkitpro:

int main(void) {
    int frame = 0;
    ...
    while(1) {
    ...
        if(++frame > 9)
            frame = 0;
    }
    return 0;
}

This is generally fine, but it ensures that all the animation initialized in the main loop runs at a set speed. How would I go about having two different sprites, each animating at different speeds? Any insight would be greatly appreciated.

  • 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-30T10:22:32+00:00Added an answer on May 30, 2026 at 10:22 am

    Use a separate frame counter for each sprite. For example, you can create a sprite struct:

    typedef struct _Sprite Sprite;
    struct _Sprite
    {
        int frame;
        int count;
        int delay; /* handles the speed of animation */
        int limit;
    };
    
    // initialize all fields
    
    void sprite_update(Sprite* s) 
    {
        if ( ( s->count++ % s->delay ) == 0 ) )
        {
            if ( s->frame++ > s->limit ) s->frame = 0;
        }
    }
    

    Give delay small value for faster animation, and a larger value for slow animation.

    Sample Usage:

    Sprite my_spr, my_spr_2;
    
    /* initialize the fields, or write some function for initializing them. */
    
    my_spr.delay = 5; /* fast */
    my_spr_2.delay = 10; /* slow */
    
    /* < in Main Loop > */
    
    while(1){
    ...
       sprite_update(&my_spr);
       sprite_update(&my_spr_2);
    }
    

    Note:
    Since you are targeting only one platform, the best way to control animation speed is to monitor the frame rate ( or “counting frames” as you call it ). Good thing about programming for consoles is, you don’t have to set timed delays. Since all console devices of the same model usually run at the same speed, so the animation speed you get on your machine ( or emulator ) will be the same everyone gets. Different Processors Speeds are a real headache when programming for the PC.

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

Sidebar

Related Questions

I have been experimenting with HTML5 and gradient fades, I would like to use
I have been experimenting with a lot of web development apps like Drupal, Moodle,
I have been experimenting recently with Silverlight, RIA Services, and Entity Framework using .NET
I have been experimenting with the lightweight NiceDog PHP routing framework, which routes like
I have recently been experimenting with naming abstract classes and interfaces in a more
I have been experimenting with functional programming and I still dont understand the concept.
I've recently become familiar with Reflection , and have been experimenting with it, especially
I have been experimenting with the localstorage module for Backbone.js (https://github.com/jeromegn/Backbone.localStorage). As I understand
I own a server running whm / cpanel, and I have recently been experimenting
I have been experimenting with supplying better debugging information when an error happens in

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.