Alice Community  

Go Back   Alice Community > Alice 3 > How Do I?

Reply
 
Thread Tools Display Modes
Spinning Character?
Old
jkidd
Member
 
Status: Offline
Posts: 21
Join Date: Jun 2018
Default Spinning Character? - 06-27-2018, 06:38 PM

Hey guys,

I have been working on having a character that asks the user for a number, which then causes the character to jump up, while using a loop to spin around the number of times specified, and then comes back down.

Once the Alice program has executed, the user is asked if they want it to run again. If they input "yes", it runs again. I am to use a loop to do this, so that it will run continually as long as the user keeps entering "yes" at the end.

Here is a screen shot of my method in Alice: https://image.ibb.co/eHYrvT/Cowboy.jpg

This is my dilemma... Once I click "yes", it goes back to the character originally asking the user as to how many times that he should spin. Instead of repeating how ever many spins that I told the character to do.

What am I missing? Any advice would be great.

Thanks.

- jkidd
   
Reply With Quote
getting to repeat spins
Old
sella18
Junior Member
 
Status: Offline
Posts: 9
Join Date: Jul 2018
Default getting to repeat spins - 07-24-2018, 09:07 PM

It's looks like from your screen shot you need to create another method where the user isn't asked how many spins they would like and use that in the loop. I would call this method spins_repeated. This will be the same as your SheriffSpin method only the statement asking the user for spins will be left out. A simple form would be sheriff move up/ sheriff turn/ sheriff move done. To make sure the object completes the same number of spins again you'll want to make a number variable in the sheriff's properties called spin. It is important that this variable is used in both SheriffSpin with value set as "asking user for number of spins" and again in spins_repeat as sheriff turn value so that it remains the same. Now in MyFirstMethod you will keep everything the same except what is in the if loop section. Instead of SheriffSpin method replace it with Spins_repeated and add your askuser2 variable with the set value of " asking the user yes or no". This should allow the object to repeat the same amount of spins again if the user selects yes to run the program again. It will continue this way until no is selected or the program is restarted and a new number of spins is input. I hope this is what you were looking for and it helps!
   
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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.