Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   The Lounge (http://www.alice.org/community/forumdisplay.php?f=4)
-   -   Advanced methods in Alice (http://www.alice.org/community/showthread.php?t=11173)

esayago 06-18-2015 07:56 PM

Advanced methods in Alice
 
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..

shoff 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.

MrMoke 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.


All times are GMT -5. The time now is 12:31 PM.

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