MouseGestures
Jump to navigation
Jump to search
Mouse Gesture system module is an input module created by Besh.
Abstract
The idea of this system was born when I start to work to "Child of the Moon". I coded this to cast spell in a way that looks like "Black & White" miracles.
This first version recognizes 20 different gestures (4 lines, 8 circles, 8 arrows).
Code
// Script header for module 'Mouse Gesture System' // // Author: Gabriel Ferri (Besh) // Please contact me about problems with this module. // // Abstract: This system recognizes the mouse movements. // // Dependencies: AGS 2.71 or later (not tested on previous versions) // // Functions: // MouseGesture.Activate(bool state) // Activates/deactivated Mouse Gesture System. // // MouseGesture.SetMouseButton(MouseButton button) // Sets the mouse button used for the gesture. The default is LEFT mouse button. // Actually, only LEFT and RIGHT mouse buttons are allowed. // // MouseGesture.AddLine(GesturePoint direction, float tolerance, String name) // This adds a simple line gesture. // direction: specifies the direction of the movement (eLeft, eRight, eUp, eDown). // tolerance: is an absolute value used to simplify the movement (from 0.0 impossible to 4.0/5.0 simple) // name: is the value returned by the system if this gesture is recognized. // // MouseGesture.AddCircle(GesturePoint start, GestureDirection direction, float tolerance, String name) // This adds a circle gesture. // start: specifies the gesture starting point (eLeft, eRight, eUp, eDown). // direction: specifies the direction of the movement (eClockwise, eCounterClockwise). // tolerance: is an absolute value used to simplify the movement (from 0.0 impossible to 15.0/20.0 simple) // name: is the value returned by the system if this gesture is recognized. // // MouseGesture.AddArrow(GesturePoint arrowhead, GestureDirection direction, float tolerance, String name) // This adds an arrow gesture. // arrowhead: specifies where the arrow is aiming (eLeft, eRight, eUp, eDown). // direction: specifies the direction of the movement (eClockwise, eCounterClockwise). // tolerance: is an absolute value used to simplify the movement (from 0.0 impossible to 10.0/15.0 simple) // name: is the value returned by the system if this gesture is recognized. // // Srting MouseGesture.Name // Contains the name of the recognized gesture. // // float MouseGesture.Vote // Contains the vote of the recognized gesture (from 0.0 no gesture to 1.0 perfect gesture). // // bool MouseGesture.isGesture // Sets to 1 when by the system when a new gesture is recognized. // // // // Use: // Add gestures and give them a name. Remenber to activate the system. // // IMPORTANT - in repeaditely_execute function add: // if (MouseGesture.isGesture) { // MouseGesture.isGesture = false; // ... // ... // } // // This code is needful to capture recognized gesture (not a great solution but works fine :-)) // // Example: // MouseGesture.AddArrow(eUp, eClockwise, 10.0, "ArrowUp"); // MouseGesture.AddCircle(eRight, eCounterClockwise, 15.0, "Circle"); // MouseGesture.AddLine(eLeft, 5.0, "LineSX"); // MouseGesture.AddLine(eRight, 5.0, "LineDX"); // // ... // // //script for Room: Repeatedly execute // if (MouseGesture.isGesture) { // MouseGesture.isGesture = false; // // if (MouseGesture.Name == "ArrowUp") // Function1(); // else if ((MouseGesture.Name == "Circle") && (MouseGesture.Vote >= 0.6)) // Function2(); // else if (MouseGesture.Name == "LineDX") // Function3(); // else if (MouseGesture.Name == "") // // no gesture recognized // } // // // // Revision History: // // 09 Jun 06: v1.0 First release of Mouse Gesture System module // // Licence: // // AGS Mouse Gesture System script module // Copyright (C) 2005-2006 Gabriel Ferri // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //=========================================================
Link