
-----------------------------------
RsX
Sun Apr 02, 2006 2:21 am

Help with Pong --&gt; 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!!! 







%%----------------------------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 = 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 = 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.

-----------------------------------
RsX
Sun Apr 02, 2006 4:26 am


-----------------------------------
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? :oops: 
Help is greatly appreciated!

-----------------------------------
Tony
Sun Apr 02, 2006 4:32 am


-----------------------------------
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

-----------------------------------
RsX
Sun Apr 02, 2006 4:33 am


-----------------------------------
How do you use that? Can you maybe write sample code or something if u have time? :P

-----------------------------------
Tony
Sun Apr 02, 2006 4:42 am


-----------------------------------
[Turing Tutorials] is the place to be. I've [url=http://www.compsci.ca/v2/viewtopic.php?t=114]tried to explain Input.KeyDown
