Author |
Message |
RsX
|
Posted: Sun Apr 02, 2006 2:21 am Post subject: Help with Pong --> Paddle Movement. |
|
|
I have a problem with paddle movement code.
As you can see I set the main user to use 'A' to move up and 'Z' to move down. Player 2 uses 'K' to move up and 'M' to move down. There are 2 problems with this.
1) The movement is cut off, random, doesnt work at times, slow and inefficient.
2) Player 2 cannot move at all for some reason...
Thank you in advance to all those who help!!!
code: |
%%----------------------------Paddle Control Player 1
% Keyboard Control (VS. Human)
if multi="y" then
if hasch then
loop
exit when hasch = false
getch (multimovp)
end loop
if multimovp="a" then
if P1Pad + 50 <= 380 then
P1Pad := P1Pad + 30
end if
elsif multimovp="z" then
if P1Pad >= 20 then
P1Pad := P1Pad - 30
end if
end if
end if
%----------------------------Paddle Control Player 2
% Keyboard Control/Human Player (Human)
if multi="y" then
if hasch then
loop
exit when hasch = false
getch (multimove)
end loop
if multimove="k" then
if P2Pad + 50 <= 380 then
P2Pad := P2Pad + 30
end if
elsif multimove="m" then
if P2Pad >= 20 then
P2Pad := P2Pad - 30
end if
end if
end if
|
P.S. I have a smaller problem that isnt as urgent...
Is it possible to add background sounds? (processes within loops and ifs?)
It wont let me for some reason. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
RsX
|
Posted: Sun Apr 02, 2006 4:26 am Post subject: (No subject) |
|
|
NVM I got the sound fixed. But I still need help with the big problem..
For some reason player 2 works when I remove the player 1 code....
Anyone have any ideas?
Help is greatly appreciated! |
|
|
|
|
|
Tony
|
Posted: Sun Apr 02, 2006 4:32 am Post subject: (No subject) |
|
|
because getch() reads only 1 key at a time. Go ahead, try it - reply to this post and hold down two letter keys, see what happens? That's what your program sees.
if you want to register multiple button presses, you need to use Input.KeyDown |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
RsX
|
Posted: Sun Apr 02, 2006 4:33 am Post subject: (No subject) |
|
|
How do you use that? Can you maybe write sample code or something if u have time? |
|
|
|
|
|
Tony
|
|
|
|
|
|