Alice Community  

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

Reply
 
Thread Tools Display Modes
random motion
Old
thearun
Guest
 
Status:
Posts: n/a
Default 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]
   
Reply With Quote
9 views:O
Old
thearun
Guest
 
Status:
Posts: n/a
Default 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.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 01-09-2010, 06:03 PM

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


(')>
   
Reply With Quote
i can't find it.
Old
thearun
Guest
 
Status:
Posts: n/a
Question 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.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 01-10-2010, 01:35 PM

No, this one.

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


(')>
   
Reply With Quote
Thanks
Old
thearun
Guest
 
Status:
Posts: n/a
Default Thanks - 01-10-2010, 01:40 PM

I'll have a look at that and see if i can figure it out.
   
Reply With Quote
Old
jediaction
Senior Member
 
jediaction's Avatar
 
Status: Offline
Posts: 5,064
Join Date: Jul 2009
Location: Bel Air, Maryland
Default 01-10-2010, 01:42 PM

Quote:
Originally Posted by thearun View Post
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
FaceBook: www.facebook.com/SalokinGames
   
Reply With Quote
Old
thearun
Guest
 
Status:
Posts: n/a
Default 01-10-2010, 01:51 PM

Quote:
Originally Posted by jediaction View Post
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
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 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
   
Reply With Quote
Old
thearun
Guest
 
Status:
Posts: n/a
Default 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.
Please don't laugh
The random motion is in the method "world.Turtle Movement"
Attached Files
File Type: a2w turtle game.a2w (1.44 MB, 48 views)
   
Reply With Quote
Reply


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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.