Alice Community random motion

 random motion
 thearun Guest   Status: Posts: n/a random motion - 01-09-2010, 04:24 PM 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]
 9 views:O
 thearun Guest   Status: Posts: n/a 9 views:O - 01-09-2010, 05:02 PM n no posts:'(? it can't be that hard can it? i'm desperate. and so lost.
 x2495iiii Super Moderator     Status: Offline Posts: 3,508 Join Date: Dec 2008 Location: Somewhere in the Continental U.S. 01-09-2010, 06:03 PM Search chris101b's posts, he made an example of something like this for use in enemy AI. (')>
 i can't find it.
 thearun Guest   Status: Posts: n/a i can't find it. - 01-10-2010, 01:28 PM Is this the thread you were referring to? http://alice.org/community/showthrea...ghlight=random 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 Super Moderator     Status: Offline Posts: 3,508 Join Date: Dec 2008 Location: Somewhere in the Continental U.S. 01-10-2010, 01:35 PM No, this one. http://www.alice.org/community/showthread.php?t=3259 (')>
 Thanks
 thearun Guest   Status: Posts: n/a Thanks - 01-10-2010, 01:40 PM I'll have a look at that and see if i can figure it out.
jediaction
Senior Member

Status: Offline
Posts: 5,064
Join Date: Jul 2009
Location: Bel Air, Maryland
01-10-2010, 01:42 PM

Quote:
 Originally Posted by thearun 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, yoru problem is because you put them showing to false, there not there, change them to visible = true but opacity = 0%. it should work

Website: www.salokingames.com

thearun
Guest

Status:
Posts: n/a
01-10-2010, 01:51 PM

Quote:
 Originally Posted by jediaction 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
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.

Last edited by thearun; 01-10-2010 at 01:57 PM. Reason: update

 Dameria Senior Member     Status: Offline Posts: 978 Join Date: Sep 2009 Location: United States 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... 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
thearun
Guest

Status:
Posts: n/a
01-10-2010, 02:08 PM

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.
The random motion is in the method "world.Turtle Movement"
Attached Files
 turtle game.a2w (1.44 MB, 48 views)

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge