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 = 10;
//int floatingStoper = moduleSize;
// paddle
int incPaddle=1;
int vTemp;
//button
int buttonX=25, buttonY=325;
int buttonSize = 50;
boolean boolButton = false;
int count;
Module[] mods;
void setup() {
size(400, 400);
listRand = new ArrayList(10);
mods = new Module[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 );
}
void draw() {
background(50);
buttonUpdate();
for (Module mod : mods) { mod.display(); }
// paddle
rect (incPaddle*30, 85, 20, 5);
// rect (floatingStoper*30, 75, 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)
{
counter++;
if(mods[incPaddle].rectHight < mods[incPaddle-1].rectHight)
{
vTemp= mods[incPaddle-1].rectHight;
mods[incPaddle-1].rectHight=mods[incPaddle].rectHight;
mods[incPaddle].rectHight=vTemp;
}
}
}
//отжатие
void mouseReleased() {
...