Homework 11.2

Here’s my “Shooter” class… Click the mouse anywhere to fire a “bullet”.
And each mouseclick generates a new bullet

Posted in Uncategorized | Leave a comment

Erick Asadobay H.W 11.2

http://www.openprocessing.org/sketch/96964

Posted in Uncategorized | Leave a comment

Jad Atoui – Homework 10.2 part 2

Jad Atoui – processing 10.2

I made a class that handles the sound objects and their status. I also envision making classes for slider and combing the sound and slider classes into a wrapping class called channel that manages the entire channel of sound.

An issue is related to the graphics and media contexts, where i  need to construct the movie object at the top appellation

new Movie(this, file)

“this” for this constructor is not well documented on the processing site and seems very inflexible .

//Sampler.pde main sketch

int LENGTH = 3;
String BASE_FILENAME = “sample”;
Sample[] sounds = new Sample[LENGTH];

PImage pauseIcon;
PImage playIcon;
int offset = 600;
int[] sliderY = new int[LENGTH];

void setup() {
size(1600,1200);
println(this);
//This is a for loop that load the 3 samples and initialises the status to 0 .
for(int i=0; i < LENGTH; i++) {

String file = BASE_FILENAME + String.valueOf(i) + “.wav”;
Movie sound = new Movie (this,file);
sounds[i] = new Sample(sound);
sliderY[i] = 365;
}
// here load the pause and play icons
println(“we are done”);
playIcon = loadImage(“play.png”);
pauseIcon = loadImage(“pause.png”);
colorMode(RGB, 100);
}

void draw() {
background(0);
noStroke();
drawInterface();
}
// draw ALL the buttons and the sliders for each sound – spacing icons and on off button
void drawInterface() {
for(int i=0; i < LENGTH; i++) {
int x = i*140 + offset;
int y = offset;
drawButton(i,x,y);
drawSlider(i,x,y);
}
}
//differciaion of the buttons
void drawButton(int index, int x, int y) {
if(sounds[index].getStatus() == 1) {
fill(25,255,25,60);
rect(x,y,101,101);
image(pauseIcon,x,y);
}
else {
fill(255,25,25,60);
rect(x,y,101,101);
image(playIcon,x,y);
}
}

void mouseDragged(){
// if(mouseX >= x && mouseX <= x+rectW && mouseY>= y && mouseY<=Y+rectH){

for(int i=0; i < LENGTH; i++) {
if(mouseX >= (offset+20+140*i) && mouseX <= (offset+80+140*i) ) {
println(mouseX);
println(i);
sliderY[i]= mouseY;
sliderY[i] = constrain(sliderY[i],200,530);
//change

float speed = map(sliderY[i],200,530,0.0,2.0);
sounds[i].changeSpeed(speed);

}
}
}

void drawSlider(int index, int x, int y) {
//stroke(255,0,0,100);

fill(125,125,125,65);
rect(x+20,y-400,60,360);

//draw the slider button
fill(255,0,0,60);
rect(x+20,sliderY[index],60,30);
}
void drawIcon(int index, int status) {

}
void mousePressed() {

// if(mouseX >= offset && mouseX <= (140+offset) && mouseY >= offset && mouseY <= offset+101) {
// toggleSound(0);
// }
// else if(mouseX >= offset && mouseX <= (140*2+offset) && mouseY >= offset && mouseY <= offset+101) {
// toggleSound(1);
// }
// else if(mouseX >= offset && mouseX <= (140*3+offset) && mouseY >= offset && mouseY <= offset+101) {
// toggleSound(2);
// }
}

void keyPressed() {
if(key == ‘f’)
toggleSound(0);
else if(key == ‘g’) {
toggleSound(1);
}
else if(key == ‘h’) {
toggleSound(2);
}
}

//This funtion toggle the sound on and off depending on the status
void toggleSound(int index) {
sounds[index].toggleSound();
}

//Sample.pde

//this class manages a single sound

import processing.video.*;
public class Sample
{
int status;
Movie sound;

public Sample(Movie sound) {
this.sound = sound;
status = 0;
}

public void changeSpeed(float speed) {
sound.speed(speed);
}

public void toggleSound() {
if(status == 0) {
stopSound();
}
else {
playSound();
}
}
public int getStatus() {
return status;
}

protected void stopSound() {
status = 1;
sound.stop();
sound.loop();
}

protected void playSound() {
status = 0;
sound.stop();
}
}

 

P.S : I can’t ipload the web export because of the Movie class .

Posted in Uncategorized | Leave a comment

10.2

//Making a robot
// L- left,r-right,w-width,x-X axis,Y-Yaxis
//robot head
int hY=105;
int hX=278;
int hW=45;
int hL=45;
int hsX=323;
int hsY=150;
int hsX2=329;
int hsY2=94;
int hsX3=326;
int htX=279;
int htY=104;
int htX2=286;
int htY2=94;
int htX3=329;
int htX4=324;
// rbot neck
int nX=295;
int nY=150;
int nL=20;
int nW=10;
//robot body
int bX=258;
int bY=165;
int bW=85;
int bL=80;
int blX=258;
int blY=244;
int blX2=251;
int blY2=245;
int blY3=155;
int blX3=248;
int brX=344;
int brY=245;
int brX2=350;
int brY2=238;
int brX3=349;
int brY3=155;
int blsX=258;
int blsY=166;
int blsX2=253;
int blsY2=154;
int blsX3=296;
int blsY3=185;
int brsX=304;
int brsY=166;
int brsX2=304;
int brsY2=154;
int brsX3=346;
int brsX4=343;
int brsY3=165;
//robot right shoulder using arc
float rsX=345;
float rsY=180;
float rsW=30;
float rsH=30;
float rsStart=0;
float rsStop=6.283185307;
float rsMode=OPEN;
//robot left shoulder
float lsX=255;
float lsY=180;
float lsW=30;
float lsH=30;
//int

//robot right arms
int raX=357;
int raY=179;
int raX2=360;
int raY2=180;
int raX3=368;
int raY3=182;
int raX4=376;
int raY4=184;
int raX5=379;
int raY5=198;
int raX6=379;
int raY6=219;
int raX7=361;
int raY7=198;
int raW=30;
int raL=40;
//robot left arm
int laX=258;
int laY=198;
int laW=30;
int laL=40;
int laX2=258;
int laX3=232;
int laX4=225;
int laX5=220;
int laX6=205;
// robot right leg
int rX=269;
int rY=264;
int rX2=15;
int rY2=70;

//robot left leg
int lX=313;
int lY=264;
// robot left feet
int flX=268;
int flY=333;
int flY2=344;
int flX2=284;
int flX3=257;
//robot right feet
int frX=313;
int frX2=328;
int frX3=339;
// robot mouth
int mL=10;
int mW=40;
int mX=280;
int mY=135;
// robot  eyes
int reL=10;
int reW=10;
int reX=313;
int reY=120;
int leX=287;
// robot anteena
int anteenaX=306;
int anteenaY=103;
int anteenaX2=306;
int anteenaY2=71;
//robot hip
float hipX=275;
float hipY=246;
float hipX2=326;
float hipY2=246;
float hipX3=344;
float hipY3=265;
float hipX4=256;
float hipY4=265;
int hipX5=277;
int hipY5=265;
int hipW=30;
int hipL=30;
int hipX6=320;
int hipY6=265;
//robot finger
int fingerX=207;
int fingerY=238;
int fingerX2=207;
int fingerY2=252;
int fingerX3=201;
int fingerW=10;
int fingerL=10;
// second finger
int sfingerX=222;
int sfingerX2=222;
int sfingerX3=216;
//third finger
int tfingerX=235;
int tfingerX2=235;
int tfingerX3=231;
//fouth finger
int fFingerX=362;
int fFingerX2=362;
int fFingerX3=362;
// fifth finger
int fiFingerX=376;
int fiFingerX2=376;
int fiFingerX3=376;
// six finger
int sifingerX=391;
int sifingerX2=391;
int sifingerX3=391;
int i=0;
float r,g,b;
RobotHead myRobotHead;

boolean robotmove=false;
int speed=1;
PImage img;
void setup() {
size(500,500);
myRobotHead= new RobotHead ();
}

void draw() {
myRobotHead.display();
myRobotHead.move();
img= loadImage(“DanceFloor.jpg”);
//image(img, 0, 150);
background(50);
robot(430,500,bX,bX);
move();
int x=height/2;
int y=width/2;
int w=0;
int l=0;

ellipse(reX,reY,reW,reL);
ellipse(leX,reY,reW,reL);
if(bX<width/2||x>width){
//speed=speed*-1;
//bX=bX+speed;
}
if(robotmove){
bX=bX;

}
else{
bX=bX+speed;}

if(bX<0|| bX>width){
speed=speed*-1;
}
}

void move() {
//bX=bX+1;

fingerY2=fingerY2+speed;

//if(fingerX<height){
//fingerY2=speed*-1;
} //}} }

void robot(int x, int y, int size, int fill) {

//ellipse(x,y,size,fill);
//size(x,y);
fill(255);
line(fingerX, fingerY, fingerX2, fingerY2);
rect(fingerX3, fingerY2, fingerW, fingerL);
line(sfingerX, fingerY, sfingerX2, fingerY2);
rect(sfingerX3, fingerY2, fingerW, fingerL);
line(tfingerX, fingerY, tfingerX2, fingerY2);
rect(tfingerX3, fingerY2, fingerW, fingerL);
line(fFingerX, fingerY, fFingerX2, fingerY2);
ellipse(fFingerX, fingerY2, fingerW, fingerL);
line(fiFingerX, fingerY, fiFingerX, fingerY2);
ellipse(fiFingerX, fingerY2, fingerW, fingerL);
line(sifingerX, fingerY, sifingerX, fingerY2);
ellipse(sifingerX, fingerY2, fingerW, fingerL);
beginShape();
vertex(blX, blY);
vertex(blX2, blY2);
vertex(blX2, blY3);
vertex(blX, blY3);
endShape();
beginShape();
vertex(hsX, hsY);
vertex(hsX2, hsY);
vertex(hsX2, hsY2);
vertex(hsX3, hsY2);
endShape();
//noFill();
beginShape();
vertex(brX, brY);
vertex(brX2, brY2);
vertex(brX3, brY3);
vertex(brX, brY3);
endShape();
beginShape();
vertex(blsX, blsY);
vertex(blsX2, blsY2);
vertex(blsX3, blsY2);
vertex(blsX3, brsY3);
endShape();
beginShape();
vertex(brsX, brsY);
vertex(brsX2, brsY2);
vertex(brsX3, brsY2);
vertex(brsX4, brsY3);
endShape();
rect(hX, hY, hW, hL);
rect(nX, nY, nW, nL);
rect(laX6, raY7, laW, laL);
rect(raX7, raY7, raW, raL);
// fill(255);
beginShape();
noFill();
curveVertex(raX, raY);
curveVertex(raX2, raY2);
curveVertex(raX3, raY3);
curveVertex(raX4, raY4);
curveVertex(raX5, raY5);
curveVertex(raX6, raY6);
endShape();
beginShape();
curveVertex(laX, raY);
curveVertex(laX2, raY2);
curveVertex(laX3, raY3);
curveVertex(laX4, raY4);
curveVertex(laX5, raY5);
curveVertex(laX6, raY6);
endShape();
fill(255);
//arc(lsX, lsY, lsW, lsH, rsStart, rsStop, rsMode);
//arc(rsX, rsY, rsW, rsH, rsStart, rsStop, rsMode);
rect(bX, bY, bW, bL);
rect(rX, rY, rX2, rY2);
rect(lX, lY, rX2, rY2);
//arc(hipX5, hipY5, hipW, hipL, 0, PI, OPEN);
//arc(hipX6, hipY6, hipW, hipL, 0, PI, OPEN);
ellipse(reX, reY, reW, reL);
ellipse(leX, reY, reW, reL);
rect(mX, mY, mW, mL);
line(anteenaX, anteenaY, anteenaX2, anteenaY2);
//ellipse(anteenaX2, anteenaY2, 20, 20);
quad(hipX, hipY, hipX2, hipY2, hipX3, hipY3, hipX4, hipY4);
beginShape();
vertex(flX, flY);
vertex(flX2, flY);
vertex(flX2, flY2);
vertex(flX3, flY2);
vertex(flX, flY);
endShape();
beginShape();
vertex(frX, flY);
vertex(frX2, flY);
vertex(frX3, flY2);
vertex(frX, flY2);
vertex(frX, flY);
endShape();
beginShape();
vertex(htX, htY);
vertex(htX2, htY2);
vertex(htX3, htY2);
vertex(htX4, htY);
endShape();
stroke(0);
// randomSeed(10);
fill(r,g,b);
ellipse(anteenaX2, anteenaY2, 20, 20);
//line(0, height/2, width, height/2);
//line(width/2, 0, width/2, height);
println(mouseX);
println(mouseY);
r=random (255);
b=random(0);
g=random(0);
}
void mousePressed(){
if(mouseX>bX&&mouseX<bX+bW&& mouseY>bY&&mouseY<bY+bL){
robotmove=!robotmove;
}}
class RobotHead {
int hY;
int hX;
int hW;
int hL;
int hsX;
int hsY;
int hsX2;
int hsY2;
int hsX3;
int htX;
int htY;
int htX2;
int htY2;
int htX3;
int htX4;
int speed;
RobotHead() {
hY=105;
hX=278;
hW=45;
hL=45;
hsX=323;
hsY=150;
hsX2=329;
hsY2=94;
hsX3=326;
htX=279;
htY=104;
htX2=286;
htY2=94;
htX3=329;
htX4=324;
}

void move() {
hY=hY+speed;
hX=hX+speed;
hW=hW+speed;
hL= hL+speed;
hsX=hsX+speed;
hsY= hsY+speed;
hsX2=hsX2+speed;
hsY2=hsX2+speed;
hsX3= hsX3+speed;
htX=htX+speed;
htY=htY+speed;
htX2=htX2+speed;
htY2=htY2+speed;
htX3=htX3+speed;
htX4= htX4+speed;
}

void display() {
beginShape();
vertex(htX, htY);
vertex(htX2, htY2);
vertex(htX3, htY2);
vertex(htX4, htY);
endShape();
rect(hX, hY, hW, hL);
beginShape();
vertex(hsX, hsY);
vertex(hsX2, hsY);
vertex(hsX2, hsY2);
vertex(hsX3, hsY2);
endShape();
}
}
when i upload to openprocessing i get a plank  background

http://www.openprocessing.org/sketch/96597

Posted in Uncategorized | Leave a comment

Mohammad Rahat 10.2

since I didn’t really have a decent midterm, I just did something simple

class Rect {

color c;
int xpos;
int ypos;

Rect() {
c = color(255);
xpos = 100;
ypos = 50;
}

void display() {
fill(c);
rect(xpos, ypos, 200, 200);
}
}

Rect myRect;

void setup() {
background(0);
size(400, 400);
myRect = new Rect();
}

void draw() {
myRect.display();
}

Posted in Uncategorized | Leave a comment

Nafis Sabir HW 10.2

CelestialBody class is at the bottom.

I was having a hard time trying to figure out how to break my program down into classes since I didn’t really use any objects in the program. I was thinking about a class for the seasons, but it wasn’t working out like I wanted. I decided to create a CelestialBody class, using a slightly modified bouncing ball code. I’ll use this to add a body for each of the seasons. Right now I only have a sun, but I was thinking about the moon, clouds, etc…
The program will only run in java, so I pasted the code below.

/*Nafis Sabir
Professor Calli Higgins
HW 10.2*
/
/* There’s a problem with parts of the code working in Javascript so some of the code is commented out. The main problem appears to be something with the images being used in the program. I’ll have to figure out why this problem is occurring.*/

//import ddf.minim.*;
////initialize audio
//Minim minim;
//AudioSample fireworks;
//AudioSample hallow;
//AudioSample leaves;
//AudioSample love;
//AudioSample snow2;
//AudioSample ocean;
//AudioSample olympic;
//AudioSample rain;
//AudioSample sleigh;
//AudioSample birds;
//AudioSample turkey;
//AudioSample snow;

PImage january, february, march, april, may, june, july, august;
PImage september, october, november, december;
int d, m, y, dateX, dateY, springc, winter, fall, summer, season;
float l, r, u, dn;
PFont myfont;
CelestialBody sunBody;// declare a CelestialBody object

void setup() {

size(640, 425);
sunBody = new CelestialBody();//initialize the CB object
l = width;
r = -600;
u = height;
dn = -425;
//loads audio
// minim = new Minim(this);//start sound engine
// //loads audio sample files
// fireworks = minim.loadSample(“fireworks.wav”, 2048);
// hallow = minim.loadSample(“hallow.mp3”, 256);
// leaves = minim.loadSample(“leaves.mp3”, 256);
// love = minim.loadSample(“love.mp3”, 256);
// snow2 = minim.loadSample(“snow2.wav”, 256);
// ocean = minim.loadSample(“ocean.mp3”, 256);
// olympic = minim.loadSample(“olympic.mp3”, 256);
// rain = minim.loadSample(“rain.mp3”, 256);
// sleigh = minim.loadSample(“sleigh.mp3”, 256);
// birds = minim.loadSample(“birds.mp3”, 256);
// turkey = minim.loadSample(“turkey.mp3”, 256);
// snow = minim.loadSample(“snow.mp3”, 256);
january = loadImage(“january.jpg”);
february = loadImage(“february.jpg”);
march = loadImage(“march.jpg”);
april = loadImage(“april.jpg”);
may = loadImage(“may.jpg”);
june = loadImage(“june.jpg”);
july = loadImage(“july.jpg”);
august = loadImage(“august.jpg”);
september = loadImage(“september.jpg”);
october = loadImage(“october.jpg”);
november = loadImage(“november.jpg”);
december = loadImage(“december.jpg”);

myfont = loadFont(“Dialog-70.vlw”);//temporary font for date
textFont(myfont, 70);
}

void draw() {
d = day(); // Values from 1 – 31
m = month(); // Values from 1 – 12
y = year(); // 2013, 2014, 2015, etc.
dateY = 60;//date y location
dateX = 20;//date x location
springc = #00CC00;//date fill for months spring
winter = #66A3D2;//date fill for months winter
fall = #FF6A00;//date fill for months fall
summer = #F7FE00;//date fill for months summer
//winter();
//spring();
//summer();
//fall();
println(m);

if (m <= 12) {//if month is january to december
randomSeed(d);
// background(255,0,0);
background(random(0, 255), random (0, 255), random (0, 255), 0);//background changes color depending on the date

if (m == 1) {//if month is january
january();
// for (int a=20; a < 20+(d*20); a=a+20) {//future place for image code
// image();
}
}

if (m == 2) {//if month is february
february();
// for (int a=20; a < 20+(d*20); a=a+20) {
// image();
}
// }

if (m == 3) {//if month is march
march();
// for (int a=20; a < 20+(d*20); a=a+20) {
//image();
//}
}

if (m == 4) {//if month is april
april();

// for (int a=20; a < 20+(d*20); a=a+20) {
// image();
}
// }

if (m == 5) {//if month is may
may();
// for (int a=20; a < 20+(d*20); a=a+20) {
// image();
// }
}

if (m == 6) {//if month is june
june();
// for (int a=20; a < 20+(d*20); a=a+20) {
// image();
// }
}

if (m == 7) {//if month is july
july();
//if (key == '7' )fireworks.trigger();
// for (int a=20; a < 20+(d*20); a=a+20) {
// image();
// }
}

if (m == 8) {//if month is august
august();
// for (int a=20; a < 20+(d*20); a=a+20) {
// image();
// }
}

if (m == 9) {//if month is september
september();
// for (int a=20; a < 20+(d*20); a=a+20) {
// image();
// }
}

if (m == 10) {//if month is october
october();
// for (int a=20; a < 20+(d*20); a=a+20) {
// image();
// }
}

if (m == 11) {//if month is november
november();
// for (int a=20; a < 20+(d*20); a=a+20) {
//image();
// }
}

if (m == 12) {//if month is december
//background(255);
december();
// for (int a=20; a =1) {
l -= 1;
}
}
void imageRight() {//moves image from left to right
if (r = 1) {
u -= 1;
}
}

void imageDown() {//moves image from top to bottom
if (dn = 12) || (m= 3) && (m= 6) && (m= 9) && (m<= 11)) {
season = fall;
println("It's Fall!");
}
}
//void keyPressed() {
// if (m==7 && key == '7' )fireworks.trigger();
// if (m == 10 && key == '0' )hallow.trigger();
// if (m == 9 && key == '9' )leaves.trigger();
// if (m == 2 && key == '2' )love.trigger();
// if (m == 3 && key == '3' )snow2.trigger();
// if (m == 6 && key == '6' )ocean.trigger();
// if (m == 8 && key == '8' )olympic.trigger();
// if (m == 4 && key == '4' )rain.trigger();
// if (m == 12 && key == 'd' )sleigh.trigger();
// if (m == 5 && key == '5' )birds.trigger();
// if (m == 11 && key == 'n' )turkey.trigger();
// if (m == 1 && key == '1' )snow.trigger();
//}

//at the bottom of the page

//void stop() {
// fireworks.close();
// hallow.close();
// leaves.close();
// love.close();
// snow2.close();
// ocean.close();
// olympic.close();
// rain.close();
// sleigh.close();
// birds.close();
// turkey.close();
// snow.close();
// minim.stop();
// super.stop();
//}

//CelestialBody class code
class CelestialBody {
//CB variables
color c;
int x;
int y;
int speed;

//Initialize data variables
CelestialBody() {
c = color(#FFF708);
x = 0;
y = 50;
speed = -1;

}

//CelestialBody functions
void fly() {//moves CB across the screen
x = x + speed; // Change the x location by speed
}

void orbit() {//function to make the CB return

if ((x > width) || (x < 0)) {//change direction when at the edge of the screen
speed = speed * -1;
}
}

// A function to display the CB
void display() {
stroke(0);
fill(c);
ellipse(x, y, 75, 75);
}

} //close CelestialBody class

Posted in Uncategorized | 1 Comment

Matthew_Soto_10.2_Hw_Post

Posted in Uncategorized | Leave a comment

Matthew_Soto_Midterm_Object_Breakdown

When looking at my midterm I noticed that I can break down just about all my the objects in my midterm into parts. For example the the Buildings, the moving cars, and the moving plane. Each of them can be given their own attributes to make them objects and therefore can be used multiple times. Mainly the buildings and the cars.

Posted in Uncategorized | Leave a comment

HW 10.2

This assignment is more difficult than I assumed I thought all I had to do was create a food class for my snake game

class Food{
int xpos;
int ypos;
color c;

Food(){
xpos = int(random(1,199));
ypos = int(random(1,199));
c = color(0,0,255);
}

void display(){
fill(c);
rect(xpos,ypos,5,5);
}
}

but when I add myFood.display the processing doesn’t run. It could be that I am missing something in my main code or in the Food class, but I will try to fix it before class.

Another class that I can create for my midterm is a snake class.

Posted in Uncategorized | Leave a comment

Homework 10.2

So we were assigned to change one part of our midterm code into class, thus giving me to work with my pong code. Big mistake of my life to even start to try. My midterm was on pong, so I have the option to class up either the ball or the paddle. The ball itself have 3 sets of codes; the speed where it starts, what would happen when it hits the paddle, and because it is linked, the computer paddle follows the ball. If I were to class that, it would mainly just end up as more of a mess than I started with.

EDIT: In case the openprocessing thing doesn’t show, as it doesn’t on my screen. The code:

Ball myBall;
int bally = 300;
int ballx = 500;
int speed = 2;
int directx = speed;
int directy = speed;
float randplacing = 300;
float fast = 1.5;
boolean started = false;
PImage wallpaper;

void setup(){
size (1000,600);
myBall = new Ball();
wallpaper= loadImage(“pongLAfinal191.jpg”);
image(wallpaper,1000,600,width,height);
frameRate(100);
}

void draw(){
background(0);
if(started == false){
if(mouseY 600 && mouseX 600){
fast = 1.5;
speed = 2;
started = true;
myBall.display();
}

}

//Ball
bally = bally + directy;
ballx = ballx + directx;
rectMode(CENTER);
rect(ballx, bally, 10,10);
noStroke();
if (ballx == 990 && bally = mouseY-50) {
//Ball Go upward
if (bally mouseY) {
directx = – speed;
directy = + speed;
}
//Ball Stayput
if (bally == mouseY) {
directx = – speed;
directy = 0 ;
}
}

//Player Paddle
rectMode(CENTER);
rect(990, mouseY, 10 , 80);
noStroke();

//ComputerPaddle
rectMode(CENTER);
rect(10, randplacing, 10, 80);
noStroke();
//Make computerpaddle chase after ball
if(randplacing bally){
randplacing = randplacing – fast ;
}

//Computer Paddle Movement
if (ballx == 20 && bally = randplacing – 50){
// Go Up if ball does
if (bally randplacing) {
directx = speed;
directy = + speed;
}
// Stay if it stays
if (bally == randplacing) {
directx = speed;
directy = 0 ;
}

}

//Wallbounces
//Right
if ( bally == 600) {
directy = – speed;
}
//Left
if ( bally == 0) {
directy = speed;
}
//Reset when Right Scored
if (ballx 1000){
ballx = 400;
bally = 300;
}

}
——————————

class Ball{
color c;
int bally;
int ballx;
int speed;

Ball(){
c = color(0);
bally = 300;
ballx = 500;
speed = 2;
}

void display(){
rectMode(CENTER);
fill(c);
rect(ballx,bally,10,10);
}
}

EDIT#2: Here’s a direct link to open processing

http://www.openprocessing.org/sketch/96414

Posted in Uncategorized | 2 Comments