473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How do I move two graphic paddles(pong) at the same time using one keyboard in C#?

Expand|Select|Wrap|Line Numbers
  1.         protected override void OnKeyDown(KeyEventArgs e)
  2.         {
  3.             if (e.KeyCode == Keys.Up) 
  4.                 paddleY = paddleY - 15;
  5.             else if (e.KeyCode == Keys.Down)
  6.                 paddleY = paddleY + 15;
  7.             else if (e.KeyCode == Keys.W) 
  8.                 paddleY2 = paddleY2 - 15;
  9.             else if (e.KeyCode == Keys.S)
  10.                 paddleY2 = paddleY2 + 15;
  11.  
  12.             Invalidate();
  13.             base.OnKeyDown(e);
  14.         }
May 9 '13 #1
1 1875
Make Keys.Up, Keys.Down AND Keys.W, Keys.S their own if statements. Right now this is just one big if statement, and only one condition can be ran at a time, so how do you expect more than one paddle to move here?

It should be... if Keys.Up {} else if Keys.Down {}, and then if Keys.W {} else if Keys.S {}.
May 23 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Weston C | last post by:
I'm coding up a small little script that's supposed to be used to display the number of hours until the US Financial markets open/close. Naturally, this involves getting the current time on the...
1
by: George LAZAR | last post by:
how can I change the system current date (time) using c#? thank you George
1
by: Michael Fitzpatrick | last post by:
Is it possible to set a variable with the value of a compile time constant. Example: #Const MODE_STR = "Mode1" dim strMode as String = MODE_STR Obviously this doesn't work. Is there a way...
6
by: Sakharam Phapale | last post by:
Hi All, How to move the CommandButton control using mouse from one position to other? Is it possible using Drag, Drop events or I have to write my own code for that? I have set the...
1
by: Russell Mangel | last post by:
Sorry about the Cross-Post, I posted my question in the wrong group. Hello, What is the simplest way to create a dynamic collection (during run-time), using basic C (Struct data types). Since...
3
by: brazel | last post by:
Good day! Hello everybody, I want to move my mouse pointer using my keyboard. in vb5 Tnx andvance.
6
by: remya1000 | last post by:
i'm using Vb.net. i need to find out the remote machine's time by using NET TIME. NET TIME i got this help from internet while searching. but while using this code i'm not able to display...
7
by: RADAR | last post by:
i use VC++ 6,0 and i have problems with getting keyboard system inputs and to use them to check to proceed or break the loop. for example if i want to proceed until Ctrl+z is written for input.What...
2
ammoos
by: ammoos | last post by:
Hi friends I couldnt move controls in a user form(ms excel) using keyboard but I can move it by mouse.. I couldnt understand whats the issue.. now I reinstalled ms office 2003 on my machine,...
17
by: msmjsuarez | last post by:
Hello, I need help... How to automatically insert data to mysql database without submit button using php? Is there a way on this? thanks a lot.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.