sorry but you didnt understand me, look :
i have a room which i build
i have area 150 meters squared : 6 and get 25 (25 computers in room)
in this room i must draw 25 not more ( may be <)
with your code i cant draw PC
"you want to draw the PCs with the mouse and automatically stop after 25 PCs? " i learn processing a little ( few mounth) Yes i need to do it, with a mouse
when I have a bigger program as yours, I take time to write it in a way that is easy to read (and to maintain)
one point is to use functions (and don't have all in draw())
one point is to use tabs (and don't have everything in one tab)
one point is to have states: With a state I exactly know in a game e.g. where I am: do I show the start screen, do I play, do I show the high score?
do you use states? Because you could be in a state drawPCs and then he counts how many times you clicked... displays this number... when you have 25, he leaves the state...
if(button1[i])
{
float sum;
int count=0;
sum=currArea/6;
println(sum);
println(count);
if(sum==0)
{
if (mouseY > 120)
{
strokeWeight(4);
rect(mouseX-18,mouseY-14,36,28);
image(img1, mouseX-18,mouseY-14,36,28);
}
fill(0,255,0);
}
if ( sum > count)
{
count=count+1;
if (mouseY > 120)
{
strokeWeight(4);
rect(mouseX-18,mouseY-14,36,28);
image(img1, mouseX-18,mouseY-14,36,28);
}
}
}
else
{
noFill();
}
strokeWeight(3);
rect(330,26,56,48);
i still cant fix this part of code, when i draw rect i want to do this " count=count+1;" but it dont work, i want add +1 every time when i draw rect, can you check my code?
Other than I wrote in one of my e-mails, you cannot totally put the mouse stuff into mousePressed (since you're drawing with the mouse directly in some modes). You can put them into clear separate functions though.
look what i get a few indexs i want build a room timers[1]=20 timers[2]=50 and rect();
rect(mouseX,mouseY,timers[1],timers[2]); datas from timers its length of wall
i understood that i want write timers[1] (with idex 1) and timers[2]( with index 2 ) in othen value because when i use
rect(mouseX,mouseY,timers[1],timers[2]);
i got this error
Answers
yes, understood
maybe the for-loop gets called more often than 1 time?
you can say
every time when i build room ill use loop, but i dont understand where should i use your code???
maybe that why you get too many PCs when the for- loop gets called too often
so before setup say boolean allPCsAreDrawn = false;
then comes the if-clause I just said, it is around the for-loop
inside the if is the for loop and we set the var to true
it's our marker to assure the for-loop is run only once
just a small yes/no switch
i dont understand you, can you fix my code
here...
this makes it so that the PCs are drawn only once
because of allPCsAreDrawn the sketch knows whether they are already drawn or not
sorry but you didnt understand me, look : i have a room which i build i have area 150 meters squared : 6 and get 25 (25 computers in room) in this room i must draw 25 not more ( may be <) with your code i cant draw PC
you want to draw the PCs with the mouse and automatically stop after 25 PCs?
Man, you are building a cathedral and you don't even know how to build a simple wall, right?
I mean when you draw the PCs with the mouse one by one, just stop drawing PCs when you have 25
you don't need a for-loop then.
"you want to draw the PCs with the mouse and automatically stop after 25 PCs? " i learn processing a little ( few mounth) Yes i need to do it, with a mouse
what did i do wrong? about wall i build walls with a lines
the cathedral and wall thing was a metaphor
I think your program is very big (like a cathedral) and you lack some basic knowledge (no offense).
did you follow my advice to put arrays in?
for the PCs thing
you made a small nice bar with the buttons, and one of them is to place the PCs in the room, right?
when you click it:
while in this mode you place PCs with the mouse
your code must come without the for-loop
float sum; sum = currArea/6; println(sum);
}
the general architecture of your program
when I have a bigger program as yours, I take time to write it in a way that is easy to read (and to maintain)
one point is to use functions (and don't have all in draw())
one point is to use tabs (and don't have everything in one tab)
one point is to have states: With a state I exactly know in a game e.g. where I am: do I show the start screen, do I play, do I show the high score?
do you use states? Because you could be in a state drawPCs and then he counts how many times you clicked... displays this number... when you have 25, he leaves the state...
;-)
i still cant fix this part of code, when i draw rect i want to do this " count=count+1;" but it dont work, i want add +1 every time when i draw rect, can you check my code?
you really should use ctrl-t in your processing
i thought that i had been pressed ctr-t, anyway what do you think about code, why it dont work?When i draw rect i want to add +1 to "count"
why
if ( sum > count) { count=count+1;
I don't understand
why not count=count+1;
after line 14 ?
I told you how I would do it: With states, see old post...
i can do nothing (( i dont understand how to do it
just for anyone interested:
this went on via PM and e-mail
Other than I wrote in one of my e-mails, you cannot totally put the mouse stuff into mousePressed (since you're drawing with the mouse directly in some modes). You can put them into clear separate functions though.
;-)
did you ask about a code for a timer?
this is a simple timer (it's like a stop watch: hit 1 to start it, hit 2 to stop it. It shows the millis passed)
you need an array of Timer:
Timer[] timers = new Timer [1000];
and then use it
timers[indexTimer].xxxxxxxx
here
what is index? you mean first will be Timer[0] then will be Timer[1] then Timer[2]??
yes, it's a list of timers and index is which one you have currently
look what i get a few indexs i want build a room timers[1]=20 timers[2]=50 and rect(); rect(mouseX,mouseY,timers[1],timers[2]); datas from timers its length of wall
??
My sketch gives the time in millis between you press 1 and 2.
Nothing to do with what you plan...?
i understood that i want write timers[1] (with idex 1) and timers[2]( with index 2 ) in othen value because when i use
rect(mouseX,mouseY,timers[1],timers[2]);
i got this errorMake
int zet.....
i use int in this case error same but "to int" in the end
Why 5 ??
This timer is empty....
i can compilate code because of this error
my bad...