Programming – Week 2

Another week of programming has come to an end, and LOTS of new things has been introduced. We have been introduced to functions, arrays, references and pointers, how to use rand and srand to produce a random number. As you can see, lots of things. During thursday and friday we also had a workshop where we went through the code for the classic game Pong. This was done by using Visual Studio and SDL, which stands for Standard Digital media Library.

In the code we were introduced to something that interested me, which was struct, it’s a data structure of a group of data

elements under one name, these data elements, known as members can be of different types. For instance, int weight and double price, this would be two declared variables in the struct which you can use in for example your main function later.
In the screenshot you can see that I have three data structures for Paddle, Ball and Game, all with different members. These are also used in various functions later in the code, easy way to reuse the code instead of always having to recode it.

kodning

About Ludvig Storm

2014  Programming