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

  • Home
  • SEARCH
  • 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 1112125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:39:35+00:00 2026-05-17T02:39:35+00:00

This may be the wrong approach, but as I dig deeper into developing my

  • 0

This may be the wrong approach, but as I dig deeper into developing my game engine I have ran into a timing issue.

So lets say I have a set of statements like:

for(int i = 0; i < 400; i++)
{
     engine->get2DObject("bullet")->Move(1, 0);
}

The bullet will move, however, on the screen there won’t be any animation. It will basically “warp” from one part of the screen to the next.

So, I am thinking…create a vector of function pointers for each base object (which the user inherits from) and when they call “Move” I actually don’t move the object until the next iteration of the game loop.
So something like:

while(game.running())
{
     game.go();
}

go()
{
     for(...)
          2dobjs.at(i)->action.pop_back();
}

Or something like that, and this way it runs only a single action of each object during each iteration (of course I’ll add in a check to see if there is actually “actions” to be ran).

And if that is a good idea, my question is how do I store the parameters. Since each object can do more than a single type of “action” rather than move (rotateby is one example), I think it would be nonsensical to create a struct similar in fashion to:

struct MoveAction {
     MovePTR...;
     int para1;
     int para2;
};

Thoughts? Or is this the completely wrong direction?

  • 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-17T02:39:36+00:00Added an answer on May 17, 2026 at 2:39 am

    I don’t think this is the right direction. After you store 400 moves in a vector of function pointers, you’ll still need to pop and perform a move, redraw the screen, and repeat. Isn’t it easier just to move(), redraw, and repeat?

    I’d say your bullet is warping because it’s moving 400 pixels/frame, not because you need to delay the move calculations.

    But if this is the correct solution for your architecture, in C++ you should use classes rather than function pointers. For example:

    class Action // an abstract interface for Actions
    {
    public:
        virtual void execute() = 0; // pure virtual function
    }
    
    class MoveAction: public Action
    {
    public:
        MoveAction(Point vel) : velocity(vel) {}
        virtual void execute();
        Point velocity;
        ...
    }
    
    std::vector<Action*> todo;
    
    gameloop
    {
        ...
        todo.push_back(new MoveAction(Point(1,0))
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be the wrong place but this is new to me. I did
I may be approaching this problem from the wrong angle but what I'm thinking
This may be a stupid question but I have a code with the following
This may be have a better name than custom tab completion, but here's the
This may sound like a very generic question but here it goes. I have
I am completely new to iOS development so I may be doing this wrong
This may be a simple question but I can;t find the answer anywhere. Here
this may sound pretty straight forward, but still I want to post this question
This may seem a bit crazy, but if you can tell me a better
Folks, Apologies if this has been covered in another thread, but I have searched

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.