RE: Steering Game Objects with P.I.D. Control

You are viewing a single comment's thread from:

Steering Game Objects with P.I.D. Control

in gaming •  7 years ago 

I always wondered about the "mechanism" how games display the movement of an object on screen. Just for my curiosity (I have little experience in programming), how does the code/engine of the game (for e.g. the old Pong game) define the object that needs to be displayed on screen? As a variable that has value for x, y position and a certain colour for the pixel?

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Indeed. In it's simplest form, a 2D game that is moving a green pixel from left to right on the screen would clear the screen and then set the colour of pixel (x,y) to green and vary x from 0 to Max (and using the same y value each frame.) All current computers use framebuffers that contain all the pixels on the CRT or LCD screen.

The actually setting a pixel colour is just writing to a location in the framebuffer. If the framebuffer holds 320x200 pixels, then setting pixel X,Y to colour C would mean writing the value C at location Y×200+X.

Interestingly, this wasn't always the case. In the early days, there were vector displays. These did not have the concept of scanlines nor pixels. The computer driving a vector display would actually move an electron beam over a screen (in any direction) and turning the beam on and off. Very similar to an oscilloscope actually. Asteroids arcade machines worked that way. The electron beam would trace out the shapes on the screen.

Later computer monitors all wrote the screen left to right top to bottom as pixels on scanlines.

In 3D games it is a little more involved. A world composed of triangles is drawn a triangle at a time, and each triangle is projected onto the screen using linear algebra with 4x4 matrices, after which the corresponding pixels in the framebuffer for that triangle are set to a colour.

Thank you for your answer! I wanted to code games... but didn't have the technical expertise or education... I've started (recently) to dabble with Unity to gain some experience in coding games (to create a game engine is a titanic task), so later on I can start my own projects or look for opportunities in the game industry (currently I work as a SysAdmin for an outsourcing company).

Happy to help. For a gentle introduction that is easier than unity, I would first attempt something really simple, maybe a snake game (or pong) in Python e.g.

I'll try that. Thank you!

You actually gave me an idea. I learned to program on a micro computer in the early 80s, which was a much lower threshold for learning to code. You plug the computer in the wall, and you see the prompt of a basic interpreter.

No need for complex tools, no compiler, no GPUs, or window management.

I decided to start a tutorial on how to program Snake for Python, just with a simple output to a command line window. No loading assets, just a gentle introduction to making a video game.

A simple step-by-step programming from zero to snake in 3600 seconds, or something :-) Hey, that's a catchy title! Keep an eye out for it on my feed, in case it interests you.

That would we really great :D! I'll keep my voting power :)). I'll follow every post :D