Alice Community  

Go Back   Alice Community > General Discussion > The Lounge

Reply
 
Thread Tools Display Modes
Assignment 4: random jumping objects coming down
Old
smccray
Junior Member
 
Status: Offline
Posts: 7
Join Date: Jul 2013
Default Assignment 4: random jumping objects coming down - 07-21-2013, 09:07 PM

I can't figure out how to get the object (I used a turtle) to come back to the ground? My turtle "jumps" and I found the random feature, but I can't figure out how to get it to come back down. He disappears into the ground with the "go to ground" method. Right now, I just have move up 1.5 m & move down 1.5 m. I can't figure out how to get him to move proportionally with the random feature. I tried creating a variable, but couldn't plug "random" into the value. I'm confused.
   
Reply With Quote
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 212
Join Date: Dec 2012
Location: Frosno, Ca
Default 07-22-2013, 09:17 AM

Quote:
Originally Posted by smccray View Post
I can't figure out how to get the object (I used a turtle) to come back to the ground? My turtle "jumps" and I found the random feature, but I can't figure out how to get it to come back down. He disappears into the ground with the "go to ground" method. Right now, I just have move up 1.5 m & move down 1.5 m. I can't figure out how to get him to move proportionally with the random feature. I tried creating a variable, but couldn't plug "random" into the value. I'm confused.
1. Are you using the same value to move up and down or are you calling random twice? Calling random twice would usually give you two different values. If that is the case I would expect the turtle to end up in the air sometimes, in the ground others and occasionally back at the ground. An additional problem could arise if you are "telling" the turtle to move up and then "telling" it to move toward the ground. This scenario only works if the turtle was over the ground's center when it move up, otherwise it is moving down some and toward the ground's center some.

2. In Alice you frequently need to use place holders. So if you create a variable 'dst' to represent the distance to jump, setting it to a random value is a two step process.
  • Drag dst into your method and give it any value, it doesn't matter what number you use.
  • Drag the random function into your method and use it to replace the value in your set dst instruction.

Mark


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
Old
JasonEllis
Junior Member
 
Status: Offline
Posts: 11
Join Date: Jul 2013
Default 07-22-2013, 07:15 PM

Quote:
Originally Posted by smccray View Post
I can't figure out how to get the object (I used a turtle) to come back to the ground? My turtle "jumps" and I found the random feature, but I can't figure out how to get it to come back down. He disappears into the ground with the "go to ground" method. Right now, I just have move up 1.5 m & move down 1.5 m. I can't figure out how to get him to move proportionally with the random feature. I tried creating a variable, but couldn't plug "random" into the value. I'm confused.
According to this, I think you're doing:

turtle move up random number
turtle move down random number

You should be using a variable like (height):

height set value to random number
turtle move up height meters
turtle move down height meters

As far as making them jump periodically, there are a few ways you can do this. I made mine jump at periodic intervals during the song, but it would be easier to just do a "do together", then add a "do in order" that waits a certain amount of time, jumps a random height, waits, jumps a random height, as many times as you'd like.

I hope this helps, post again if you have more questions!
   
Reply With Quote
Similar Challenges
Old
eug3n10
Junior Member
 
Status: Offline
Posts: 12
Join Date: Jul 2013
Location: Irving, TX
Default Similar Challenges - 07-23-2013, 01:02 AM

I had the same issue as you but I was eventually able to fix it. Ultimately what I did as previously mention was set a variable which I named JumpHeight to 1. This initial value did not matter as it would ultimately be set to a random variable. You have to set the JumpHeight to a random variable, for mine I chose a min of .75 meters and max of 1.25 meters. It worked very well for my camera view. In order to have the jump occur repeatedly I inserted it within a DoTogether within the Boom Boom (verse) method. This worked quite well in mine although it took a lot of time for me personally to complete this assignment.
   
Reply With Quote
Thank you for your responses
Old
smccray
Junior Member
 
Status: Offline
Posts: 7
Join Date: Jul 2013
Default Thank you for your responses - 07-24-2013, 06:22 PM

So I did figure it out. I'm just now seeing your responses, so I apologize about that.

I used one of the course documents to figure it out. I created a "distance to" method and set value to "distance to {ground}" - 1.

This is what I ended up with--or something like it b/c I'm not looking at it:

Turtle [move] up [random number]
[(numerical) distance to variable] set value to [distance to (ground)] - 1.

So when I ran the program, the turtle jumped however high and regardless of how high he jumped he always landed on the ground.
   
Reply With Quote
Reply

Tags
jumping, random, values

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