Community
Message Board

Chat room - users
Game Over
( 394431 downloads)
Work In Progress
( 523201 downloads)
Links

Code Exchange
Downloads
Tutorials
Add to Favourites

Submit news

DIV ARENA FORUMS
Not logged in [Login - Register]
Go To Bottom

Printable Version  
Author: Subject: ayuda a codificar correctamente el algoritmo..
oskarg
DIV Junior
**




Posts: 33
Registered: 27-2-2016
Member Is Offline


[*] posted on 6-11-2016 at 08:07 PM
ayuda a codificar correctamente el algoritmo..


Hola,buenas....tengo un error en programacion y no encuentro como arreglarlo....
Lo que quiero es que cuando pulse la tecla _a acceda al proceso sube() si pulso la tecla _up entonces el valor=valor+1 ,es decir, si pulso por primera vez la tecla _up deberia valer 1...si pulsara dos veces la tecla _up deberia valer 2....


/*
* teclado.PRG by o
* (c) 2016 o
*/

PROGRAM teclado;
global
valor=0;
valor2=0;
BEGIN

write_int(0, 30, 24, 4, OFFSET valor); // A variable is displayed.
write_int(0, 40, 24, 4, OFFSET valor2); // A variable is displayed.

teclados();
sube();
loop

frame;
end
END



process sube()
private pa;

BEGIn
loop
if (key(_up)==1)
if (pa!=1)
valor2=valor2+1;
pa=1;
end

else
pa=0;

end
frame;
end
END






process teclados()
private pa;

BEGIn
loop
if (key(_a)==1)
if (pa!=1)
valor=valor+1;
pa=1;
end
sube();

else
pa=0;

end






frame;
end
END



View user's profile View All Posts By User
MikeDX
DIV Nerd
*********


Avatar


Posts: 8388607
Registered: 25-2-2016
Member Is Offline


[*] posted on 6-11-2016 at 09:21 PM


I think your logic is a bit strange but I can try to help you

Code:
/* * up.prg by MikeDX * (c) 2016 DX Games */ PROGRAM up; GLOBAL value2; BEGIN //Write your code here, make something amazing! write_int(0,0,0,0,&value2); doup(); loop frame; end END process doup() private oldup; BEGIN LOOP // check up pressed if(key(_up)) value2=1; if(oldup>0) // if we pressed up twice within 10 frames value2=2; end oldup=10; // 10 frames to press up again end while(key(_up)) // wait for up to be released if(oldup>0) oldup--; end frame; end oldup--; frame; value2=0; end // end loop end // end process
View user's profile View All Posts By User

  Go To Top

Powered by XMB
XMB Forum Software © 2001-2012 The XMB Group
[Queries: 18]