//Nick Ferro Sept 6 2015 // Two Player Movement prototype String info_1= "Player 1 red, Player 2 blue"; String info_2= "Player 1 moves with WASD, Player 2 moves with arrow keys, Exit with X"; float x,y,z,w; void setup(){ size(1200,800); x= width/3; //player 1 location y=height/2; //player 1 location z=width/1.5; //player 2 location w=height/2; //player 2 location } void draw(){ background(200); fill(255); text( info_1, 20, 20); //Displays instructions text( info_2, 20, 40); fill(250,0,0); ellipse(x,y,20,20); fill(0,0,250); ellipse(z,w,20,20); } void keyPressed(){ if (key == 'd'){ //start player 1 controls x=x+20; } if (key == 'a'){ x=x-20; } if (key == 'w'){ y=y-20; } if (key == 's'){ //end player 1 controls y=y+20; } if (key == 'x'){ // exit option exit(); } if (key == CODED) { //start player 2 controls if (keyCode == RIGHT) { z=z+20; } } if (key == CODED) { if (keyCode == UP) { w=w-20; } } if (key == CODED) { if (keyCode == DOWN) { w=w+20; } } if (key == CODED) { //end player 2 controls if (keyCode == LEFT) { z=z-20; } } }