String title= "4331a"; //boundary// int left=20, right= left+600; int top=50, bottom= top+400; Player pinhead; // object // void setup() { // screen set up // size (right+20,bottom+30); reset(); } void reset() { //Create a player// pinhead= new Player (); pinhead.name= "Pinhead"; } void draw() { // move pinhead and draw // scene(); pinhead.move(); pinhead.show(); } void scene() { // draw field w/ grass on bottom // fill (0,100,255); stroke (5); rectMode (CORNERS); // screen // rect(left, top, right, bottom); text( title, 7.5,25); fill (0,255,0); rect(0,350, 600, 50 ); } class Player { // pinhead moves and speed // float x=100, y=100; // placement on screen float dx=3,dy=2; // speed of movement per frame // String name= "Pinhead"; // player's name // int r1=100, g1=150, b1=50; int w=30, h=50; void move() { // move pinhead // if (xright-w/2) dx= -dx; // bounce // if (ybottom-h/2) dy= -dy; // bounce // x += dx; y += dy; } void show() { // show the player // rectMode (CENTER); fill(100,150,50); rect (x,y,w,h); ellipseMode (CENTER); ellipse(x,y-13, 24,24); fill(0); text(name, x-18, y-10); } }