Sunday, 21 August 2016

What Is Programming?

It’s all about writing code. Programming is a process in which we organize data and use logic to do something with those data. The data are everything a computer can store; they can range from numbers to zombie characters in a video game.

You do this by writing text into files called source code. Source code written into text files replaces punch cards used by the computing machines half a century ago.
When data are combined with logic and then written into a single file, they’re called a class. Classes are also data, and as such can be managed with more logic.
Classes are used to create objects in the computer’s memory and can be duplicated to have a life of their own. Classes are used to build objects. Each piece of data within the class becomes a part of that object. Different chunks of data inside of a class are called class members.
Class members can also be chunks of logic called functions or methods. In a game with a horde of zombies, each zombie is duplicated or instanced from a zombie class. Each zombie has unique values for each attribute or data element in the class.

This means hit points, and locations are unique for each duplicate zombie object. Objects created from a class are called instances. Similar to families, objects can inherit properties from one another. The child sometimes called a subclass inherits attributes from its parent. For instance, the child created from a zombie may inherit the parent’s hunger for brains.
To be useful, the child zombie can also add new objects and change the objects it inherited from its parent class. As a result, now the child zombie might have tentacles that the parent didn’t have. Objects talk to each other through events and messages.

Shooting at zombies can create an event, or in programmer terms, it “raises” an event. The bullet impact event tells the zombie class to then take necessary steps when hit by a bullet.
Events command the class to take actions on its data, which is where functions come in.
Functions, also known as methods, are sections of logic that act on data. They allow your class to cre- ate additional events and talk to yet more objects.
As the player presses the trigger and moves the joystick around, yet more events can be raised and messages can be sent. Events and messages allow the player to interact with your world; logic events and objects together build your game.
No comments :

No comments :

Post a Comment