Thursday, 16 August 2012

Programming for beginners – part 2

And here we are again, thanks for coming back!.

I hope everything was clear last time we met, if not please comment and let me know.

Today we are going to learn a few new things. First of all, on the right there’s a picture from my first app. I named it mini fono candy (or minifono for short). My plan is to take you from absolutely no programming knowledge to being able to make an app like minifono.

Like I said, let’s go slowly first. When I first started programming there were not many options and I only had access to a very small computer called zx81. It was similar to a programmable calculators we use these days. But it really worked as a teaching tool and because it was so limited it made me think things twice.

My first game, back in 1983, was a horse racing game. It was very rudimentary but it served it’s purpose. There were 10 horses and you could bet on one of them. At the end of the race you could win or loose, easy.

So the first thing I needed to do was to make 1 horse. Remember last time I was talking about the visual representation, the pixel, right?. So first thing was making a horse. Back then I just put 3 squares together, because that’s was all available, period. Today I would do it differently. I would make a horse with a paint software.

So let’s say we have an image of a horse, we now tell the computer to put it on the screen. And then move it to the right. We repeat this step as many times as needed to complete the amount of horses in our race. At the end we check which one wins, if it’s our horse we then increment our reward. That’s fine but what this has to do with programming? Well, years later I went to school and actually learn how to program. There they taught me something very important. They taught me that I need to understand the problem before I try to solve it.

Minifono is an app that teaches the numbers from 0 to 9 in English and Spanish. Right, so what’s the problem here? Mmmh.

Let’s say this: every time I touch a button I need to hear the sound of that number. That’s it? Well yes but wait, that’s easy to say but how on earth do we do it?

Let’s isolate the problem a little bit. First of all we need to show the button, then assign an event (touch) and then assign a sound to that event. Do you get it? Ok, so then let’s start with what we call CODE. A code is a language that the computer understand. It’s also known as programming language. So we first need to learn it before we can command the computer to do such things.

For every object that we see on screen we need a referrer, something, like a tag on a t-shirt. We call this tag a variable. And we need it because we need to put some information in it. Put? similar to a TAG, tags have information written on it right? things like price, brand, size, etc, right? I feel illuminated now. So a variable is a tag, a container that has information in it. We need to name those tags, we are going to call button1 to the first tag. So now we have a variable called button1. This variable is not attached to anything right now but it will NEXT WEEK !

So please read this as many times as needed. See you next week!

Oh and if you need to download minifono just click on it’s name and it will take you to the App Store it’s FREE, if you don’t have an apple device you can still get it from the Barnes and Noble Store.