![]() |
How to make a game work?
Hi, so i am making a game where a guy kicks a football through a goal post, my question is how can i make the football fly to different parts of the world like miss the goal post depending on when the user clicks a button, also how do i make a power meter for the kick power? I need the power meeter jump back and fourth and depending when the user clicks a button it determines the power and kicks at it and that determines the flight of the football....
I need some help to accomplish this. Thank You |
You'd need a variable which determines how much power the kick has, and a loop which keeps making the direction of the ball and the power of the kick vary with time.
Go ahead and show me what YOU think the code would look like. I'll help you along from there. |
how do you make a vehicle? i just have a football object
|
Vehicles are in the vehicles section of the objects gallery.
Or did you mean 'variable?' |
lol i dont know why i said vehice, i think i was reading a different post and replied to this one.
anyways, what would you suggest to do to make the football fly based on when the user presses a button. I was thinking of making the arrows turn the kicker to get the angle and then a power meter so when the user presses a button depending on what power it is at it kicks the ball. Not quite sure how to do that in Alice, all the help would be appreciated. So maybe for the power of the kick i can make the guys foot bend back and forth somehow on a loop, but i' am not sure how that would generate me a number for the force of the kick. |
It wouldn't. You'd need to make your own number generation which moves at the same time as the football player's leg and goes up until it hits max power, then starts decrementing until it hits zero, and repeats.
|
how can i make the 3d text display the number that is being randomly generated, then i need it to stop the generation once the button is pressed
|
You could have two variables, one being randomNumber, the other is buttonPressed. Then 3d Text as an object
Create a method called "Button" somewhere, then you could have an event saying when button is pressed, do "Button". In that method make buttonPressed == 0. Then in another method you create, you can do If "buttonPressed == 0" do nothing / Else do 3d Text set text to ("randomNumber" as a String) (you get the "as a string" from the functions tab of World). I kinda lost my train of thought here, but so far it sounds like that should work. EDIT: Oh ya and you would have to make the if/else statement in a continuous loop, or in a while(true), or as a "While world is running" event in the event box. |
k got that, i got the 3d text looping infinitely, now i need to stop it when space is pressed?
|
Did you do the Button method that I said? Where it changes variable, and in your method where you have the if/else you make sure if variable is 2, then do nothing.
You can do in event box When space button is pressed, do Button (the method). |
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 ?
|
I don't know what you mean, but if post the world I can see if I can help with what you want it to do.
|
1 Attachment(s)
ok i think i got the count up and down figured out.
how do i get rid of the decimal ?[ATTACH]2063[/ATTACH] I need to be able to start and stop it when space is hit... |
I don't think you can get rid of the decimal, one of the bugs of Alice.
|
yeah that counter the way i did it it doesn't work like i need it to. I cant stop it.
|
well post the world then and I will see whats wrong
|
i did post it... its few posts up.... just blends in with my post.
|
1 Attachment(s)
Ok here I made this version right now. To make it so that you can press the spacebar and it stops the number right then, I had to make an if/else for every number 1-10 going up, and 1-10 going down. You can see the method when you open the world.
|
Thank you, wow that's a lot of code for a simple thing.
Is there a way to store the Power Value in a variable ? so i can use it... right now it is stored in the two variables... |
1 Attachment(s)
Ya, you would just add to each of the if/else statement to set power# to either powerUp or powerDown. I'll do it for you. When you make your football version, make sure not to have the wold.spacebar method have an else statement. Only have it make spacebar == true. Then in a later method, after the football has been kicked and it reappears but before you reinitialize the numberChange method, then in that method at the end do spacebar == false.
Oh and in the future, you can upload the worlds through a reply to this thread like I have below by, when in the reply part, and after you have written what you want to say, scroll down to where a button says "Manage Attachments". Click that, and then click "Choose File" and choose where your file is, and click it. Then press "Upload" on the right and it should upload to your reply! EDIT: Post 123, lol |
1 Attachment(s)
Ok here is what i got so far, if you have improvements for me please let me know!
|
Pretty good! The only thing i dislike is the score at the end. See if it is possible to calculate if each punt went in or not. Not sure how you would get around doing that. Also, if you don't want to do that, try and make it so you must pass a certain score to win. Just suggestions.:D
|
yeah i wad thinking that too, i didn't have enough time to implement any additions.
|
All times are GMT -5. The time now is 11:49 AM. |
Copyright ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.