Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Multiple Input From Keyboard at Once?

Reply
Thread Tools

Multiple Input From Keyboard at Once?

 
 
caleb
Guest
Posts: n/a
 
      07-19-2005
I'm making a Mario like side scroller game and I having some trouble
with input. I can only hit one key at once, if I try two it doesn't
register. I would like to be able to run and jump at the same time.

public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_RIGHT) {
for(int i=0; i<player.size(); i++) {
Player p = (Player) player.elementAt(i);
p.moveEast();
}
}
if(e.getKeyCode() == KeyEvent.VK_LEFT) {
for(int i=0; i<player.size(); i++) {
Player p = (Player) player.elementAt(i);
p.moveWest();
}
}
if(e.getKeyCode() == KeyEvent.VK_SPACE) {
for(int i=0; i<player.size(); i++) {
Player p = (Player) player.elementAt(i);
p.jump();
}
}
}

This is an example of the kind of thing I'm trying to do. Also I've
been trying to figure out how to have the camera center on the
player... so the player's pixels aren't actually moving, but rather the
background. I assume I should make the input keys move the background
while the character is only being animated but I haven't started coding
it yet. Any source code from similar games would be very helpful.
Thanks in advance.

 
Reply With Quote
 
 
 
 
caleb
Guest
Posts: n/a
 
      07-19-2005
bump

 
Reply With Quote
 
 
 
 
hiwa
Guest
Posts: n/a
 
      07-20-2005
"caleb" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed) roups.com>...
> I'm making a Mario like side scroller game and I having some trouble
> with input. I can only hit one key at once,
> if I try two it doesn't

Simply you can't. Except some modifier keys.

> This is an example of the kind of thing I'm trying to do. Also I've
> been trying to figure out how to have the camera center on the
> player... so the player's pixels aren't actually moving, but rather the
> background. I assume I should make the input keys move the background
> while the character is only being animated but I haven't started coding
> it yet. Any source code from similar games would be very helpful.
> Thanks in advance.

That's simple animation task. Examples should abound on the Net.
 
Reply With Quote
 
caleb
Guest
Posts: n/a
 
      07-31-2005
If it's not possible then why do some games allow you to shoot, jump,
and run at the same time?

Thanks for the reply though.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can I use scanf to get input (some times user enters input sometimes not, just hit keyboard)? santa19992000@yahoo.com C Programming 4 09-09-2005 03:38 AM
Keyboard error or no keyboard present??? Bud Light Computer Support 2 01-22-2005 04:00 AM
Unbuffered keyboard input??? Starbase Commander Perl 1 09-10-2004 11:20 PM
Coloring input type=input browse button; uploading multiple files Ron Brennan Javascript 5 05-14-2004 08:13 PM
detect keyboard input without reading it? Scott Shaw Perl 1 11-10-2003 04:33 AM



Advertisments