Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Thread Tools Display Modes
Keeping Track
Posts: n/a
Cool Keeping Track - 02-23-2006, 06:37 PM

Well, like i've mentioned before, i'm making a game with every day people and everyday Giant Fire hydrants The reall problem is, when you shoot someone or something, the revolver reacts by turning backwards and forwards. Is there anyway that every time like someone is clicked on can there be a way to keep track of points?
Reply With Quote
Whay about an an event handler?
Posts: n/a
Default Whay about an an event handler? - 02-27-2006, 03:29 PM

I'm not sure of your programing experience, so please don't be insulted if the following seems obvious, but I hope it helps.

In event driven programming a true event consists of an event trigger and an event handler. An event trigger is the condition that causes an event to occur. An event handler is a method that runs whenever the trigger occurs. Events can often take the place of complicated or convoluted logic in a program.

I suggest you combine an Alice event that checks for the trigger with an Alice method to handle what happens when the trigger occurs. In your particular case, you could:

1. Set up a method to do whatever you want to do when the mouse is clicked on a particular object. To keep score, you could set up a variable as a property of an object, or as a property of the world itself. When the method runs, the score varibale could be incremented or otherwise changed.

2. Set up an event of the form:
When the mouse is clicked on (something) do (method name)

Put the object in place of (something) and the method described
above in place of (method name).

The method coud do one thing, do several things, or call other methods from within itself, which would be the proper way to layer software modules.

You could also set up an event of the form:

When something is true

to cause whatever actions you desire when the score variable reaches a certain value.For example:

When (score > 100) becomes true, do (world.victory)

Chuck Herbert
Reply With Quote

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 ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.