![]() |
how can i make a variable gradually increase to a certain number? I need the football to get kicked of the ground and rise to the goal post.
Also how can i reset an object to its starting position ? ex: the football needs to come back for another kick ( 3 kicks total, count score) PS I appreciate all your help, i have learned a lot today. |
1 Attachment(s)
Ok, i'am attaching what i got so far, i need the ball to miss if the power is bellow 5, but it doesn't seem to read my RandomNumber variable.
[ATTACH]2001[/ATTACH] |
Ok I can see your program now. First of all, do you want it to be random numbers, or do you want it to count 1 through 10, and then go down 10 to 1, and keep going in a loop like that until the spacebar is pressed?
|
yeah prob 1 - 10 makes more sense
|
Ok I am working on it now again. The problem with your program is that you made the RandomNumber variable inside of your method. That means that whenever your method ends, it gets rid of the variable that it assigned. The RandomNumber variable should be a world variable, accessible by every method in the program. I will fix this, and I will also add the 1-10 scale if I can. I'll post it when it is done.
EDIT: Wow, I'm sorry but you are going to have to remake this world or something because I just cannot get rid of that RandomNumber variable. Whenever I try to get rid of it, it just produces an error and won't let me do anything else. Can you try doing everything you did before you made that RandomNumber variable? And from now now only create variables in objects, not methods. |
yeah, i couldn't delete it either. it a bug in Alice i think. I made RandomNumbers a variable in World as well. but i guess it is not using it.
|
only create variables in a method when you are only going to use them in that method, because as soon as the method ends, the variable is erased (hence why your football always goes to the same place, the variable gets set back to 1 always.)
EDIT: Woot, this is my 100th post! |
ok i will remake the world tomorrow, how would i go about making the counter variable go 1 - 10 and then 10 - 1 ?
|
I have an idea on that, about making a variable numberUp and numberDown, and then (if numberUp < 10 and not 1), add 1. (If number == 10), set number up to 1, and subtract 1 from numberDown(which is at 10) and so on the other way.
It would be in an infinite if/else statement, and each time a numberUp or numberDown is changed, it would set that number as a different integer, numberDisplay, which would display it to the world in the text. Oh, and make sure that you are using the latest version of Alice 2.2 (the one made on August 1, 2009). If you are not using that, I would suggest downloading it and using that from now on. |
How do you do >10 and not 1 ?
|
All times are GMT -5. The time now is 10:14 AM. |
Copyright ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.