Friday, 20 February 2015

The If Factor: Crossy Road

          Conditional or if statements ask questions about the program state to choose from a set of different sequences of commands (Basically if something is true then a chosen set of commands will execute, and if not, a different set of commands will execute or nothing will happen).  Examples of if statements can be seen in almost all game and software applications. To find specific examples, we can look at the programming behind Crossy Road. 
          In Crossy Road, you have to tap the screen in order to move forward. An if statements would have been used by the programmer so that if screen is touched then move forward by 1. 



          Similarly, if the screen is swiped sideways or backwards, the game will automatically move the character sideways or backwards by 1 every time the screen is swiped in the desire direction. The basic code for this would sound like if screen swiped from left to right then move right by 1 OR if screen swiped from right to left then move left by 1. The same thing happens for moving backwards except the screen would need to be swiped downwards and the character would move down or backwards by 1.

          Watch out though! If you get hit my a car or a train, or even if you fall in water, then game stops and you temporarily 'die'. Don't worry though! Like in any video game you can try again and come back to life. The if statement to simulate this would be something like if character touches car then stop everything. The actual code for the game is much more complicated because after you 'die' different screens and options are brought up however, the main code for the whole action of 'dying' is probably similar.

          One of the really cool things about Crossy Road that keeps players interested is you can win different characters. If you have 100 coins then you can go to the prize machine to win a character. One of the codes for this would be if coins = <100 then show 'win a prize' button. If you wanted to go further you'd need a code that said if the button was pressed then show a different background, bring up a different script or 'character' etc. You would need a whole new set of codes to program the actual prize machine.

          One of the other cool things about Crossy Road is that if you have a certain character, the 'map' or 'roads' will be specified to that certain characters habitat or theme. To do this there would need to be an if code that said if '_______' character is selected then change background to '________'. Examples of this are desert areas for desert animals and winter areas for winter animals. There is also a map that turns black and white for Frankenstein and the main grassy one for all the basic characters.



Thursday, 12 February 2015

Variables, Programming and Video Games: It's not Chemistry But There Is Definitely a Connection

        What is a variable? Well basically (in math at least) it's a letter that replaces an unknown number. Variables can be used in programming as numbers, but they can also be used as text values such as "true" or "false" for example.
        So now that you know what a variable is your probably wondering to yourself "Well... what can be stored as a variable...". Well, I'll tell you that almost anything can be stored as a variable and they can be used to do hundreds of different things. You could create a variable called "store" that could store the information about the number of points you get during a game.

.An illustration of a computer game using variables to keep track of score.
("How Do Computer Programs Use Variable?" BBC News. BBC Bitesize, n.d. Web. 12 Feb. 2015.)

Now your probably wondering "Well... how could the word 'store' automatically know what I want it to do and store the number of points I have?" well that part is simple actually. When your avatar or character touches or "collects" a coin or piece of treasure for example, you could tell the program to increase the variable 'score' by 1. As you keep touching or 'collecting' points, the variable 'score' will keep changing.
        Variables are needed to run almost everything except the simplest of simple computer programs.  Programs need variables to store information as it runs. Whether it needs to store numbers, or answers to a question, variables allow us as programmers to change and access thing information as the program is running.


Here's a simple example of variable used in scratch programming:
1. Make the character as for your name

2. Make a variable called 'name' and set the variable to the answer
3. Make the character join the words 'Hello' and the variable 'name' and say "Hello (your name)".

GOOD LUCK!














Sunday, 8 February 2015

A Small Introduction to Scratch Programming

          Scratch is a program the teaches users the foundations and basic aspects of computer programming. It uses pre-written commands that can be pieced together rather then having to write the commands manually. Scratch offers a unique way to make programs without actually knowing how to code which makes it different from many other programs (which is pretty cool). Anyone can learn how to program with Scratch which makes it perfect for people like me who have never programmed before. There are 3 basic structures in Scratch that are each used to do specific things. The first is the sequential structure are sets of commands that repeat one after the other. Sequential structures are the basic set of commands that are used in larger, more complex structures. Repetition structures are what are used to repeat certain sequential structures a certain number of times. The command(s) is put into a loop or cycle until it has been completed, where it then moves to the next command after the repetition structure. Any command inside the repetition structure will be repeated for a set amount of time or until certain conditions are met. Finally, there are selection structures where certain commands will be completed if a 'statement' is completed as well. For example, one can make certain command happen if a certain button is pressed. If the button is not pressed, nothing will happen. However, one can make a selection structure that completes certain commands even if a 'statement' is not met. The structure will do a certain command if a statement is met, otherwise it will do another set of commands. All of these structures can be used together to make more advanced commands. This course is different from another other course I have ever taken. It is similar in the aspect that all or most of the work is done on a computer, however, instead of using other peoples programs, ICS 2O1 teaches you how to make your own. Although I have never programmed before now, I am excited to learn about all the new skills this course teaches that I never thought I could do.

(FLAPPY BIRD SCRATCH!)