Skip to content

Instantly share code, notes, and snippets.

@RouNNdeL
Last active January 14, 2020 23:20
Show Gist options
  • Save RouNNdeL/5993e5ab37fa2eecc4585725ec126972 to your computer and use it in GitHub Desktop.
Save RouNNdeL/5993e5ab37fa2eecc4585725ec126972 to your computer and use it in GitHub Desktop.
One of my first programs (2013)
var pr = 365;
var sy = 200;
var sx = 120;
var a1 = 0;
var a = 0;
var ap = a;
var b1 = 0;
var b = 0;
var bp = b;
var c = 0;
var wait = 0;
var wy = 0;
var li = 0;
var zw = 0;
var guzik = function(x,y,n,s){
fill(255, 0, 0);
strokeWeight(2);
rect(x,y,s,s);
textSize(s);
fill(0, 0, 255);
text(n,x+8,y+29);
if(wait%4===0){
if(mouseX>x&&mouseY>y&&mouseX<x+s&&mouseY<y+s&&mouseIsPressed){
if(li===0){
a = a*10+n;
}
else{
b = b*10+n;
}
wy = 0;
}
}
};
var reset = function(x,y,r,s){
fill(255, 0, 0);
strokeWeight(2);
rect(x,y,s,s);
textSize(s);
fill(0, 0, 255);
text(r,x+4,y+30);
if(wait%4===0){
if(mouseX>x&&mouseY>y&&mouseX<x+s&&mouseY<y+s&&mouseIsPressed){
a = 0;
b = 0;
c = 0;
pr = 365;
a1 = a;
wy = 0;
li = 0;
zw=0;
}
}
};
var znak = function(x,y,z,s){
fill(255, 0, 0);
strokeWeight(2);
rect(x,y,s,s);
fill(0, 0, 255);
text(z,x+9,y+29);
if(wait%4===0){
if(mouseX>x&&mouseY>y&&mouseX<x+s&&mouseY<y+s&&mouseIsPressed){
if(li===1){
c=a;
pr=365;
}
if(z==="="){
wy = 1;
if(zw==="+"){
c=a+b;
}
if(zw==="-"){
c=a-b;
}
if(zw==="*"){
c=a*b;
}
if(zw==="/"){
c=a/b;
}
}
else{
li = 1;
pr=365;
zw=z;
}
}
}
};
var draw = function() {
background(0, 0, 0);
wait = wait+1;
fill(255, 0, 0);
rect(25,20,350,120);
fill(0, 0, 255);
textSize(40);
if(b>1000000000){
b = bp;
}
else{
bp = b;
}
if(b>b1){
if(b<=1000000000){
pr = pr-22;
b1 = b;
}
}
if(a>1000000000){
a = ap;
}
else{
ap = a;
}
if(a>a1){
if(a<=1000000000){
pr = pr-22;
a1 = a;
}
}
if(li===0){
if(a>0){
text(a,pr,55);
}
}
else{
if(b>0){
text(b,pr,55);
}
}
if(wy===1){
text(c,32,133);
}
guzik(sx,sy+80,1,35);
guzik(sx+40,sy+80,2,35);
guzik(sx+80,sy+80,3,35);
guzik(sx,sy+40,4,35);
guzik(sx+40,sy+40,5,35);
guzik(sx+80,sy+40,6,35);
guzik(sx,sy,7,35);
guzik(sx+40,sy,8,35);
guzik(sx+80,sy,9,35);
guzik(sx+40,sy+120,0,35);
//println(a+" "+b);
znak(sx+120,sy,"+",35);
znak(sx+120,sy+40,"-",35);
znak(sx+120,sy+80,"=",35);
znak(sx+160,sy,"*",35);
znak(sx+160,sy+40,"/",35);
reset(sx+160,sy+80,"C",35);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment