Alice Community  

Go Back   Alice Community > Alice 2 > Suggestion Box

Reply
 
Thread Tools Display Modes
Keyboard key variables?
Old
zero00
Senior Member
 
zero00's Avatar
 
Status: Offline
Posts: 300
Join Date: Oct 2009
Default Keyboard key variables? - 11-17-2011, 03:21 AM

Is it possible to add a "key" variable to Alice, and to modify the When a key is typed 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?


==============Some of my Games and Ideas===========

Sky Warrior: http://www.alice.org/community/showthread.php?t=6291
Health Bars: http://www.alice.org/community/showthread.php?p=36968#post36968
Sky Warrior: Dual Force: http://www.alice.org/community/showthread.php?t=7174

Want to make your own space game? http://www.alice.org/community/showthread.php?t=6389
   
Reply With Quote
Old
room14
Senior Member
 
room14's Avatar
 
Status: Offline
Posts: 549
Join Date: Nov 2009
Location: Auckland New Zealand
Default 11-17-2011, 03:31 AM

i heard, using scripting you can.


:D
   
Reply With Quote
Old
sfunk
Senior Member
 
sfunk's Avatar
 
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 11-17-2011, 08:53 AM

Quote:
Originally Posted by room14 View Post
i heard, using scripting you can.
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


If you are stuck on a project, check out the tutorials I made here at this link:

http://alice.org/community/showthread.php?p=36778#post36778

There are lots of tutorials on it so far, including some youtube videos, check it out

Or..

Go to my youtube channel to check out my alice 2.2 tutorials I have there..

http://www.youtube.com/user/sfunk1992?feature=mhsn
   
Reply With Quote
Old
Mr Kidnapper
Senior Member
 
Status: Offline
Posts: 442
Join Date: Feb 2011
Default 11-17-2011, 09:32 PM

Use the ASCII key table.
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.
   
Reply With Quote
More keys for When "<key> is typed" event
Old
aikmin
Senior Member
 
aikmin's Avatar
 
Status: Offline
Posts: 85
Join Date: Mar 2008
Default More keys for When "<key> is typed" event - 11-18-2013, 12:08 AM

Edit your \Required\resources\common\StandardResources.py file.

Find this section in the file:
["edu.cmu.cs.stage3.alice.core.behavior.KeyClic kBeh 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 http://docs.oracle.com/javase/7/docs.../KeyEvent.html

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



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