C++ 08 – Structs

A lot of the variables we use in our programs are related. For example, the two coordinates of a 2D vector, or a pointer pointing to an array and the size of said array. It would be useful if we could define types that consist of several variables grouped together.

In C++ and other languages, this can be achieved through the use of structs. In this lesson we will see how and why structs are used.
Continue reading “C++ 08 – Structs”

C++ L07 – Arrays

On the previous post we discussed about pointers. Pointers is a very important feature of C++ and it is something missing from other similar object oriented languages like Java and C#. While pointers is a great feature and a must for high performance it is also a source of great pain and agony. This power and agony both come from memory management.

Pointers provide direct access to memory. An array is the simplest data structure, since it is just a block of memory. It is also one of the most useful.

Continue reading “C++ L07 – Arrays”

C++ L06 – Pointers

Pointers is one of the most important features of C++. It is a feature that is (purposely) missing from other popular object-oriented languages like Java and C#.

Pointers are a powerful thing. It gives you direct access to computer memory. However, with great power comes great responsibility, since a great chunk of programming errors in C++ are related to pointers.

In this post we are going to explore pointers and memory and update our game with new features.

Continue reading “C++ L06 – Pointers”

C++ L05 – Functions

Functions are pieces of code that do certain things based on given arguments. When writing programs, you will start to notice patterns in your code, things that you repeatedly do. Instead of copying and pasting code here and there, you simply wrap this code as a function and call that.

Not only this saves you a lot of typing, but imagine if for some reason you want to change a pattern (like a sneaky typo); you would have to go hunting for every instance. If instead, you have defined your reusable patterns as functions, you can change it once and work everywhere.
Continue reading “C++ L05 – Functions”

C++ L04 – Control structures

On this post we are going to start developing our first game. The game we will be writing is going to be an adventure with ASCII graphics, meaning that we will present our world using console output. On the posts that will follow we will expand on this game, divert it to something different and maybe even start using real graphics.

Our goal for this post, is to print a basic map and move our character using console input in the form of north-south-east-west [nsew].

Continue reading “C++ L04 – Control structures”

C++ L03 – Variables, types and operators

In order to be able to do something interesting and useful with C++, we have to take advantage of computer memory. The way we use computer memory is though variables.

On this post, I will show how you can define and use variables and apply operations on them.

Continue reading “C++ L03 – Variables, types and operators”

C++ L02 – Analyzing hello world

On the previous post we talked about setting up a C++ development environment. You should be able to compile and run C++ programs.

On this post we will be analyzing the previous hello world program in order to become familiar with some of the language features and artifacts. Don’t worry if you don’t understand everything that is mentioned here. Most of the terms discussed, are going to be posts of their own.

Continue reading “C++ L02 – Analyzing hello world”

C++ L01 – Setting up and Hello World

Video game development is mostly done in C++. A reason behind this is that C++ is close enough to the hardware, that the needed performance can be achieved. Of course there are disadvantages to using C++, since it is not by any means a perfect language. That said, having knowledge of a language like C++ will provide you with valuable insight and a lot of it can be transferred to other languages and environments such as Java and C#.

In order to be able to program in any programming language, it is vital to setup an (efficient) environment. This lesson is here to get you up to speed with programming with C++.
Continue reading “C++ L01 – Setting up and Hello World”