JSFiddle - React, Tailwind, and code Playground
by demso
HTML
<script src="processing.js"></script>
<script type="text/processing" data-processing-target="mycanvas">
ArrayList listRand;
int newRand;
int counter;
int moduleSize = 15;
// paddle
int slider=2;
int limiterL = 1;
int vTemp;
int limiterR=moduleSize;
//button
int buttonX=25, buttonY=325;
int buttonSize = 50;
boolean boolButton = false;
boolean flag;
int count;
Module[] mods;
void setup() {
size(500, 400);
mods = new Module[moduleSize];
listRand = new ArrayList(moduleSize);
mods[0] = new Module(1*30, randFoo()*10 );
mods[1] = new Module(2*30, randFoo()*10 );
mods[2] = new Module(3*30, randFoo()*10 );
mods[3] = new Module(4*30, randFoo()*10 );
mods[4] = new Module(5*30, randFoo()*10 );
mods[5] = new Module(6*30, randFoo()*10 );
mods[6] = new Module(7*30, randFoo()*10 );
mods[7] = new Module(8*30, randFoo()*10 );
mods[8] = new Module(9*30, randFoo()*10 );
mods[9] = new Module(10*30, randFoo()*10 );
mods[10] = new Module(11*30, randFoo()*10 );
mods[11] = new Module(12*30, randFoo()*10 );
mods[12] = new Module(13*30, randFoo()*10 );
mods[13] = new Module(14*30, randFoo()*10 );
mods[14] = new Module(15*30, randFoo()*10 );
}
void draw() {
background(50);
buttonUpdate();
for (Module mod : mods) { mod.display(); }
// paddle
rect (slider*30, 85, 20, 5);
rect (limiterL*30, 75, 20, 5);
rect (limiterR*30, 65, 20, 5);
textSize(25);
text(counter,300,350);
// draw button
fill(150);
rect(buttonX,buttonY,buttonSize,buttonSize);
if(boolButton && mousePressed)
{
fill(200);
rect(buttonX,buttonY,buttonSize,buttonSize);
}
}
class Module {
int xOffset;
int rectHight;
// Contructor
Module(int xOffsetTemp, int rectHightTemp) {
xOffset = xOffsetTemp;
rectHight=rectHightTemp;
}
// Custom method for drawing the object
void display() {
fill(255);
rect(xOffset , 100, 20, rectHight);
}
}
// кнопка
// нажатие
void mousePressed() {
if(boolButton)
{...