How can i make moving objects in c++

how do get moving objects in c++ and for them to move when you press a button on your keyboard?

Have you looked at this stack exchange thread?

  1. Create an object
  2. Draw it on screen
  3. Update it’s position
  4. Refresh
    It’s not simple to just jump into. You will probably need to use a library or just mess around with text at first.
    A simple exercise would be to create a 2d array and change the characters in it within a loop.

Try changing where the asterisk is, and redrawing the array within a timed loop.
Once you understand that movement is just a series of updated frames - start changing the color of the thing you are moving, or add in the controls to move it yourself, maybe put obstacles in the way and manipulate the asterisk to avoid them.

1 Like