We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey so i am trying to make this code have rain and the rain works and its different sizes like i want but i want to be able to click and it turns on/off but i keep getting Unexpected token: void please help also any modifications to make the code simpler are appreciated also. Code below.
` Rain s1,s2,s3,s4; int z = 0; int w = 0; float a = .5; ArrayList rainfall = new ArrayList(); PImage pic; int mouse;
void setup() { background(0); mouse=1; pic= loadImage("Picture.jpg"); size(1200,800); for (int i = 0; i < 10; i++) { rainfall.add(new Rain()); rainfall.add(new Rain()); rainfall.add(new Rain()); rainfall.add(new Rain()); } }
void draw() { background(0); image(pic, 0, 0); pic.resize(1200,800);
if (mouse==1){
if (random(1) < a) { rainfall.add(new Rain()); rainfall.add(new Rain()); } for (int i = 10; i < rainfall.size(); i++) { Rain r = rainfall.get(i); r.drawRain(); } }
class Rain { float xpos; int ypos; float xvel; float yvel; float size;
Rain() { xpos = random(width); ypos = 0; yvel = 0.05; xvel= 0; size = random(5,20); }
void drawRain() { noStroke(); if (ypos> 750) { z=1; } else { fill(31,153,216,100); ellipse(xpos,ypos,size,size); if(w != 0) { ypos = int( ypos + yvel ); } else { ypos = int( ypos + yvel ); yvel = yvel +.1; } } } } void mouseClicked(){ if (mouse == 1){ mouse = 0;} else{mouse = 1; } }
`
Answers
Please edit your post, select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code.
Kf
Ctrl-t in the editor will try and indent your code and show any missing brackets, which I think it's your problem. Do you close draw? Can't tell without you formatting...