Loading...
Copy code
Close
Permalink
Close
Please tell us why you want to mark the subject as inappropriate.
(Maximum 200 characters)
Report Inappropriate
Cancel
Private Message
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Cancel
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Update
Cancel
Feedback
Email ID
Subject :
Comments :
Send
Cancel
Private Message
Type the characters you see in the picture below.
Type the characters you see in the picture below.
Attach files
Desktop
Zoho Docs
Google Docs
Each Attachment size should not exceed 1MB.
Max no of attachments : 0
Loading User Profile...
guest
Response title
This is preview!
Attachments
Publish
Back to edit
Cancel
(
)
Sign In
You can also use the below options to login
Login with Facebook
Login with Google
Login with Yahoo
New to this Portal?
Click on Join Now to Sign Up
Join Now
Help
Feedback
Sign In
Processing Forum
Recent Topics
All Forums
Search All
Tags
Author
Advanced Search
Search
New Topic
Screen name:
ofirofir85
ofirofir85's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
handling the mousePressed and some other things...
[3Replies]
28-Jul-2012 05:13 AM
Forum:
Programming Questions
Hi:)
this is my code:
**Edit - I tried to change to color of the block in the display function , and it stays black... I cant find the problem ..
Block[][] grid;
int cols = 16;
int rows =10;
void setup()
{
size(800,500);
grid = new Block[cols][rows];
for(int x = 0;x<cols;x++)
{
for(int y = 0;y<rows;y++)
{
grid[x][y] = new Block(x*50,y*50,50,50);
}
}
}
void draw()
{
for(int x = 0;x<cols;x++)
{
for(int y = 0 ;y<rows;y++)
{
grid[x][y].display();
}
}
}
class Block
{
int x,y,w,h,xEnd,yEnd;
boolean clicked;
Block(int xx,int yy,int ww,int hh)
{
clicked = false;
x = xx;
y = yy;
w = ww;
h =hh;
xEnd = x+50;
yEnd = y+50;
}
void display()
{
if(clicked = false)
{
fill(color(255));
rect(x,y,w,h);
}
else if(clicked = true)
{
fill(color(0));
rect(x,y,w,h);
}
}
void changeColor()
{
if(clicked = false)
{
clicked = true;
}
else if(clicked = true)
{
clicked = false;
}
}
}
void mouseClicked()
{
moveToBlock(mouseX,mouseY);
}
void moveToBlock(int mX,int mY)
{
for(int x = 0;x<cols;x++)
{
for(int y = 0 ;y<rows;y++)
{
if(mX > grid[x][y].x && mX < grid[x][y].xEnd)
{
if(mY > grid[x][y].y && mY<grid[x][y].yEnd)
{
grid[x][y].changeColor();
}
}
}
}
}
My problem is that the block is not changing the color...
please help me
(Sorry for my English ...)
«Prev
Next »
Moderate user : ofirofir85
Forum