Pixelh8 @ Computing Club, Holywells High School, Ipswich “Processing Lesson 2″
I am genuinely very proud of my Computer Club only the second week in to programming with “Processing” and they are real getting it, they are really thinking logically and coherently. Below is a simple program to load a sprite place it on the screen and move it around using the cursor keys, they were all able to follow my instructions and get it to work.
I also set a few traps along the way for them to figure out for themselves and they were successful in solving the problem. Again this is just another piece of the overall project, and will later be merged with work from other sessions.
Cleverly they also worked out how to load other graphics and experimented with them too.
To get the below example to work
1) Load up processing and save immediately this will create a folder, example “MazeGame”
2) Within that folder create another folder called “data” so MazeGame\Data
3) Within that folder put a graphic called “good.png” 40X40 pixels.
4) Run it
//MazeGame
//Copyright Room 1 Studios 2009
//Matthew C. Applegate – Pixelh8
int goodx, goody;
PImage hero;
void setup(){
background(0);
size(600, 400); // 15 X 10
hero = loadImage(“good.png“);
}
void draw (){
background(0);
updatescreen();
}
void updatescreen (){
image(hero, goodx*40, goody*40);
}
void keyReleased() {
if (key == CODED) {
if (keyCode == UP) {goody=goody-1;}
if (keyCode == DOWN) {goody=goody+1;}
if (keyCode == LEFT) {goodx=goodx-1;}
if (keyCode == RIGHT) {goodx=goodx+1;}
}
}
Posted in Educational, Holywells Computing Club, Lectures & Workshops, Programming in Schools, Visits |