We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey there,
I'm making this minigame (short desc):
Screen is filled with a grid of circles, the circle's radius gradually grows smaller, goal is to click the circles before they disappear. (this is currently where i'm struggling). In the end there should be multiple colors of circles - colors to click, colors not to click. Spawn speed of circles should increase over time. Score bonus when over 10-correct combo clicks.
My current is: I can't seem to draw a grid of circles and get dist(); values for each individual circle. (to check if cursor is over circle when clicked). I searched all over the interwebs for similar games/code but haven't been able to find.
Would be great if someone could assist me with this.
:) thanks
Answers
show your code
for dist : for-loop over all circles in your array and say
if (dist(circlesX[i],circlesY[i],mouseX,mouseY) < circlesRadius[i]) {
this depends from how you store your data, which you didn't tell
but the principle is the same
are you into oop yet?
but dist() should do it - please see reference
;-)
can you draw a grid of circles?
To be fair. I'm only into processing since a week or 6. I'm probably going at it all wrong. hehe
Can you show me how to create that circle-grid with an array?
what happens when you run your code?
maybe this is a different language than processing / java?
because var and function don't exist here
this is a new version that makes it 20 circles and not endless many...
when you really try to work in processing (and not another language), please take a look at the first five tutorials and at the examples and in the reference.
processing is very good documented, so it puzzles me that you come up with a code that doesn't run.
in the new version I inserted teller = 0 in draw.
;-)
you wrote:
yes... and when clicked, the cirlce is off, right?
to do so you need a method to store which circle is on and which is off...
have you done arrays or oop?
I recommend to have multiple parallel arrays to store the position of each circle, its color and whether it's still ON.
OK?
Best, Chrisir ;-)
your radius isn't radius, it's diameter by the way
don't accept answers when your question is not solved. btw
to do the dist thing: in function void mousePressed() for-loop over your circles, calculate their positions and then do the dist check (see above) --- but then you need to put the value (on/off) in an array and use it when displaying the circle (using if).
do come back when you need more help...
could you give an example how to create an array like you described above?
@ilikepancakes, you're better off going w/ OOP way rather than lotsa messy arrays! :P
Class syntax is much easier in Java. But JS' prototypical "classes" aren't that diff. either! 8-X
Take a look at "Anthills" sketch @ this forum thread below:
http://forum.processing.org/two/discussion/8380/issues-with-my-anthill-program#Item_11
You can also watch it running online via PJS framework (JS Mode) below:
http://studio.processingtogether.com/sp/pad/export/ro.91A3Jfnrsldhp/latest
I am sorry, I didn't realize it's js - my bad....
I suggested messy arrays assuming you were not into oop yet....
@Chrisir, I dunno whether he knows OOP or not. I've just suggested him so!
And as a side note, keyword
var
is more than a proper hint it's much probably JS! In this case P5.JS! ;)thanks.... @-)
I don't know the syntax in JS but normally it's
boolean[] circleIsOff = new boolean [21];
then when a circle is clicked say circleIsOff[i] = true;
when displaying the cirlces say
if (!circleIsOff[i]) {
.....
so only the non-clicked circles are showing
;-)
Java to JS "automatic" human translation: :D
boolean[] circleIsOff = new boolean [21];
--->const circleIsOff = Array(21);