Pages: 1
Author Topic: Double-Click/Button Press?  (69,258 Views)
Offline (Unknown gender) AsherOS

Member
Joined: Jul 2013
Posts: 19
View profile
Posted on: September 03, 2013, 06: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
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #1 Posted on: September 03, 2013, 06: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 mouse_left_clicks = 0; in the create event and everytime the mouse left button occurs or you check it with mouse_check_button(mb_left); just do this mouse_left_clicks += 1; and then...


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.
Offline (Unknown gender) AsherOS

Member
Joined: Jul 2013
Posts: 19
View profile
Reply #2 Posted on: September 03, 2013, 07: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
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #3 Posted on: September 03, 2013, 07:03:40 PM
Ha, if only I could clone myself, right now I am redesigning our sprite editor...
Offline (Unknown gender) AsherOS

Member
Joined: Jul 2013
Posts: 19
View profile
Reply #4 Posted on: September 03, 2013, 07:05:41 PM
That is something I will very much appreciate!  :D Everyone's got their hands full these days.
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #5 Posted on: September 03, 2013, 07: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.
Offline (Unknown gender) AsherOS

Member
Joined: Jul 2013
Posts: 19
View profile
Reply #6 Posted on: September 03, 2013, 07:50:09 PM
I was just using the console game as an example, I have no intention of using controllers.
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #7 Posted on: September 03, 2013, 08: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.
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #8 Posted on: September 03, 2013, 09: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.
Offline (Unknown gender) AsherOS

Member
Joined: Jul 2013
Posts: 19
View profile
Reply #9 Posted on: September 04, 2013, 08: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?
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #10 Posted on: September 04, 2013, 09: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.
Offline (Unknown gender) AsherOS

Member
Joined: Jul 2013
Posts: 19
View profile
Reply #11 Posted on: September 06, 2013, 06:17:38 AM
I figured it would be more work. That compiler sounds cool though.
Pages: 1