Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Programming Basics

An overview of some of the most common techniques used in computer programming.
by

Graham Hastings

on 23 March 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Programming Basics

Computer programmers use some standard techniques or building blocks to create their computer programs.
This Prezi will introduce you to some of these techniques
and will give you some Scratch examples that you can use in your own programs. Programming
Basics Graphics Many of the programs or apps that you use will be graphical.
They make use of colourful backgrounds and moving images or characters known as sprites. Repeat If a program is going to work it must run in the correct order or sequence.
You can program Scratch so that one sprite tells another sprite a joke. If the sprites don't speak in the right order the joke does not make sense. Sequence Variables Sometimes you will want to store some data in your programs. A good example is a game that needs to keep a player's score.
We use something called a variable to keep the score. The varible will have to change each time a player scores some more points. Decisions Programs can just follow a simple sequence of instructions but more often programs are written to respond to something that the user has done or to an event that has taken place. Motion If you are using sprites you need to be able to position them on the screen. This is done by using a system of screen coordinates.
The same system of coordinates can be used to move your sprites on the screen. x is the horizontal position and y is the vertical position.
If you increase the x value the sprite will move to the right - if you decrease the x value the sprite will move to the left.
If you increase the y value the sprite will move up the screen - if you decrease the y value the sprite will move down the screen. The red fish is at x: -100 y: 100
The yellow fish is at x: 100 y: 100
The blue fish is at x: -100 y: -100
The green fish is at x: 100 y: -100 Sprite 1 - "Doctor."
Sprite 2 - "Who's there?"
Sprite 1 - "How did you know?"
Sprite 1 - "Knock knock."
Sprite 2 - "Doctor who?" You will often want to do something more than once in your programs.
Computers are excellent at repeating instructions. They can do so over and over again, they never get tired and never make a mistake.
This is sometimes called looping or iteration. The script on the left will make the bat flap its wings as it moves.
For an animation the bat needs to keep flapping its wings so we have used a repeat loop to make it flap itd wings ten times. In the game shown on the right the big green fish has to eat all the little red fish.
The program will hide the red fish when it has been eaten.
The program must make a decision - have the teeth of the large fish touched the red fish?
The movement of the red fish is placed in a loop that will make it repeat forever but if the red colour of the little fish touches the dark blue colour on the teeth of the large fish, the little fish will say 'Got me!' and will then be hidden to make it look as if it has been eaten.
This is also known as selection. A good way to think of a variable is to imagine a little box into which a number can be placed. The variable must be given a name. We will call it n because it is going to store a number (variables can also store letters and words).
Suppose a player scores 4 goals - we must store 4 in the variable called n. If the player scores another point we will need to add 1 more to the variable. The variable needs to change to the variable plus 1. This can be written as n = n +1 (see the diagram below) so n= 4 + 1 = 5. The player's score is now 5.
We can do this with the script change n by 1.
Full transcript