Skip to content

Instantly share code, notes, and snippets.

@kuzemkon
Created November 9, 2014 21:41
Show Gist options
  • Save kuzemkon/eb359e6cfe94fc21dd1f to your computer and use it in GitHub Desktop.
Save kuzemkon/eb359e6cfe94fc21dd1f to your computer and use it in GitHub Desktop.
int keyP[]=new int[8],keyR[]=new int[8];
void keyPressed()
{
if(keyCode==SHIFT)keyP[0]++;
if(keyCode==CONTROL)keyP[1]++;
if(keyCode==ENTER)keyP[2]++;
if(keyCode=='A')keyP[3]++;
if(keyCode=='S')keyP[4]++;
if(keyCode=='D')keyP[5]++;
if(keyCode=='F')keyP[6]++;
if(keyCode=='G')keyP[7]++;
redraw();
}
void keyReleased()
{
if(keyCode==SHIFT)keyR[0]++;
if(keyCode==CONTROL)keyR[1]++;
if(keyCode==ENTER)keyR[2]++;
if(keyCode=='A')keyR[3]++;
if(keyCode=='S')keyR[4]++;
if(keyCode=='D')keyR[5]++;
if(keyCode=='F')keyR[6]++;
if(keyCode=='G')keyR[7]++;
if(keyCode==BACKSPACE)for(int i=0;i<8;i++) keyP[i]=keyR[i]=0;
redraw();
}
PFont font;
void setup()
{
size(640,200);
noStroke();
noLoop();
font=createFont("Consolas",14);
textFont(font);
frameRate(10);
}
int i;
void draw()
{
textAlign(RIGHT,CENTER);
background(25);
fill(0,225,225);
text("Shift:",90,22);
text("CONTROL:",90,42);
text("ENTER:",90,62);
text("A:",90,82);
text("S:",90,102);
text("D:",90,122);
text("F:",90,142);
text("G:",90,162);
fill(0,120,255);
text("Press Backspase key for clear",width-40,182);
for(int i=0;i<8;i++)
{fill(0,228,0);
for(int j=0;j<keyP[i];j++) rect(100+j*10,20+i*20,8,3);
fill(0,14,88);
for(int j=0;j<keyR[i];j++) rect(100+j*10,25+i*20,8,3);
}
fill(255);
textAlign(CENTER,CENTER);
text("Практична робота Куземка Юрія",320,5);
fill(14,88,228);
text(i,40,120);
if (keyPressed) {
if (keyCode == ENTER){
i++;
}}
if (keyPressed) {
if (key == 'a' || key == 'A') {
i++;
}}
if (keyPressed) {
if (key == 's' || key == 'S') {
i++;
}}
if (keyPressed) {
if (key == 'd' || key == 'D') {
i=i+1;
}}
if (keyPressed) {
if (key == 'f' || key == 'F') {
i++;
}}
if (keyPressed) {
if (key == 'g' || key == 'G') {
i++;
}}
if (keyPressed) {
if (keyCode == SHIFT) {
i++;
}}
if (keyPressed) {
if (keyCode == CONTROL) {
i++;
}}
if(keyPressed== false) {
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment