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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:40:17+00:00 2026-05-11T22:40:17+00:00

The data model in my program has a number of discrete states, but I

  • 0

The data model in my program has a number of discrete states, but I want to animate the transition between these states. While the animation is going on, what the user sees on the screen is disconnected from what the underlying data is like. Once the animation is complete, they match up again.

For example, let’s say we have a simple game where Snuffles the bunny hops around on a 2D grid. The model of Snuffles contains integer x/y coordinates. When the player tells Snuffles to hop north, his y-coordinate is decremented by one immediately. However, on the screen, Snuffles should at that point still be in his old location. Then, frame by frame, Snuffles proceeds to hop over to his new location, until he is shown in the location his model states.

So usually, when we draw Snuffles, we can just look up his coordinates in his model. But when he’s hopping, that coordinate is wrong.

If there is only ever one thing moving on the screen, I can just about get away with freezing the entire game state and not allowing the user to do anything until Snuffles has finished hopping. But what if there is more than one bunny on the screen?

It gets worse if elements interact, merge or split. If Snuffles magically merges with a hat to become a potato, at which point does the data model delete the bunny and the hat, and add the potato? If it does so immediately, the view instantly loses access to information about Snuffles and the potato which it still needs to draw the animation of the magical merger.

I have come across this problem multiple times while implementing animated GUIs, especially games, and have found no satisfactory solution.

Unsatisfactory ones include:

  • Do the changes immediately, but then suspend any further changes in the model until the animation has resolved. Makes things unresponsive and doesn’t work if more than one thing can move or things interact in complex ways.

  • Merge the model and the view – Snuffles gains floating-point coordinates, and probably a z-coordinate to indicate how far up he is. The model’s rules become massively more complex as a result, as the model can no longer make concise statements like “you cannot hop north if there is a wall at (x, y – 1)”. Any change to the rules takes much longer, and development slows to a crawl.

  • Keep what amounts to a duplicate of the data in the view. SnufflesModel has integer coordinates, but SnufflesSprite has floating-point ones. End up duplicating some of the model rules in the view and having to keep them in sync. Spend lots of time debugging to make sure that SnufflesModel and SnufflesSprite don’t de-sync under some rare circumstance.

My best bet at the moment is option 3, but it hardly strikes me as elegant. Thoughts?

  • 1 1 Answer
  • 1 View
  • 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-11T22:40:17+00:00Added an answer on May 11, 2026 at 10:40 pm

    You would need a stronger model to account for the time component of changes:

    1. Each sprite needs to maintain a queue of animation actions it is supposed to carry out. Adding animations to the queue should be a zero-time action (game time). Queued animations proceed on a frame-by-frame basis when they get a tick from the animation clock. Queuing lets you separate the model from the graphics subsystem and the animations.

    2. Each animation in the queue carries with it a model action to perform when the animation is complete. Some languages make that easier, e.g. with anonymous functions in C# or JavaScript. In other languages, you could use a callback instead. The model action lets you specify how the model would change when the animation completes.

    3. Sprites can carry high resolution coordinates (e.g. floating point), while the model stays with integer ones. Sprites don’t need to know anything about the game rules though — the queued animation-completion model-actions deal with that.

    4. Model entities should be able to account for a transitional states: appearing, disappearing, and moving. This lets you avoid checking the rules for objects in transition.

    To implement Snuffle’s quest, you could then:

    • User asked to move Snuffle north? -(1) check that the rules allow the move, (2) queue a move animation on Snuffle’s sprite, coupled with a landing model action. Put the bunny’s model into a transitional moving state.

    • Snuffle’s landing model action brings the bunny’s model back to a normal state, and checks the landing spot and the rules. Finding a hat, it queues a potato appearance animation (the “merger”) and two disappearance animations for the bunny and hat.

    • The model actions for the disappearance animations delete the bunny and hat when complete.

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

Sidebar

Related Questions

I have a data model where a 'Program' has a 1-to-many relationship with 'ToDo's
I have a program that starts up and creates an in-memory data model and
I'm implementing a Model View Control program. I have a class User that has
I want to be able to store an atomic model in an OpenGL program
I use auto generated Entity-Framework Data Model for a Database that has 100+ tables.
I'm writing a small program to record reading progress, the data models are simple:
I want to save my program's DataModel objects to a file, and be able
Is Model only Entity Data Model class of my database? Model as simple place
I have a data model where a User can like a Project, Suggestion, Comment
I'm building a data model using ADO.NET Entity Framework 3.5 in Visual Studio 2008

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.