Alice Community  

Go Back   Alice Community > General Discussion > Questions and Comments

Reply
 
Thread Tools Display Modes
methods for multiple use
Old
firechild
Guest
 
Status:
Posts: n/a
Default methods for multiple use - 11-05-2010, 03:23 PM

hello, I'm trying to create a marching method for some toy soldiers. I have coded what I want for the first soldier but I was wondering if there is a way to set it up so I can assign toy soldier2 to do the same code without rewriting it (or copying / paste it and switching the object)?
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 11-05-2010, 03:43 PM

Yes, as a matter of fact there is a very useful thing in Alice that allows you to do this, and it requires a "list". It is pretty complicated, so if you want you can upload your program to this thread and I can implement what I am trying to say for you, and then explain it afterwards so you can read what I say and see what I did. If you just listen to what I say it might be a little confusing, and you may have never heard of any of the terms that I use like "list" or "For all in order" or "(Object)'s part named (key)".


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 578
Join Date: Nov 2008
Location: In the interwebs
Default 11-05-2010, 03:45 PM

Also, you can put the target as a parameter for the method and have all actions releative to that target.


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.
   
Reply With Quote
Old
firechild
Guest
 
Status:
Posts: n/a
Default 11-05-2010, 03:53 PM

here is the code, (noob alert) it is very basic!
Attached Files
File Type: a2w the game.a2w (1.23 MB, 5 views)
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 11-05-2010, 04:50 PM

Ok I fixed it, here it is. Notice that it took a lot of work to change the animations because I had to use a function called "(object)'s part named (key)", which is one of the last functions in the world functions tab. I had to change this out for all of the "toySoldier2"s in the animation and switch it with an object parameter called "soldier". This parameter could then be switched with multiple objects, allowing each object to do the same thing, just used on the different people. I made it so at first, all the soldiers did the same thing with the same method at once, and then had them do it one at a time. It is all in the "my first method" method and the "march(soldier)" method.

Ask me if you do not understand a part of it, or if you don't know where I got certain things. Also, when you do the animation you can click the "More" option to the side of the blocks of code and choose "Duration" to decide how fast you want that certain subpart to move. It goes really slowly right now because the soldier is doing everything in 1 second intervals. If you want you can make him to it all 4 times faster than he does right now by making the duration "0.25" seconds instead of the default "1" second per animation.
Attached Files
File Type: a2w the game (firechild).a2w (1.31 MB, 20 views)


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
firechild
Guest
 
Status:
Posts: n/a
Default 11-05-2010, 06:04 PM

First I want to thank you! This is awesome I got the soldier to move its arms and legs back and forth using this. However I'm having some trouble with the move forward command, I put the (soldier)'s part named (????) command in but I'm not sure how to full in the ????'s. I want the entire soldier to move forward how do i do this?

Edited:
oh I figured it out you just put the object (soldier), instead of "(soldier)'s part named (????)".

Last edited by firechild; 11-05-2010 at 06:13 PM.
   
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 ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.