Homework 4.2 Part 2

My midterm is still a work in progress, I’m still not sure what I’d like to do…..

Posted in Uncategorized | Leave a comment

4.1 HW

*Missing A Few Things Couldnt Figure It Out* 4.1 HW _Ashlee Frontin

 

int x = 50;
int y = 50;
int w = 25;
int h = 25;
int x2 = 10;
int y2 = 50;
int w2 = 30;
int h2 = 30;
int x3 = 30;
int y3 = 30;
int w3 = 35;
int h3 = 35;

int state = 1;
int speed = 1;
boolean insidepress = false;
boolean insidecolor = false;
boolean insideshape = false;

void setup()
{
size (200,200);
}

void draw()
{
if(state == 1)
{
background(255,0,0);
}
else if (state == 2)
{
background(0,255,0);
}
else if (state == 3)
{
background(0,0,255);
}
rect (x, y, w, h);
fill(255);
if (x < 0 || x >= width || y < 0 || y >= height)
{
speed = speed * -1;
}

if (insidepress)
{
x = x;
y = y;
}
else
{
x = x + speed;
y = y + speed;
}

if (insidepress)
{
x = x;
y = y;
}
rect (x2, y2, w2, h2);
if (x2 < 0 || x2 >= width)
{
speed = speed * -1;
}

x2 = x2 + speed;
if (insidecolor)
{
rect (x, y, w, h);
fill (255,287,67);
rect (x2, y2, w2, h2);
fill (255);
}
if (insideshape)
{
rect (x3,y3,80,40);
}
else
{
rect (x3, y3, w3, h3);
}
if (y3 < 0 || y3 >= height)
{
speed = speed * -1;
}
y3 = y3 + speed;

}

void mousePressed()
{

if (mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h)
{
insidepress = !insidepress;

}

if (mouseX > x2 && mouseX < x2+w2 && mouseY > y2 && mouseY < y2+h2)
{
insidecolor = !insidecolor;
}
if (mouseX > x3 && mouseX < x3+w3 && mouseY > y3 && mouseY < y3+h3)
{
insideshape = !insideshape;
}
state++;

if(state == 4){
state = 1;
}

}

Posted in Uncategorized | Leave a comment

homework 4.1

//tried my best but there seems to be an error(s). Stuck on the freezing ball theorem.

 

int x=300;
int speed=2;
boolean button=false;
void setup(){
size(600,600);
}

void draw(){
background(mouseX,mouseY);
noStroke();
if (button) {
x=x;
}
fill(mouseX,121,30);
rect(x,200,100,100);

if(x > width) {
speed=speed * -1;
}
else if (x < 0){
speed = speed * -1;
}
x = x+speed;
}
fill(255);
rect(x,200,100,100);
if(mousePressed) {
fill(8,34,255);
rect(x,300,100,100);
button=!button;
}else{
background(255);
fill(0);
rect(x,200,150,150);
}

Posted in Uncategorized | Leave a comment

Noah Ruede – HW 4.1

EDIT: Figured it out and fixed it.

int ax =300;
int ay =200;
int bx=300;
int by=0;
int cx=300;
int cy=500;
int w=100;
int h=100;
int aspeed = 1;
int bspeed =1;
int cspeed=1;
boolean ccol;
boolean freeze;
boolean aclk;
boolean bclk;
boolean cclk;
int state=1;

void setup() {
size(600, 600);
}

void draw() {
if (freeze) {
ax = ax;
}
else {
ax = ax + aspeed;
}

bx = bx + bspeed;
cx = cx+cspeed;

if(state==1){
background(0);
}
else if(state==2){
background(0,0,255);
}

fill(255);
rect(ax, ay, w, h);
rect(bx, by, w, h);

if (ax+w > width) {
aspeed = aspeed * -1;
}
else if ( ax < 0) {
aspeed = aspeed * -1;
}

if (bx+w > width) {
bspeed = bspeed * -1;
}
else if ( bx < 0) {
bspeed = bspeed * -1;
}

if (ccol) {
fill(255, 0, 0);
}
else {
fill(255);
}

rect(cx, cy, w, h);
if (cx+w > width) {
cspeed = cspeed * -1;
}
else if ( cx < 0) {
cspeed = cspeed * -1;
}
}

void mousePressed() {
if (mouseX > ax && mouseX< ax+w && mouseY > ay && mouseY < ay+h) {
freeze=!freeze;
aclk=true;
}

if (mouseX > bx && mouseX< bx+w && mouseY > by && mouseY < by+h) {
bspeed=bspeed*-1;
bclk=true;
}

if (mouseX > cx && mouseX< cx+w && mouseY > cy && mouseY < cy+h) {
ccol=!ccol;
cclk=true;
}

if(!aclk && !bclk && !cclk){
state=state+1;
}
if(state>2){
state=1;
}
}

Posted in Uncategorized | Leave a comment

Homework 4_1

//Terrance Shields – Prof. Calli Higgins – HW 4.1 – 2/21/13

boolean square = true;
boolean ball = true;
boolean quad = true;

int bgChange = 0;

int bgColor = 255;

color green = color(28, 198, 14);
color blue = color(14, 138, 198);
color purple = color(145, 14, 198);
color white = color(255);

float x = 10; // x location of square
float y = 0; // y location of square
float bx = 0;
float by = 100;
float qx = 0;
float qy = 400;
float squareSpeed = 0; // speed of square
float ballSpeed = 3;
float quadSpeed = 1;
float gravity = 0.1;

void setup() {
size(400, 400);
smooth();
}

void draw() {
background(bgColor);

// Display the square
fill(0);
noStroke();
rectMode(CORNER);
rect(x, y, 30, 30);
fill(255, 255, 0);
ellipseMode(CORNER);
ellipse(bx, by, 40, 40);

if (square) {
x++;
y = y + squareSpeed;
squareSpeed = squareSpeed + gravity;
}
if ((x > width) || (x height) {
squareSpeed = squareSpeed * -0.95;
}
else if (!square) {
squareSpeed = 0;
}

if (ball) {
bx = bx + ballSpeed;
// If ball reaches the sides //
if ((bx > width) || (bx width) || (bx width) || (qx width) || (qx x && mouseX y && mouseY bx && mouseX by && mouseY qx && mouseX qy && mouseY 3) {
bgChange = 0;
}
}

Posted in Uncategorized | Leave a comment

Nafis Sabir HW 4.1

This isn’t finished. I was having a really hard time trying to figure out how to get the ball/mouse location correct, among other things. I was having such a hard time locking that down, I didn’t even try to wrap my mind around the triangle ad quad. Did get them moving though. The color change for the background also has some bugs. Hours and hours…

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

/*Nafis S Sabir
Prof. Calli Higgins
HW 4.1*/
int state = 0;
int x = 300;//rect x location
float y = random(500);//random rect y location
int speed = 2;//x-axis speed change
int bounce = 2;//y-axis speed change
int bspeed = 2;//x-axis speed change
int bbounce = 2;//y-axis speed change
int tspeed = -2;//x-axis speed change
int tbounce = -2;//y-axis speed change
int qspeed = -3;//x-axis speed change
int qbounce = -3;//y-axis speed change
int rx = 100;//ball x
int ry = 500;//ball y
int rw = 100;//ball width
int rh = 100;//ball height
int w1 = 100;//width of small square
int h1 = 100;//height of small square
//int w2 = 300;//width of small square
//int h2 = 300;//height of small square
int tx1 = 200;//traingle x1
int ty1 = 200;//triangle y1
int tx2 = 320;//triangle x2
int ty2 = 100;//triangle y2
int tx3 = 350;//triangle x3
int ty3 = 300;//triangle y3
int qx1 = 200;//quad x1
int qy1 = 231;//quad y1
int qx2 = 320;//quad x2
int qy2 = 210;//quad y2
int qx3 = 363;//quad x3
int qy3 = 350;//quad y3
int qx4 = 210;//quad x4
int qy4 = 356;//quad y4

float color1 = random(50);//random float color
boolean button = false;

void setup() {
size(600, 600);//screen size
}

void draw() {
if (!button) {
background(0);
state = 0;
}
else if (mousePressed) {//background change on mousepress isn’t working completely had issues with button and mousePress
background(0, 255, 0);
state = 1;
}
else if (state == 1) {

state = 2;
}
else if (state == 2) {
background(0, 0, 255);
}
else if (button) {
state = 3;
}
else if (state == 3) {
background(155, 255, 0);
}
else if (!button) {
state = 4;
}
else if (state == 4) {
background(138, 0, 255);
}
else if (button) {
state = 0;
}

if ((button) && (mouseX > x && mouseX y && mouseY width && mouseX height && mouseY width * .84) {//keeps square from exceeding width
speed = speed * -1;//if the square touches the right boundary it changes direction
}
else if (x height *.84) {//keeps square from touches height
bounce = bounce * -1;//if the square touches the top boundary it changes direction
}
else if (y width * .92) {
bspeed = bspeed * -1;//if the ball touches the right boundary it changes direction
}
else if (rx height *.92) {
bbounce = bbounce * -1;//if the ball touches the top boundary it changes direction
}
else if (ry width) {
tspeed = tspeed * -1;//if the triangle touches the right boundary it changes direction
}
else if (tx1 height) {
tbounce = tbounce * -1;//if the striangle touches the top boundary it changes direction
}
else if (ty2 width) {
qspeed = qspeed * -1;//if the quad touches the right boundary it changes direction
}
else if (qx1 height) {
qbounce = qbounce * -1;//if the quad touches the top boundary it changes direction
}
else if (qy2 < 0) {
qbounce = qbounce * -1;//if the quad touches the bottom boundary it changes direction
}
}

void mousePressed() {

button = !button;//changes button state to false
}

Posted in Uncategorized | Leave a comment

Erick Asadobay H.W 4.1

int cx=10;
int cy=10;
int cw=100;
int ch=100;
int x=150;
int y=150;
int x1=150;
int y1=150;
int w=100;
int h=100;
int w1=100;
int h1=100;
int speed=2;
int state=0;
boolean rec=false;
boolean rac=false;
boolean sun=false;

void setup() {
size(400, 400);
}
void draw() {
if (state == 0) {
background(255);
}
else if (state == 1) {
background(255, 0, 0);
}
else if (state == 2) {
background(0, 255, 0);
}
else if (state == 3) {
background(0, 0, 255);
}
ellipseMode(CORNER);
if (!mousePressed) {
fill(255, 189, 34);
rect(x, y, w, h);
}
else {
fill(0);
ellipse(x, y, w, h);
}
if (rec) {
y=y;
}
else {
y=y + speed;
}

if (y > 300 || y < 0) {
speed = speed * -1;
}
if (mouseX > x && mouseX< x+w && mouseY > y && mouseY < y+h && mousePressed) {
rec=!rec;
}

fill(255, 90, 45, 200);
rect(x1, y1, w1, h1);

if (rac) {
x1=x1;
}
else {
x1=x1 + speed;
}
if (x > 300 || x < 0) {
speed=speed * -1;
}
if (sun) {
fill(255, 255, 0);
ellipse(cx, cy, cw, ch);
}
else {
fill(0);
ellipse(cx, cy, cw, cw);
}
if (mouseX > cx && mouseX < cx+cw && mouseY > cy && mouseY < cy+ch && mousePressed) {
sun=!sun;
}
}

void mousePressed() {
state++;
if (state > 3) {
state=0;
}
}

Posted in Uncategorized | Leave a comment

Matthew Soto 2/20/13 Hw 4.2

int x= 1;
int speed= 1;
float y= 200;
float w= 100;
float h= 100;
int state=0;
boolean button= false;

void setup(){
size(800, 800);
}

void draw(){
background(0);
if (button){
x=x;
}
else{
x= x+speed;
}
fill(255);
rect(x, 200, 100, 100);
if(mousePressed){
background(252, 0, 0);
fill(8, 34, 255);
rect(x, 400, 100, 100);
ellipse(x, 90, 100, 100);

button=!button;
}else {
background(0);
fill(255);
rect(x, 90, 100, 100);
}

if(x>width){
speed=speed* -1;
fill(255);
rect(x, 200, 100, 100);
}
else if (x<0){
speed=speed* -1;
}
rect(x, y, w, h);
if (state==0){

}
if (button){
x=x;
}else{
fill(3,29,255);
}
if(mouseX<mouseY&&mousePressed){
button= button;
}
fill(255);
rect(x, 400, 100, 100);
if(state==0){;
x=x+speed;
}
if (x>width-10){
x= width-10;
state=1;
}
else if (state==1){
y=y+speed;
}
if (y>height-10){
y=height-10;
state=2;
}
else if (state==2){
x=x-speed;
if(x< 0){
x=0;
state = 3;
}
}else if (state==3){
y= y-speed;
if(y<0){
y=0;
state=0;
}
}
fill(255);
rect(x, 90, 100, 100);

fill(255);
rect(x, 600, 100, 100);

}
void mousePressed(){
if(mouseX>x&&mouseX<x+w&&mouseY>y&&mouseY<y+h){
println(“click”);
button=!button;

}
}

Posted in Uncategorized | Leave a comment

homework week 4.2

int x=100;
int speed=5;
boolean freeze=false;
int y=100;
int w=50;
int h=50;
int t=100;
int p=50;
int r, g, b;

 
void setup() {
size(400, 400);
}
void draw () {
background(255);
if (freeze) {
x = x;
}
else {
x = x- speed;
t=t+speed;
r=r+speed;
}

line(width/2, 0, width/2, height);
line(0, height/2, width, height/2);

fill(255, 0, 0);

rect(p, 250, w, h);

fill(0, 255, 0);

ellipse(t, y, h, w);//new shape thats moving opposite
fill(0, 0, 255);
ellipse(x, y, h, w);
if (x>width) {
speed=speed*-1;
}

else if (x < 0) {
speed=speed*-1;
}
if (t >width) {
speed=speed*-1;
}
else if (t<0) {
speed=speed*-1;
}

if (mouseX> width/2 && mouseY < height/2) {
r++;
}
else {
r–;
}

if (mouseX < width/2 && mouseY < height/2) {
g++;
}
else {
g–;
}
if (mouseX < width/2 && mouseY > height/2) {
b++;
}
else {
b–;
}
{
r = constrain(r, 0, 255);
g = constrain(g, 0, 255);
b = constrain(b, 0, 255);
}
}

void mousePressed() {
if (mouseX>x &&mouseX <x+w &&mouseY >y && mouseY<y+h) {
freeze = !freeze;
}

}

 

 

~~~~side note i no i missed a few things..could u emailed me on how  to those missing items work ?tried many things with the void mousepressed + i used the prev homework as a guide for the background still not sured why it wasnt making the magic effects o.o~~~

 

 

found an error that didnt get called in my prog

new code is

int x=100;
int speed=5;
boolean freeze=false;
int y=100;
int w=50;
int h=50;
int t=100;
int p=50;
int r, g, b;

void setup() {
size(400, 400);
}
void draw () {
background(255);
if (freeze) {
x = x;
}
else {
x = x- speed;
t=t+speed;
r=r+speed;
}

line(width/2, 0, width/2, height);
line(0, height/2, width, height/2);

fill(255, 0, 0);

rect(p, 250, w, h);

fill(0, 255, 0);

ellipse(t, y, h, w);//new shape thats moving opposite
fill(0, 0, 255);
ellipse(x, y, h, w);
if (x>width) {
speed=speed*-1;
}

else if (x < 0) {
speed=speed*-1;
}
if (t >width) {
speed=speed*-1;
}
else if (t<0) {
speed=speed*-1;
}

}

void mousePressed() {
if (mouseX>x &&mouseX <x+w &&mouseY >y && mouseY<y+h) {
freeze = !freeze;
}

}

 

Posted in Uncategorized | Leave a comment

Homework 3.2 2/19/13

int x = 200;
int speed = 6;

void setup() {
size (600, 600);
}

void draw() {
background(0);
ellipse(x, 100, 100, 50);
noStroke();
fill(255, 225, 0);
ellipse(x, x, 200, 100);
speed = speed* 1;

fill (225,0,0);
random(225);

if (x > width) {
speed = speed * -1;
}

else if (x < 5) {
speed = speed * -1;
}

x = x+speed;
}

void mousePressed(){
fill(0,225,225);
ellipse(x, x, 100, 100);
}

Posted in Uncategorized | Leave a comment