The Daily Click ::. Forums ::. Klik Coding Help ::. Events with two keypresses at the same time
 

Post Reply  Post Oekaki 
 

Posted By Message

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
5th February, 2006 at 13:02:09 -

Here's probably a really easy one, but how do you get user input for pressing down two keys at once?

I thought it'd be by doing this:

> If user presses "SPACE BAR"
+ If user presses "UP ARROW"

But it doesn't work for me. I also tried to simultaneously press SPACE BAR and the UP ARROW when I was prompted as to which key should the event check on press to have it as a single event, but that didn't cut it either. I know that in VB different keys have different ASC codes that correspond with them (ex. the <ENTER> key = ASC code 13), does the solution have to do with their ASC codes?

I'm sure it's easy, but how do you do it?

Thanks!

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Peblo

Custom ratings must be 50 characters or less

Registered
  05/07/2002
Points
  185

Game of the Week WinnerVIP MemberI'm on a Boat360 OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimePS3 OwnerIt's-a me, Mario!
I'm a Storm TrooperSonic SpeedStrawberryI like Aliens!Wii OwnerMushroomGhostbuster!
5th February, 2006 at 13:09:08 -

Um, you could always try it:

> Repeat while user holds "SPACE BAR"
+ If user presses "UP ARROW"

Or:
>Always- Flag 0 off, Flag 1 off
>User presses Space- Flag 0 ON
>User presses Up- Flag 1 ON
>Flag 0 is on
+Flag 1 in on- Action

I believe that works, be careful on the order though.

 
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
5th February, 2006 at 15:19:59 -

Ever played a sonic the hedgehog game?
The spindash move requires two buttons to be pressed

however you don't need to see if two buttons are pressed you can use something else like an animation or a value.

(1)Repeat while user presses down - set animation to crouch

(2)Animation crouch is playing
+Upon pressing button 1


that should work too.

 
.

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
5th February, 2006 at 19:14:04 -

The best way to handle this is to do it this way.

-----------------------------------
Always - Dummyobjecy.Flag0 & Flag1 turn OFF
Player Presses X - Dummyobject1.Flag0 turn ON
Player Presses C - Dummyobject1.Flag1 turn ON

Dummyobject.Flag0 = On && Dummyobject.Flag1 = On - Your event here.

===
Though the way Peblo said works as well. They way you've got it coded Del, the person would have to press both buttons in the exact same loop. That's press, not hold down.

Image Edited by the Author.

 
Craps, I'm an old man!

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
5th February, 2006 at 19:19:50 -

Awesome, thank you very much!

The way I have it now, my guy can do an upward slash while he's jumping, but I also wanted to give the player the option to do the same attack while standing on the ground with space + up. I'll code this after work straightaway.

I don't believe I've ever used the repeat while key is down, but it all makes sense now, doh!

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!
   

Post Reply



 



Advertisement

Worth A Click