Alice Community  

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

Reply
 
Thread Tools Display Modes
I have to 4 questions?
Old
scarlet
Guest
 
Status:
Posts: n/a
Default I have to 4 questions? - 10-18-2007, 10:48 AM

1. How do I copy code from one program to another. I wrote a world level method "jump", and I wanna use it in an another program.

2. How do I check if one object makes contact with another object? I know there is a "within distance of" function but that only works with centers. I want any part of an object.

3. How do I break out of loops?

4. Can I create and delete objects at run time?
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 10-18-2007, 10:47 PM

Quote:
Originally Posted by scarlet View Post
1. How do I copy code from one program to another. I wrote a world level method "jump", and I wanna use it in an another program.
There is probably an easier way, but one way may be to copy your method to one of the gallery classes, export that object/class from the File menu, import it into your new program, and copy the method to the world. However, I have never tried that so I can't assure you that it will work.

Quote:
Originally Posted by scarlet View Post
2. How do I check if one object makes contact with another object? I know there is a "within distance of" function but that only works with centers. I want any part of an object.
There have been lots of postings on collision detection. When the Search feature is restored, you will be able to read them.

Quote:
Originally Posted by scarlet View Post
3. How do I break out of loops?
Unlike in Java, as far as I know, there is no break command. Probably the best you can do is to cause the conditional clause to return false the next time it is tested.

Quote:
Originally Posted by scarlet View Post
4. Can I create and delete objects at run time?
Unfortunately, the answer to this question is no.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm
   
Reply With Quote
Old
Ping
Guest
 
Status:
Posts: n/a
Default 10-19-2007, 01:37 AM

for the distance to an object one, a math formula

if( [object1]'s distance to [object2] - [object2]'s Width / 2 <=1 )
do whatever...
else()
do nothing...

hope that helps u
   
Reply With Quote
Correction
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default Correction - 10-19-2007, 07:57 AM

Quote:
Originally Posted by DickBaldwin View Post
There is probably an easier way, but one way may be to copy your method to one of the gallery classes, export that object/class from the File menu, import it into your new program, and copy the method to the world. However, I have never tried that so I can't assure you that it will work.
Correction:
One way may be to copy your method to one of the gallery classes, export that object/class by right-clicking on the object and selecting save object ..., import it into your new program from the File menu, and copy the method to your new world. However, I have never tried to do this, so I can't assure you that it will work.




Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm
   
Reply With Quote
Old
scarlet
Guest
 
Status:
Posts: n/a
Default 10-19-2007, 10:20 AM

Quote:
Originally Posted by Ping View Post
for the distance to an object one, a math formula

if( [object1]'s distance to [object2] - [object2]'s Width / 2 <=1 )
do whatever...
else()
do nothing...

hope that helps u
Wouldn't it be

If ([object1]'s distance to [object2] - .5([object2]'s Width + [object1]'s Width) = 0

And this will only work if the objects are facing each other, If one object is coming at an angle it won't work!

Last edited by scarlet; 10-19-2007 at 10:38 AM.
   
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.