Alice Community  

Go Back   Alice Community > General Discussion > The Lounge

Reply
 
Thread Tools Display Modes
Advanced methods in Alice
Old
esayago
Junior Member
 
Status: Offline
Posts: 6
Join Date: Jun 2015
Default Advanced methods in Alice - 06-18-2015, 07:56 PM

One of the most important things I learned from my last assignment was generating random numbers, this function is often use in games, and understanding the application of this function will help a lot with the final project. Also the importance of creating custom method to have a cleaner code to make maintenence more efficient. Something I had troubles with was making an object jump (move up) at a random distance and them have the object come back down at the same random number generated. I tried to assign the value generated to an empty variable but it didn't work for me..
   
Reply With Quote
Old
shoff
Member
 
Status: Offline
Posts: 15
Join Date: Jun 2015
Default 06-19-2015, 10:34 AM

It helps if you create a "hop" method with the up/down movement housed in it. Then in your formula, the hop method is attributed to the random distance. So when a random distance is selected, it runs the entire method from up and down. I think that's what I encountered and how I fixed it.
   
Reply With Quote
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 501
Join Date: Sep 2007
Location: Austin, Texas
Default 06-19-2015, 04:05 PM

Actually. either way should solve the problem. Something like

create numeric variable rand
set rand to random()
object move up rand
object move down rand

Should work fine.

However, remember that you are working in a 3D world. Complex movements can alter the orientation of an object. If you do a few other things between the Up and the Down, then the objects "Real" distance to the ground might no longer be the same when the down is executed.
   
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.