Graff
10-27-2012, 05:11 PM
I signed up for a Java class and to be honest I've gotten lost already. Here is the assignment; I do NOT want you to simply do it because I know it would take a real programmer all of two seconds to do. I want you to help EXPLAIN this assignment to me and help me understand so I can be prepared for future assignments and tests. I assume you already have a program to run whatever, but if not here is a link to the one we are using. It's free. [Only registered and activated users can see links]
Now, here is the assignment. I have to make three colored buttons. Each button is a switch that turns the background to a different color. Here is a picture of what pressing some buttons looks like:
[Only registered and activated users can see links]
I've written code to make the shapes and colors right but I need help setting up variables and whatnot. Most likely what I have written is totally wrong in terms of what the finished program should look like, but visually it looks right (size/colors of squares; have not yet made the borders bold.)
This project is due tuesday but I would really like to get some understanding of it today. I have some "hints" given too that I can write up if it will help. Thanks!
boolean MouseInRed;
boolean MouseInGreen;
boolean MouseInBlue;
boolean on = false;
void setup(){
size(500,500);
}
void draw() {
rectMode(CENTER);
fill(0,255,0);
rect(height/2, width/2,100,100);
//rectMode(CENTER);
fill(0,0,255);
rect(height/2+150,width/2,100,100);
//rectMode(CENTER);
fill(255,0,0);
rect(height/2-150,width/2,100,100);
if (MouseInRed){
background(255);
}}
Now, here is the assignment. I have to make three colored buttons. Each button is a switch that turns the background to a different color. Here is a picture of what pressing some buttons looks like:
[Only registered and activated users can see links]
I've written code to make the shapes and colors right but I need help setting up variables and whatnot. Most likely what I have written is totally wrong in terms of what the finished program should look like, but visually it looks right (size/colors of squares; have not yet made the borders bold.)
This project is due tuesday but I would really like to get some understanding of it today. I have some "hints" given too that I can write up if it will help. Thanks!
boolean MouseInRed;
boolean MouseInGreen;
boolean MouseInBlue;
boolean on = false;
void setup(){
size(500,500);
}
void draw() {
rectMode(CENTER);
fill(0,255,0);
rect(height/2, width/2,100,100);
//rectMode(CENTER);
fill(0,0,255);
rect(height/2+150,width/2,100,100);
//rectMode(CENTER);
fill(255,0,0);
rect(height/2-150,width/2,100,100);
if (MouseInRed){
background(255);
}}