+ 14
Something is goin wrong in my code plis help
I have a problem in code that ever time a press a button it executes the function of the button I press before, when I press it again then executes the function that it supose plis help me.The code name is game and its on my profile. Tengo un problema en mi codigo que cada vez que pressiono un botton se ejecuta la funcion del ultimo botton que presione antes que el y cuando lo presiono otra ves entonces executa la funcion que le pertenese.Por favor ayuda.El codigo se llama game y esta en mi perfil.
6 Réponses
+ 11
English is not my native language. could you give me a example?
+ 11
oh thanks I will test it
+ 4
in the function L U R what you do is draw rectangle with previous xpos ypos and then .changes. it so code seems a step behind
your function should change
the values before it is xpos ypos
+ 3
copied your function for going left
function L(){
d.save()
d.clearRect( 0, 0, 300, 300);
cube(xpos,ypos)
d.restore();
if(xpos != 280){
xpos = xpos +10;
}
}
should be
function L(){
d.save()
d.clearRect( 0, 0, 300, 300);
if(xpos != 280){
xpos = xpos +10;
}
cube(xpos,ypos)
d.restore();
}
not completely sure if "d.restore()" should move but "cube(xpos,ypos)" need to move
+ 1
in each movement function the line:
cube(xpos,ypos)
should come after u change xpos or ypos instead of before (after the 'if' u have there instead of before)
+ 1
Where is the code?