Alice Community  

Go Back   Alice Community > Alice 2 > Works-In-Progress

Reply
 
Thread Tools Display Modes
cedricdosss Space Jump
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default cedricdosss Space Jump - 11-15-2012, 11:11 AM

Quote:
Originally Posted by cedricdosss View Post
Hello, I'm working on this project can someone help me?
Create a world with an astronaut, moon surface, and Lunar Lander (LL). (Web Gallery). Using the “ask the user for a number” function, have the astronaut jump a specific height (but must be visible at all times). The value must be greater than zero, and if not, give and error message and repeat the question until a valid answer is given.

I have the most part, but can't get it to ask again until the valid answer is given.
Can anyone help?
Thanks
Hey cedricdosss, I looked at your Space Jump program and it looks like you put all of your code into one if/else statement. If you want your code to re-ask the user for a number when they enter anything 0 or less, then you'll have to use a loop. There are two kinds of loops you can use for this. The easiest is a recursive loop which basically just calls the method that you made to run it again. To do this just drag "my first method" to the place right after you have your astronaut say "Error". This should fix your problem.
Recursive loops are not a good habit to get into, though. They give you problems with lag when you recursively loop the same method a few thousand times.

A while loop is much better to use. I made the program for you with a while loop in case you want to see how it will work. I also made your animation MUCH smoother and better looking (I even finished your jump for you, you just had him suspended in mid air). You can download my version and see what I fixed. I made a world number variable called "input" and had it set to 0, and then put a while statement saying that while "input" is less than 0, it keeps asking you for a new number, and then when "input" is over 0, it preforms the animation, and when that is done the program ends.

Download from the link below and tell me what you think of the improvement I made on the animations.
Attached Files
File Type: a2w Space Jump (1).a2w (2.23 MB, 20 views)


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
Jump space
Old
cedricdosss
Junior Member
 
Status: Offline
Posts: 10
Join Date: Nov 2012
Default Jump space - 11-15-2012, 01:34 PM

Thanks you so much Dameria.
I tried to use the while loop, but could not really figure out how it works. Thanks you really was a big help. The project I'm doing is a little be longer than that. I will try first and if I run in to any more problem I will appreciate you in put.
Thanks again
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 11-15-2012, 02:33 PM

Quote:
Originally Posted by cedricdosss View Post
Thanks you so much Dameria.
I tried to use the while loop, but could not really figure out how it works. Thanks you really was a big help. The project I'm doing is a little be longer than that. I will try first and if I run in to any more problem I will appreciate you in put.
Thanks again
You should look at my program to see how I did it. The world variable I made is located by clicking the "World" tab in the top left, then pressing the "methods" tab. I'm guessing you also have to make your astronaut spin the number of times that you inputted while he is in the air?


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
Helicopter Squadron
Old
cedricdosss
Junior Member
 
Status: Offline
Posts: 10
Join Date: Nov 2012
Default Helicopter Squadron - 11-23-2012, 02:09 PM

Hello,
I have this project I'm working on
"Create a world with a list or array containing four Helicopters (Local Gallery). Each helicopter should have a unique name (in another list). You may have to resize the helicopters to fit in the world’s view. Each helicopter should have its propeller turn, and after a delay, one at a time, rise to a given height (based on a user supplied value), still in the camera’s view. The ground should fall away. The helicopters should tilt forward (one at a time). A message should appear from each (with its name), indicating its readiness for the mission (one at a time). "

I stated the programing , but I'm have issue on couple things.
[I]
.when the user enter a number that is more than 3, I want the program to ask until the right number is enter, but what it does is that he skip the helicopter. When I used "while"[ nothing happen /I]

My second issue is that I don't know how to make propeller turn and have each helicopter to say their name each at the time

Help please thanks
Attached Files
File Type: a2w Helicopter Squadron.a2w (1.14 MB, 3 views)
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 11-24-2012, 11:53 AM

Try this one. The only thing that I could not fix is that the propellers stop moving when the user is asked to enter a height. This can't be fixed though because when there is an input, all operations in the world pause.
Attached Files
File Type: a2w Helicopter Squadron (1).a2w (1.18 MB, 6 views)


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
Helicopter Squadron
Old
cedricdosss
Junior Member
 
Status: Offline
Posts: 10
Join Date: Nov 2012
Default Helicopter Squadron - 11-26-2012, 11:18 AM

Hi, thanks that was really helpful
but one question why when I add more (like other things I want the helicopter to do) It won't work?
Like I want them to turn around and move all together about 5 meters
Attached Files
File Type: a2w Helicopter Squadron (1).a2w (1.18 MB, 3 views)

Last edited by cedricdosss; 11-26-2012 at 12:00 PM. Reason: Add aa file
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 11-27-2012, 09:04 AM

Quote:
Originally Posted by cedricdosss View Post
Hi, thanks that was really helpful
but one question why when I add more (like other things I want the helicopter to do) It won't work?
Like I want them to turn around and move all together about 5 meters
You have to put everything in the tan "Do one at a time" block. You can't just add it to the bottom, because that really big "Do Together" block will never end from the infinite loop. I moved the code you wanted into the correct block.
Attached Files
File Type: a2w Helicopter Squadron (2).a2w (1.18 MB, 11 views)


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

Last edited by Dameria; 11-30-2012 at 09:55 AM.
   
Reply With Quote
Old
jediaction
Senior Member
 
jediaction's Avatar
 
Status: Offline
Posts: 5,064
Join Date: Jul 2009
Location: Bel Air, Maryland
Default 11-28-2012, 01:51 PM

This is a bit off topic, but I just want to take a second and welcome back Dameria, a long time Alice member. Welcome back, and it's glad to see you back in action and helping others again.


Website: www.salokingames.com
FaceBook: www.facebook.com/SalokinGames
   
Reply With Quote
Exercise 2 (Recursive Sailing) in Ch. 8 of Starting Out with Alice
Old
cedricdosss
Junior Member
 
Status: Offline
Posts: 10
Join Date: Nov 2012
Default Exercise 2 (Recursive Sailing) in Ch. 8 of Starting Out with Alice - 11-30-2012, 06:58 AM

I have this simple project I'm working, It about recursion. I do not get why the program will not stop when the boat is within 1 meter. And I am also trying to have the camera take a good look at the island. Help please.


Create a sea world with a boat and an island. Position the island some distance away from the boat. Write a method named sailTo, which has an Object parameter. The method should cause the boat to move one meter toward the object and then recursively call itself until the boat has reached the object. Test the method by calling it and passing the island as the argument.

Here are additional requirements:


1. The sailboat must appear to be in the water.
2. It should turn and face the island.
3. The sailboat must reach the island independent of where it is initially placed.
4. The sailboat should move towards the island object until it touches the island (not get beached).
5. The camera should be above the island looking down to verify that the boat touches the island.
Attached Files
File Type: a2w Recursive Sailing.a2w (227.3 KB, 6 views)
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 11-30-2012, 10:10 AM

The reason why it didn't stop when it got to the island is because you were telling the boat to stop when it's coordinates where less than 1 meter away from the coordinates of the island's palm tree, and that never happened.

If you look at the program that I attached, I changed it so that the "my first method" function first turns the boat to face the island (which was one of the questions), and then recursively calls your method to make the sailboat move forward (I made the animation more fluid by making it move "abruptly"). I also changed the distance that it checks to 15 meters, not 1. This will make the boat stop 15 meters away from the coordinates of the island, which makes it stop exactly where you need it too, just touching the beach. The only thing that I didn't fix is the last part. I kept your code in there to just take a good look at the island, but what you're really supposed to do is set the camera to be above the island, looking down. This is easy camera code and you can do it in 2 steps.
Attached Files
File Type: a2w Recursive Sailing (1).a2w (219.8 KB, 12 views)


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