Alice Community  

Go Back   Alice Community > General Discussion > The Lounge

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
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default 06-28-2018, 03:16 PM

Quote:
Originally Posted by jkidd View Post
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
First please stop posting the same thing to multiple threads. Second you need to look at you code and think through what it is doing.

In the code you give the user is never asked how many times to spin, unless it is in sheriff.spin which is not shown. Also the loop you have is an infinite loop, this means the loop will never end once it is started. I would like to see the whole movie before giving any help please post the movie itself rather than just the code.

Again I would urge you to work through you code and figure out what is going on as just getting the answers from this group will not teach you anything.

Mark


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
Old
jkidd
Member
 
Status: Offline
Posts: 21
Join Date: Jun 2018
Default 06-28-2018, 03:28 PM

Hi chickentree -

I'm sorry for the multiple posts. :/ I'm not trying to get the answers from folks. Merely, I'm only trying to understand what I'm missing or doing wrong.

I'm more of a visual learner, so examples or screen shots help.

I've attached the file in this reply.

- jkidd
Attached Files
File Type: a2w Lab2.a2w (1.27 MB, 1 views)
   
Reply With Quote
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default 06-28-2018, 05:15 PM

Quote:
Originally Posted by jkidd View Post
Hi chickentree -

I'm sorry for the multiple posts. :/ I'm not trying to get the answers from folks. Merely, I'm only trying to understand what I'm missing or doing wrong.

I'm more of a visual learner, so examples or screen shots help.

I've attached the file in this reply.

- jkidd
First understand what is going on now:
  1. You are asking how many times to spin in sheriff.spin. So each time it is called the question is asked again
  2. after the first time, the repeat question is asked and either sheriff.spin is called forever or the sheriff says "it was fun" over and over forever

Pick "no" to see that the sheriff says "it was fun" repeatedly (the movie is running the whole time)

Then think about what you want the movie to do:
In My First Method:
ask the user how many times to spin and save this value as times
spin the sheriff times
ask the user if they want to do it again and save this value as continue
while continue value is true

Spin the sheriff times times
ask the user if they want to do it again and save this value as continue
sheriff says bye
In sheriff.spin

Add a parameter for how many times to spin
Just spin the sheriff ( take out question about how many times.)

These changes should get you what you want. Again the main thing is to work your way through how the movie works in your head.

Mark


Mark Henwood
mhenwood@ieee.org
   
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.