Академический Документы
Профессиональный Документы
Культура Документы
About Technocamps
We go around schools and show you lots of interesting stuff!
Computer Science:
• What do you already know about Computer
Science?
• What is Computer Science?
Fact: Computers aren’t very smart!
In order for the computer to do ANYTHING it
has to be told specifically what to do. It needs
tasks breaking down into simple steps. This is
what programming is!
I am SILLY!
Fact: You can make them very smart!
“Computers are incredibly fast, accurate, and
stupid. Human beings are incredibly slow,
inaccurate, and brilliant. Together they are
powerful beyond imagination.”
Leo Cherne 1968.
Why choose
Computer
Science?
Watch this:
https://www.youtube.com/watch?
v=1o0oA3fa2ws&feature=related
Modeling in the “Real World”
• Clear, concise instruction giving is important.
• Solving real problems in addition to making fun games, what kind of problems
can you think of that could be solved?
• What jobs and careers are there? What do you think it is like working in the
Computing industry?
Watch this:
http://www.youtube.com/watch?v=yGStqRMShj4&lr=1
What careers are available?
Database
Designer Technician Teacher
analyst
Class MyFirstJavaProg!
{ !
public static void main(String [] args)!
{!
System.out.println("Hello World!");!
}!
}!
RoboGirl: Lisa!
Class: Robot
Name
RobotNumber
GroupName
GroupNumber
Progranimate
Progranimate
Go to the Progranimate website: www.progranimate.com
• Click on “Programming Problems”.
• Click on “Sequence”.
Watch this:
http://www.youtube.com/watch?
v=f7qQWvMb64U&feature=relat
ed
Greenfoot Interface
Class!Diagram!
World!
Greenfoot Interface
Subclass!
Constructor!
Instance!of!
“Wombat”!class!
How to make Objects “Act”
• Click on “Act” in the execution controls.
Each object has a built in “Act” method, so any instructions added here are run
when the “Act” button is pressed. In the Wombat example, the leaves are currently
not commanded to do anything, however the Wombats are programmed to move
forward.
{} curly brackets:
These are called “braces” or “squiggly brackets”. In Java, these are used to
surround blocks of code such as methods of class content.
Movement
Enter the amount of steps to move within the round brackets inside the “Act”
method. This will run each time the “Act” button is pressed after the code is
compiled.
Movement
Next, underneath “move(4);” command the actor to also turn to the value of 3.
See what happens after compiling and pressing “Act” what do you think “3” stands
for?
Task
Experiment with the code in this “Act” method:
You can use “IF” statements in your code to get your Actor to react to keyboard input, such
as the code snippet below:
Obstacles
• Add a new Actor, a rock has been used as an example. This will be your
obstacle.
• You do not want this to move, so the code here does not need to be altered/
added to.
• Place a variety of rocks around the World. To place these at random, click
“WombatWorld” and open up the code.
• Copy the “RandomLeaves” method and paste directly below, edit the name of
“Leaves” to your given obstacle name and re-name the method so you do not
have 2 methods with the same names.
Obstacles continued…
• In order to stop the Wombat moving through the obstacle, add the below code
to make a new method in the “Wombat” class:
public boolean noRocks(int x, int y) {
World myWorld = getWorld();
List rocks = myWorld.getObjectsAt(x, y, Rock.class);
if(rocks.isEmpty())
{
return true;
}
else
{
return false;
}
}
Remember to change the name of “rock” to whatever you have named your
obstacle.
Randomly moving Actors
Greenfoot.playSound(“file.filetype”);
Score
Score is sometimes the most fun
part of a game. It allows other
players to compete against one
another without having to play at
the same time. It also allows a user
to assess how well they play the
game, progressing and improving
their score each time.
www.greenfoot.org/files/javadoc/index-all.html
New game: PONG!
You can create a new scenario called “Pong”.
W = up
A = left
S = down
D = right
New game: Shooting Game!
You can create a new scenario called “Shooting”.
http://www.greenfoot.org/doc/tut-2
The aim of the game is to control the “Crab” using the left and
right keyboard arrow controls to collect and eat the worms as
the crab spins. Alternatively you can make the crab follow your
mouse around the World.
Make sure you avoid the lobster!
New game: Marble Drop!
You can create a new scenario called
“MarbleWorld”.
www.greenfoot.org/files/javadoc/index-all.html
Post-day
Questionnaires