Alice Community  

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

Reply
 
Thread Tools Display Modes
Variables
Old
Scott
Guest
 
Status:
Posts: n/a
Default Variables - 09-25-2008, 07:07 PM

Hey,

I am taking Computer Science at school and we are using Alice. Recently I have been working ahead and know a bit more stuff than we have learned. Yet the one thing I do not understand is variables. I read over and over the part where you learn it in the book in the classroom and tried it but couldn't get it to do what I wanted.

Let me say that I am making a game. You are a guy in a Beach Chair and you go around and hit chickens and get 100 points. I have the chair as the guys vehicle and the chair the camera's vehicle so they are all synced. I have 3 chickens in the level so far that go in circles. And as of now The guy goes right through the chickens.

First question I have is how do I make it as when the Chair hits a chicken, the chicken falls and gives you 100 points. I tried for a half hour but couldn't get it to work. I know I need to use the IF thing, and I know what to do, just don't know how to put it down. I want it to be like "If Beach Chair hits chicken, make Chicken Fall". Next part of this question is how do I get this to work when there are more than 1 chicken. There will many many many chickens, like maybe up to 30 or 40. How do I set it to get to hit any chicken for this IF statement to work. Because it lists the chickens as Chicken 1, Chicken 2, and so on. And I don't think making 40 IF statements is necessary.

Next question is how do I get a score system. I know how to get text and position it in the left corner of the screen, but how do I get the score to change up 100 points when you hit a chicken.

I have the file attached and would like to hear back from someone on how to do this. I have only been in this class for 4 weeks. And I do not mind anyone to do what I need to my file and re attach it. I would really really appreciate it if you did because I can learn best seeing it like that.
Attached Files
File Type: a2w 7 Chair Game.a2w (762.0 KB, 59 views)
   
Reply With Quote
Old
Chris101b
Senior Member
 
Chris101b's Avatar
 
Status: Offline
Posts: 361
Join Date: Jun 2007
Default 09-26-2008, 12:18 AM

Well, since no one else has said anything, ill try to help in the best way I can. I know how to make the chickens move down when the chair runs them over but am unsure of how to do scores. And unfortunately, my way of doing it involves making a function for every chicken in your world. Attached is the modified version I did. To do this, click on the button on the main screen at the top that says "Create New Event". Now click on "While Something is True". Now click on the chair and then go to the functions bar on the left and drag the "chair is within threshold" box up into the "While" Section of the event you just made. Now set it to 1 meter and then set it to chicken 1. Now notice how right below that it says:

Begin:
During:
End:

Well, click on chicken 1 and drag a thing that says "chicken move down 5 meters" into the begin box. Now what this says is that when the EXACT MIDDLE of the chair is 1 meter from the EXACT MIDDLE of the chicken, the chicken will move down 5 meters. Now the reason I specify the whole EXACT MIDDLE thing is because when you say within 1 meter, it is talking about the middle of the object. If you put it on 0, and the leg of the chair touches the tail of the chicken, it wont do anything. So setting it to around 1 meter does good. Ill attach the file below. Hope this helps even a little bit.
Attached Files
File Type: a2w Chicken Redo.a2w (740.9 KB, 73 views)
   
Reply With Quote
Thanks
Old
Scott
Guest
 
Status:
Posts: n/a
Default Thanks - 09-26-2008, 08:01 PM

Thanks

Now I just need someone to help with scoring.
   
Reply With Quote
Cool.
Old
Scott
Guest
 
Status:
Posts: n/a
Default Cool. - 09-26-2008, 08:41 PM

I just tried it. Love the way you did it. I didn't think of getting it to do that in the top part. Now I have a template to get the rest of the chickens done Thanks.
   
Reply With Quote
Old
Chris101b
Senior Member
 
Chris101b's Avatar
 
Status: Offline
Posts: 361
Join Date: Jun 2007
Default 09-27-2008, 07:40 PM

Glad I could help. I have the same problem as you do. I don't understand how to make variables either even thought I read over the tutorials over and over, so I am the type of person that tries to find the easiest alternative, and this way works the best. But the only thing is that you have to do it for every chicken. You can probably find some other tutorial on how to do that somewhere in this forums.
   
Reply With Quote
Old
Scott
Guest
 
Status:
Posts: n/a
Default 09-27-2008, 10:30 PM

Yeah. This was seems to work fine enough. lol

I finished doing that for about 6 more chickens. so now i have some progress.

The book is confusing. I see a green background and so it is in the function or whatever tab but then the next part in the book is in the regular default World.MyFirstMethod.

But I don't intend to dwell on Alice stuff THAT much since this class is about Java and we are using Alice to start. But it all will help though later on I guess.
   
Reply With Quote
Reply

Tags
car, chicken, guy, problem, variable

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.