Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   Suggestion Box (http://www.alice.org/community/forumdisplay.php?f=26)
-   -   Keyboard key variables? (http://www.alice.org/community/showthread.php?t=7609)

zero00 11-17-2011 04:21 AM

Keyboard key variables?
 
Is it possible to add a "key" variable to Alice, and to modify the [I]When a key is typed[/I] events accordingly?

For example, "Key" = Spacebar
If "Key" is pressed, execute method.

This would make it easier for games to have keys that can be reassigned during play.

Also, can you add other keys like control, alt, shift, and the number pad buttons to the list of keys?

room14 11-17-2011 04:31 AM

i heard, using scripting you can.

sfunk 11-17-2011 09:53 AM

[QUOTE=room14;43590]i heard, using scripting you can.[/QUOTE]

I think adding more keys, but not making keys variables, there is a cheap way to making keys a variable though, using boolean/number variables and if/else statements

Mr Kidnapper 11-17-2011 10:32 PM

Use the [URL="http://www.bbdsoft.com/ascii.html"]ASCII key table[/URL].
Alice detects keys as ASCII in decimals. What you can do is make a key map. Unfortunately, this method is expensive. I'm doing it now using purely booleans. Even in my boss rig, this is taking a very long time because Alice feels like rendering 127 nested if/else statements every time I make a change.

aikmin 11-18-2013 01:08 AM

More keys for When "<key> is typed" event
 
Edit your \Required\resources\common\StandardResources.py file.

Find this section in the file:
["edu.cmu.cs.stage3.alice.core.behavior.KeyClickBeh avior",
["keyCode",
java.awt.event.KeyEvent.VK_SPACE,
java.awt.event.KeyEvent.VK_ENTER, ...

Add the items/keys you want.

If you are not sure of the keyCode, refer to [url]http://docs.oracle.com/javase/7/docs.../KeyEvent.html[/url]

Repeat for (if needed):
["edu.cmu.cs.stage3.alice.core.behavior.KeyIsPresse dBehavior",
["keyCode",
java.awt.event.KeyEvent.VK_SPACE,
java.awt.event.KeyEvent.VK_ENTER,...


All times are GMT -5. The time now is 04:24 AM.

Copyright ©2018, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.