Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   random motion (http://www.alice.org/community/showthread.php?t=3749)

thearun 01-09-2010 04:24 PM

random motion
 
I understand that this question has probably been asked many times before, but i really don't get it. I'm making a game for school in which a turtle is moving and you have to click on it to get points. I know about the random number function, and the minimum and maximum, but even with those i can't seem to figure out how to make the turtle stay on the screen.

This is my new plan. I've placed knives all over the screen, and set them to not showing. I'm going to have a variable called movement. Then have it set to a random number between 1 and 44[the number of knives]. Then i put if/else statements that say things like if movement == 2 turtle move to knife 2.

Unfortunately this is not working. Could anyone help me out and figure out what I'm doing wrong. [or give me a new way to do it]

thearun 01-09-2010 05:02 PM

9 views:O
 
n no posts:'(? it can't be that hard can it? i'm desperate. and so lost.

x2495iiii 01-09-2010 06:03 PM

Search chris101b's posts, he made an example of something like this for use in enemy AI.

thearun 01-10-2010 01:28 PM

i can't find it.
 
Is this the thread you were referring to?
[url]http://alice.org/community/showthread.php?t=3254&highlight=random[/url]
It mentions the way I'm trying to do things, but doesn't have a world exampling how to execute it correctly or any directions. Could someone please upload a world in which something like this is attempted? or at least tell me what I'm doing wrong.

x2495iiii 01-10-2010 01:35 PM

No, this one.

[url]http://www.alice.org/community/showthread.php?t=3259[/url]

thearun 01-10-2010 01:40 PM

Thanks
 
I'll have a look at that and see if i can figure it out.

jediaction 01-10-2010 01:42 PM

[QUOTE=thearun;15512]I understand that this question has probably been asked many times before, but i really don't get it. I'm making a game for school in which a turtle is moving and you have to click on it to get points. I know about the random number function, and the minimum and maximum, but even with those i can't seem to figure out how to make the turtle stay on the screen.

This is my new plan. I've placed knives all over the screen, and set them to not showing. I'm going to have a variable called movement. Then have it set to a random number between 1 and 44[the number of knives]. Then i put if/else statements that say things like if movement == 2 turtle move to knife 2.

Unfortunately this is not working. Could anyone help me out and figure out what I'm doing wrong. [or give me a new way to do it][/QUOTE]

thearun, yoru problem is because you put them showing to false, there not there, change them to visible = true but opacity = 0%. it should work

thearun 01-10-2010 01:51 PM

[QUOTE=jediaction;15550]thearun, yoru problem is because you put them showing to false, there not there, change them to visible = true but opacity = 0%. it should work[/QUOTE]

I will try this, but i don't think it will work. When i tested this idea at first with only 2 knives and set the variable manually to a number, it worked. When i tested it by setting to a random number min 1 max 2 integeronly true, it didn't. When i tested again setting max 1 min 1 and integer only it did not work. When I did this without the integer only, it did work.

Chris101b's code seems complicated but now i understand it better as he wanted the cow to only jump to cubes that are next to the cube it is already on. I'll try your suggestion, and then see if i can strip Chris101b's code of the complexity if it doesn't work. Thanks all of you.

Update: Setting isshowing=true does not work. Thanks for your input though.

Dameria 01-10-2010 01:55 PM

When you are using the randomNumber thing, are you sure that when it picks the random number it is integer only? If you are choosing a random number 1-44, it could be 22.3426549... Make sure that in the block of code where it picks a random number, you click the arrow on the right to choose more options, and then click Integer only, so that the number would be 22 instead of 22.342...

thearun 01-10-2010 02:08 PM

1 Attachment(s)
Yes i did use integer only. I'm going to post the file so you can see exactly what I'm doing. I think I'm on the right track, but don't have enough programming ability to execute this.
Please don't laugh:(
The random motion is in the method "world.Turtle Movement"


All times are GMT -5. The time now is 08:08 AM.

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