I am trying to make a LoZ game in Processing. However, anytime I try moving left (using the button 'a'), the character doesnt stop moving with out another input. Its very annoying and no one i know can see the problem. Can someone take a look and help me out? Here is code. No other key has a problem. i even changed the walk left key to other keys then 'a' but it doesnt work.
`import processing.sound.*; SoundFile bitmusic; PImage walkRight; PImage walkDown; PImage attack; PImage walkLeft; PImage walkUp; int counter; int x = 0; int y = 0; int dx = 0; int dy = 0; boolean isWalkingRight = false; boolean isWalkingDown = false; boolean isAttacking = false; boolean isWalkingLeft = false; boolean isWalkingUp = false; void setup() { frameRate(30);
bitmusic = new SoundFile(this, "windfish.mp3");
bitmusic.play(); loop(); walkRight = loadImage("linkwalking.gif"); walkDown = loadImage("fowardwalking.gif"); walkLeft = loadImage("walkleft.png"); attack = loadImage("attack.png"); walkUp = loadImage("walkback.png"); size(2000,1000); noStroke(); } void draw()
{ background(150,260,0); dx = 0; dy = 0; pushMatrix(); if(keyPressed) { if (key == 'd') { dx = dx+8; if(!isWalkingRight) { image(walkRight,x,y); isWalkingRight = true; } } if (key == 'w') { dy = dy-8; if(!isWalkingUp) {image(walkUp,x,y); isWalkingUp = true; } } if (key == 's') { dy = dy+8; if(!isWalkingDown) { image(walkDown,x,y); isWalkingDown = true;
}
}
} if (key == 'a') { dx = dx -8; if(!isWalkingLeft) { image(walkLeft,x,y); isWalkingLeft = true; } } if (key == 'o') { dy = dy-0; if (!isAttacking) { image(attack,x,y); isAttacking = true; } } isWalkingUp = false; x = x+dx; y = y+dy; isAttacking = false; x = x+dx; y = y+dy; isWalkingRight = false; x = x+dx; y = y+dy; isWalkingLeft = false; x = x+dx; y = y+dy; isWalkingDown = false; x = x+dx; y = y+dy;
if(!keyPressed) {
translate (x,y); {
fill(#C16915); rect(90,130,30,20); rect(110,120,10,10); rect(10,70,60,60); rect(80,110,20,10); rect(90,100,30,10); rect(80,90,20,10); rect(70,80,10,10); rect(50,10,60,20); rect(40,20,10,10); rect(120,90,10,10); fill(#E0AE7F); rect(20,130,50,10); rect(70,90,10,40); rect(30,80,10,40); rect(20,90,30,10); rect(30,50,100,10); rect(20,30,120,20); rect(50,60,60,10); rect(70,70,30,10); rect(20,10,10,20); rect(130,10,10,20); rect(20,50,10,10); rect(130,70,40,30); /dark blue sword)/ fill(#10C41D); rect(80,120,30,10); rect(100,110,30,10); rect(120,100,10,10); rect(80,100,10,10); rect(80,80,50,10); rect(100,90,20,10); rect(100,70,30,10); rect(110,60,10,10); rect(40,-10,80,20); rect(40,10,10,10); rect(110,10,10,10); rect(60,30,10,10); rect(90,30,10,10); rect(30,20,20,20); rect(10,60,10,10); rect(20,50,20,10); rect(20,60,10,10); rect(30,60,10,10); rect(50,-20,60,10); fill(#C16915); rect(40,20,10,30); rect(110,20,10,30); rect(90,40,10,10); rect(60,40,10,10); rect(70,60,20,10); rect(120,60,20,10); rect(130,50,10,10); fill(#E0AE7F); rect(30,50,10,10); } } popMatrix(); }`