ENIGMA Forums

Outsourcing saves money => Programming Help => Topic started by: AsherOS on September 03, 2013, 01:38:33 PM

Title: Double-Click/Button Press?
Post by: AsherOS on September 03, 2013, 01:38:33 PM
In my game, I have "F" as the button for melee assassinations, but I also want to use it for the other gadgets in my game. I want to be able to use a double button press to detonate a remote explosive, similar to the double "X" or "square" press in CoD to detonate C4.

How do I make this distinction?

Cheers,
Asher
Title: Re: Double-Click/Button Press?
Post by: Goombert on September 03, 2013, 01:57:09 PM
Well neither Game Maker or ENIGMA provide this behavior by default. But you raise an interesting suggestion of something could be implemented. But for now just do as it would be done in Game Maker, eg. create a variable
Code: [Select]
mouse_left_clicks = 0; in the create event and everytime the mouse left button occurs or you check it with
Code: [Select]
mouse_check_button(mb_left); just do this
Code: [Select]
mouse_left_clicks += 1; and then...

Code: [Select]
if (mouse_check_button(mb_left) && mouse_left_clicks >= 2) {
  mouse_left_clicks = 0;
  // do stuff
}

But ya, like I said we should look at maybe how we could implement this to ENIGMA to make it easier.
Title: Re: Double-Click/Button Press?
Post by: AsherOS on September 03, 2013, 02:00:55 PM
Thanks. I was actually kind of surprised when I found out it wasn't a default feature.

Double clicks/press' would be a great feature to add
Title: Re: Double-Click/Button Press?
Post by: Goombert on September 03, 2013, 02:03:40 PM
Ha, if only I could clone myself, right now I am redesigning our sprite editor...
(http://oi42.tinypic.com/33bg8qa.jpg)
Title: Re: Double-Click/Button Press?
Post by: AsherOS on September 03, 2013, 02:05:41 PM
That is something I will very much appreciate!  :D Everyone's got their hands full these days.
Title: Re: Double-Click/Button Press?
Post by: TheExDeus on September 03, 2013, 02:27:24 PM
Things that are easy to implement in EDL (like Robert's few lines of code shows) usually are not good things to actually implement in ENIGMA as this way you have a lot more control. Problem here being that it would have to be strictly "standardized" or outlined. For example, how long should the presses be counted? When should they be clear? When you press another button? But then you won't be able to run and activate the ability at the same time. If it clears based on time, then what time? And be measured in what? Probably steps, but then the default value would usually be unsuitable and a function to set this time would have to be used. Or it needs to be cleared on times (just like Robert code, so it works even in rapid succession), but setting this for all inputs would be hassle. So a manual control for count clearing would have to be used as well. So maybe this could be added as an extension to ENIGMA just in case someone wants a ready made (but probably less flexible) solution. So in the end it would probably take even more code to use that extension than to code your own.

Also, your example mentions xbox (or similar) controller. That in itself is an extension and it would be more complicated to add a system like this for other inputs which can be controllers. Especially if it is an extension.

So it would probably always take less time and be less of a hassle to code this yourself, but I guess we can consider this. Maybe I will make an extension like that for keyboard and mouse.
Title: Re: Double-Click/Button Press?
Post by: AsherOS on September 03, 2013, 02:50:09 PM
I was just using the console game as an example, I have no intention of using controllers.
Title: Re: Double-Click/Button Press?
Post by: TheExDeus on September 03, 2013, 03:31:19 PM
I was just pointing out how complicated even the simplest things can be. Because if that is an extension (or built-in in ENIGMA without one), then others might think it should work for controllers too (which is reasonable) and so people will post here in confusion.
So for now I think the simplest things which can be done in pure EDL without problems should be done in EDL.
But thanks for the suggestion. I and others will probably consider it (the previous post was actually me considering it) and see if is doable.
Title: Re: Double-Click/Button Press?
Post by: Goombert on September 03, 2013, 04:35:30 PM
Harri, I was thinking of maybe some way to abstract the events was all, not suggesting implementing a counter when its never used.

AsherOS, we do have an XInput extension I wrote though, you can hook up and use your Xbox 360 controller if you have one, joysticks are also implemented, without extension on Linux but on Windows you enable DirectInput.
Title: Re: Double-Click/Button Press?
Post by: AsherOS on September 04, 2013, 03:45:57 PM
This is just out of curiosity, but would it be possible to make an emulator to play a game made in enigma on other platforms like consoles or mobile?
Title: Re: Double-Click/Button Press?
Post by: Goombert on September 04, 2013, 04:32:28 PM
Yes, that would be possible but a 1000x more work than just doing our various ports. We plan to do ports to Android and stuff but we need our new compiler finished first so that it can export using pretty printers to JavaScript/HTML5 etc.
Title: Re: Double-Click/Button Press?
Post by: AsherOS on September 06, 2013, 01:17:38 AM
I figured it would be more work. That compiler sounds cool though.