Author Topic: MODULE: Mouse Gesture System v1.0  (Read 4732 times)

Besh

  • Save the nature ... kill yourself.
    • I can help with translating
    • Besh worked on one or more games that was nominated for an AGS Award!
MODULE: Mouse Gesture System v1.0
« on: 09 Jun 2006, 13:17 »
MOUSE GESTURE SYSTEM script module

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).

Download MGS 1.0 (requires AGS 2.71 or later, not tested on previous versions)
Simple demo (requires AGS 2.71 or later, not tested on previous versions)

Code: [Select]
// 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
//=========================================================


What do you think? Let me know.
« Last Edit: 29 Jun 2006, 15:51 by Scorpiorus »
"Spread our codes to the stars,
You can rescue us all"
 - Muse

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Mouse Gesture System 1.0
« Reply #1 on: 09 Jun 2006, 14:48 »
Looks excellent! Good work, besh!

Radiant

  • Mittens Knight
  • AGS Baker
  • Return once more to the Two Kingdoms!
    • I can help with story design
    • I can help with publishing
    • Radiant worked on one or more games that won an AGS Award!
    •  
    • Radiant worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Mouse Gesture System 1.0
« Reply #2 on: 09 Jun 2006, 17:30 »
That's actually a rather nifty idea! I can see some cool games using this...

Re: MODULE: Mouse Gesture System 1.0
« Reply #3 on: 09 Jun 2006, 18:41 »

I tried "child of the moon" and I found the mousing impossibly difficult, maybe some kind of mouse trail would help poor inepts like me.
†œThere is much pleasure to be gained from useless knowledge.†
The Restroom Wall

Re: MODULE: Mouse Gesture System 1.0
« Reply #4 on: 10 Jun 2006, 11:11 »
Looks good, i'll add it to my site around monday.

magintz

  • Mittens Knight
  • Just because I rock doesn't mean I'm made of stone
    • I can help with story design
    • I can help with web design
    • magintz worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Mouse Gesture System v1.0
« Reply #5 on: 08 Jul 2006, 00:48 »
I had something similar in the works a while back where a verb coin type thing would appear and allow you to draw gestures within this GUI. I was working on it picking up angles of movement for general gestures and also speed, so that some puzzles may include throwing a ball or something and require speed and angle.

My main purpose of doing this was to have it like the firefox mouse gestures where "right click and drag" in various directions would perform simple actions such as look at or pick up emminating around the start point, which would be the hotspot...


This project however never progressed. I'm thinking of doing something using the drop down menu module but mixing it with a verb coin style and using context sensitive user actions, such as a window having open window and a candle having light or blow out.
When I was a little kid we had a sand box. It was a quicksand box. I was an only child... eventually.

Babar

  • Creator, Mutator and Defecator
    • I can help with proof reading
    • I can help with scripting
    • I can help with story design
    • I can help with translating
    • Babar worked on one or more games that won an AGS Award!
    •  
    • Babar worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Mouse Gesture System v1.0
« Reply #6 on: 08 Jul 2006, 14:09 »
Not sure if I understand what this does. Is it like the SPELLBOUND game that MrColossal made?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone