Hey guys!
I have a little problem.
I’m making a game for classes. It’s similar to Space Invaders.
So when i’m press <- (to left) and -> (to right), sometimes it takes to move.
Does anyone have a solution?
My code for move:
void movNave(){
//Movimiento de la nave
if(keyPressed){
if(!bullet){
if(keyCode == 38){
if(!bullet){
bulletIndepe=pos[0]+40;
bullet = true;
numdisparos++;
println(numdisparos);
}
}
}
if (keyCode == 39 && (pos[0]<=1080)){ //derecha
if(tipoNave==1){
image(navev1D, pos[0], pos[1]);
}else if(tipoNave==2){
image(navev2D, pos[0], pos[1]);
}else{
image(navev3D, pos[0], pos[1]);
}
pos[0] = pos[0]+indmov;
}else if(keyCode == 37 && (pos[0]>=500)){ //izquierda
if(tipoNave==1){
image(navev1I, pos[0], pos[1]);
}else if(tipoNave==2){
image(navev2I, pos[0], pos[1]);
}else{
image(navev3I, pos[0], pos[1]);
}
pos[0] = pos[0]-indmov;
}else{
printarNave();
}
}else{
printarNave();
}
}