Universal Programming Structures
Creating worlds, one line of code at a time.
Blocks, Containers, Machines, and.. Delivery Trucks?
When writing code, it’s best to think of your project as your delivery truck. It is how you get what you want out the door to your user.
so to start off with, every programming language has something to define as a variable. Keep in mind that the semicolon at the end is required.
float seconds;
int length;
string name;
bool isSomething;How you define variables is very important. It is always best to look at the way programming is done in your language of choice.
float a_thing;
float athing;
float AThing;
float aThing;all four of these count as different variables in C#. These are your blocks, and a lot of how your program works is based entirely how these blocks are used.
Get cameron mcleod’s stories in your inbox
Join Medium for free to get updates from this writer.
These blocks have to be used in something though, otherwise nothing will get done.
void Machine()
{
block = cube;
}
These are functions. They tell your blocks how to do things. For example:
public void UpdateBounds(Vector4 newBounds)
{
//left, right, upper, lower.
leftBounds = newBounds[0];
rightBounds = newBounds[1];
upperBounds = newBounds[2];
lowerBounds = newBounds[3];
}This adjusts the bounds of something to a set of four new values, each one labeled as left, right, upper, and lower bounds. There’s more you can do with functions, but they will be expanded upon in a later article.
class Player
{
Vector3 position;
int speed;
private void DoMovement()
{
Vector3 motion = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
position.Translate(motion * (Time.deltaTime * speed));
}
}Note that Input and Time are separate classes from the player in the above example.









