Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Old
infowire
Guest
 
Status:
Posts: n/a
Default 12-07-2009, 10:25 PM

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.

Last edited by infowire; 12-07-2009 at 10:44 PM.
   
Reply With Quote
Old
infowire
Guest
 
Status:
Posts: n/a
Default 12-08-2009, 12:50 AM

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.


test.a2w
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 12-08-2009, 02:18 PM

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?
   
Reply With Quote
Old
infowire
Guest
 
Status:
Posts: n/a
Default 12-08-2009, 04:06 PM

yeah prob 1 - 10 makes more sense
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 12-09-2009, 10:12 AM

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.

Last edited by Dameria; 12-09-2009 at 10:21 AM.
   
Reply With Quote
Old
infowire
Guest
 
Status:
Posts: n/a
Default 12-09-2009, 01:06 PM

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.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 12-09-2009, 01:26 PM

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!
   
Reply With Quote
Old
infowire
Guest
 
Status:
Posts: n/a
Default 12-09-2009, 03:12 PM

ok i will remake the world tomorrow, how would i go about making the counter variable go 1 - 10 and then 10 - 1 ?
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 12-09-2009, 03:54 PM

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.
   
Reply With Quote
Old
infowire
Guest
 
Status:
Posts: n/a
Default 12-11-2009, 01:36 PM

How do you do >10 and not 1 ?
   
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.