Alice Community  

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

Reply
 
Thread Tools Display Modes
Spinning Fan Project
Old
debooh
Guest
 
Status:
Posts: n/a
Default Spinning Fan Project - 11-03-2009, 02:08 PM

I found another way to solve this fan spinning project but I really can't figure out why the attached project does not work. Can anybody enlighten me on what I am doing wrong?



Thank you
Attached Files
File Type: a2w fan speed control 7-28.a2w (545.5 KB, 35 views)
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 11-03-2009, 11:39 PM

What I'd do is delete all of your boolean variables, then make one number variable called speed under the properties tab of the world (NOT in the method). Then, have the off button set speed to 0 when clicked, the low button set it to one, and so on for the other two buttons. Then, make a new "while the world is running" event which calls one of the methods in the During part of it (which basically means the event wil be called over and over while the world is playing). Finally, have the method that is called in the During part of the event contain a nested if/else if method which looks like this:

if speed == 3
fan.blades roll left .1 revolutions [duration = 0 seconds] [style = abruptly]
else
if speed == 2
etc.

I tried this myself, and it works wonderfully.


(')>
   
Reply With Quote
Old
antmj2317
Guest
 
Status:
Posts: n/a
Default 11-03-2009, 11:56 PM

Quote:
Originally Posted by x2495iiii View Post
What I'd do is delete all of your boolean variables, then make one number variable called speed under the properties tab of the world (NOT in the method). Then, have the off button set speed to 0 when clicked, the low button set it to one, and so on for the other two buttons. Then, make a new "while the world is running" event which calls one of the methods in the During part of it (which basically means the event wil be called over and over while the world is playing). Finally, have the method that is called in the During part of the event contain a nested if/else if method which looks like this:

if speed == 3
fan.blades roll left .1 revolutions [duration = 0 seconds] [style = abruptly]
else
if speed == 2
etc.

I tried this myself, and it works wonderfully.
There's an even easier way.

Create a global variable and give it a starting value of 0

Create events to assign different values to the variable per button.

In 'main', write a single line of code..

while true
fan.blades->roll at speed [global variable] per second

When the event's are executed, the variable in the infinite while loop will have it's value substituted.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 11-04-2009, 12:01 AM

That would work too, but you'd have less control over the fan's animation (my code allows for smooth turning and quick stopping, yours yields either choppy animation or slow stopping due to the need for a static, non-zero duration and the fact that the style cannot be changed to abruptly).


(')>

Last edited by x2495iiii; 11-04-2009 at 12:05 AM.
   
Reply With Quote
Hey guys
Old
fatdu4
Guest
 
Status:
Posts: n/a
Thumbs up Hey guys - 11-27-2009, 09:36 AM

Could you guys please attach your projects, I'd love to compare and learn from 'em. Thanks.
   
Reply With Quote
Old
dubastot
Senior Member
 
dubastot's Avatar
 
Status: Offline
Posts: 661
Join Date: Apr 2009
Location: Two Steps From Hell
Default 11-27-2009, 12:48 PM

They aren't going to post what they did for you. It is up to you to listen to what they said and try to do that in your animation.
   
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 ©2022, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.