The Daily Click ::. Forums ::. Klik Coding Help ::. 2 buttons at the same time
 

Post Reply  Post Oekaki 
 

Posted By Message

Jason Orme

Using Klik Products Since 1998

Registered
  24/05/2002
Points
  960

VIP Member360 OwnerWii OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimeI'm a Storm TrooperI'm on a BoatIt's-a me, Mario!
Sonic SpeedMushroomStrawberryI like Aliens!PS3 OwnerTurtle Power!I am an April Fool
18th January, 2008 at 09:57:22 -

Hello,

Somthing that been bugging me for awhile.

Is there a way you can set somthing to happen based on pressing two buttons at the same time.

For example, ctrl / (fire button 2) is attack, and shift / (fire button 1) is jump.

I want to be able to do somthing different if they are both pressed at the same time, but it also needs to be joystick and keyboard compatible, is there a way to do it?

Hope you can help,

Thanks

 
www.jsofts.com

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
18th January, 2008 at 10:08:32 -

Repeat Whilst "Control" pressed
+ Repeat whilst "Shift" pressed
[optional] + only one action when event loops
= Do action

Repeat Whilst "Control" pressed
+ [negate] Repeat whilst "Shift" pressed
[optional] + only one action when event loops
= Do action

Repeat whilst "Shift" pressed
+ [negate] Repeat Whilst "Control" pressed
[optional] + only one action when event loops
= Do action


You could try that, and if that doesn't work, replace "Repeat whilst X pressed" with "Upon pressing X" for the 2 non-negated conditions in the last 2.

The only one action whilst event loops is to stop it repeating it whilst you hold both keys.

EDIT--

It should work if you replace Control/Shift with Fire 1/ Fire 2



Image Edited by the Author.

 
My signature is never too big!!!

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!
18th January, 2008 at 10:09:29 -

Nevermind...

Image Edited by the Author.

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

Jason Orme

Using Klik Products Since 1998

Registered
  24/05/2002
Points
  960

VIP Member360 OwnerWii OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimeI'm a Storm TrooperI'm on a BoatIt's-a me, Mario!
Sonic SpeedMushroomStrawberryI like Aliens!PS3 OwnerTurtle Power!I am an April Fool
18th January, 2008 at 11:16:49 -

Doesn't seem to work when done as shown, and when replacing "Repeat whilst X pressed" with "Upon pressing X" it won't let you negate them.

 
www.jsofts.com

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!
18th January, 2008 at 11:24:04 -

You can make an active object called keyboard...

Repeat Whilst "Control" pressed = Flag 0 for activekeyboard on

negate)Repeat Whilst "Control" pressed = Flag 0 for activekeyboard off

Repeat Whilst "Shift" pressed = Flag 1 for activekeyboard on

negate)Repeat Whilst "Shift" pressed = Flag 1 for activekeyboard off


Flag 0 is on
+ Flag 1 is on
[optional] + only one action when event loops
= Do action

Flag 0 is on
+ Flag 1 is off
[optional] + only one action when event loops
= Do action

Flag 0 is off
+ Flag 1 is on
[optional] + only one action when event loops
= Do action


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

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
18th January, 2008 at 11:25:43 -

Was about to post something exactly like that, Peblo. Beat me to it

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Jason Orme

Using Klik Products Since 1998

Registered
  24/05/2002
Points
  960

VIP Member360 OwnerWii OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimeI'm a Storm TrooperI'm on a BoatIt's-a me, Mario!
Sonic SpeedMushroomStrawberryI like Aliens!PS3 OwnerTurtle Power!I am an April Fool
18th January, 2008 at 11:25:58 -

okay, i've got it to a point where it does work, but its alittle hard to do as somtimes it will jump instead.

 
www.jsofts.com

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
18th January, 2008 at 11:32:01 -

The problem you are experiencing is most likely that you have events tied to both hitting "CTRL" and "SHIFT"; so whenever one of them is pressed, it will attack or jump. The problem then is that when someone tries to hit two keys at the same time, 99% of the time one of the keys will be pressed down before the other one. Then the game will interpret it in order of what was hit.

So for example, if you mash the A & S buttons really fast, you'll most often type AS, not SA. This means that by nature one of the keys must go down first. If you want CTRL + SHIFT to have a completely different use then CTRL or SHIFT on their own, what you need to do is time delay your events;

For example, trigger it so that you will not attack IMMEDIATELY after hitting CTRL, but rather while holding control, a counter is added up to say 4 or 5, and when it reachs that number, it counts it as hitting control.

For example:

+While Control is Pressed
Add one to A

+If A >= 5
Set Flag 0 On

+Flag 0 is on
Play Attack Animation


You'll need to play around with the numbers. If you set the delay too high, the controls will feel slippery. If you set it too low, it will register alot of false positives

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

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!
18th January, 2008 at 11:33:54 -

If you have the 'two button at once' code above the other two button code, then it should register first.

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

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
18th January, 2008 at 11:37:01 -

That too >.>
I like giving people a couple frames leeway for overloaded controls.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Jason Orme

Using Klik Products Since 1998

Registered
  24/05/2002
Points
  960

VIP Member360 OwnerWii OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimeI'm a Storm TrooperI'm on a BoatIt's-a me, Mario!
Sonic SpeedMushroomStrawberryI like Aliens!PS3 OwnerTurtle Power!I am an April Fool
18th January, 2008 at 11:40:48 -


Originally Posted by Peblo
If you have the 'two button at once' code above the other two button code, then it should register first.



That seemed to fix the problem

Thanks everyone for the help.

Now... the next problem is when pressing the two button together, due to it being repeat while button is pressed the sound effect goes all horrible (repeats).

 
www.jsofts.com

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
18th January, 2008 at 11:43:21 -

Put an "Only one action while event loops" into your event where bot when both are pressed.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

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!
18th January, 2008 at 11:43:37 -

Put in the [optional] events.

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

Jason Orme

Using Klik Products Since 1998

Registered
  24/05/2002
Points
  960

VIP Member360 OwnerWii OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimeI'm a Storm TrooperI'm on a BoatIt's-a me, Mario!
Sonic SpeedMushroomStrawberryI like Aliens!PS3 OwnerTurtle Power!I am an April Fool
18th January, 2008 at 11:46:18 -

Done.

Thanks alot.

I've never thought to post here before with problems, seems everyones a great help.

 
www.jsofts.com
   

Post Reply



 



Advertisement

Worth A Click