I know this is kind of a basic question, but I'm trying to create my own game from scratch and really don't understand this. How does the code of a videogame program certain pixels to be certain colors and then move them in agreement with the player's movement?

For example, in a 2D platformer, how does the code program the on-screen visuals of the world that the player is in? And then, how does it move a certain object matching the speed of the player and then eventually have it go off screen?

Thanks in advance!!


closed as too broad by Stephane Hockenhull, Philipp, wondra, jgallant, msell Aug 7 '16 at 17:07

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    \$\begingroup\$ Google "Computer graphic tutorial" and learn from there. There is too much in this question to answer. That would require an entire year long class in computer graphics. Here's a good link: lodev.org/cgtutor \$\endgroup\$ – Stephane Hockenhull Aug 7 '16 at 14:49
  • \$\begingroup\$ This is a really broad question. How about you just following a few tutorials? A lot of things will become a lot more obvious after you made a bit of experience yourself. \$\endgroup\$ – Philipp Aug 7 '16 at 14:50
  • \$\begingroup\$ You don't set the colors of individual pixels anymore. That kind of programming was done on a C64/C128 30 years ago. Nowadays you typically use vertices and textures (which work for both 3d and 2d) or draw sprites, or use whatever the abstraction laye of your choice does. \$\endgroup\$ – Polygnome Aug 7 '16 at 15:41

I think you need to start with: How is anything drawn to the screen -- text, windows, shapes, sprites, etc.? A very simple answer is people have written code that makes basic 'drawing' happen and then other people have written methods/functions/code to use those drawing functions to do things like animate a character on screen.

I would try creating some 'non-game' programs first before trying to produce even a simple game (a non-trivial task). This will teach you the basics of things like rendering. Then you can move on to create games.


Not the answer you're looking for? Browse other questions tagged or ask your own question.