Hi,
I am working on making a basketball game in scratch. I want to make it so that one sprite can pick up the basketball when it is rolling around. I also want to make it so that if the basketball is touching the top of the net, it will slide through. Would anyone be able to help me with that?
Offline
You would set it's (the ball's) x and y axis based off the holders position with an offset.
when gf clicked forever if <(player_holding_ball)= (1)> go to x: <<(x position v) of (player v)> + (25)> y: <<(y position v) of (player v)> - (25)>So you can setup some script for setting when sprite 1 has the ball you set the variable "player_holding_ball" to 1, then the script above will run.
Offline
Write it so its in forever if, then touching player, then go to player.
Offline
crushed377 wrote:
Write it so its in forever if, then touching player, then go to player.
forever if <touching? [Player v]> go to [player v]Actually, is you're using what the first responder said, you should just have this:
when gf clicked forever if < (holding?) = [yes] > go to x: < [x position v] of [player v] > y: < [y position v] of [player v] >You of course add an offset like the first responder showed, and then:
when gf clicked forever if <touching? [player v] > set [holding? v] to [yes] else set [holding? v] to [no]Regards,
Offline
mrdance62 wrote:
Thanks, but I'm having a problem. When I jump, I let go of the ball. How can I program it to stay in the players hands when I jump.
Hmm... using the above scripts should keep it there regardless, could you post your scripts or at least the scripts that pertain to the holding and jumping?
And, no problem.
Regards,
CAA14
Offline
This is my script for holding:
[scratchblocks]
when gf clicked
forever
if touching <player>
go to x: x position of sprite + 25 y: y position of sprite
end
My script for making me jump is:
When up arrow key pressed
Change y by 100
Offline
mrdance62 wrote:
This is my script for holding:
when gf clicked forever if touching <player> go to x: x position of sprite + 25 y: y position of sprite endMy script for making me jump is:
When up arrow key pressed
Change y by 100
Okay, try putting another forever loop in it, like this:
when gf clicked forever if < touching? [player v] > forever go to x: <[x position v] of [player v]> y: (<[y position v] of [player v]> + [25]) end end endAlso, You need to have your jumping script go down 100 after a certain amount of time. Are you doing this?
Last edited by CAA14 (2013-04-17 19:17:39)
Offline
I tried that script, when I jump its okay. However, when I try to shoot the ball, it just comes right back at me. I will try to do something like this:
[/scratchblocks]
when gf clicked
forever
if (touching <ball>)
forever if (touching <ball>)
go to x position of ball + 25 y position of ball
Offline
mrdance62 wrote:
I tried that script, when I jump its okay. However, when I try to shoot the ball, it just comes right back at me. I will try to do something like this:
[/scratchblocks]
when gf clicked
forever
if (touching <ball>)
forever if (touching <ball>)
go to x position of ball + 25 y position of ball
Actually, that didn't work. Maybe I can try something like this for the ball script:
when gf clicked forever wait until (touching <player 1>) if (touching <player 1>) forever go to (<x position> of <player 1> <y position> of <player 1> end
Offline
mrdance62 wrote:
mrdance62 wrote:
I tried that script, when I jump its okay. However, when I try to shoot the ball, it just comes right back at me. I will try to do something like this:
[/scratchblocks]
when gf clicked
forever
if (touching <ball>)
forever if (touching <ball>)
go to x position of ball + 25 y position of ballActually, that didn't work. Maybe I can try something like this for the ball script:
when gf clicked forever wait until <touching [player1 v] ?> if <touching [player 1 v]?> forever go to x: ([x position v] of [player 1 v]) y: ([y position v] of [player 1 v]) end
Fixed
With regards
~7734f
Offline
Ok, I did this script for the ball:
when gf clicked forever if (touching <player 1>) repeat until (key <space> pressed) or (touching <player 2> go to x position of player 1 + 25 and y position of player 1 end endOne problem, MY GRAVITY IS NOT WORKING! This is just problem after problem after problem. Here is my script for gravity:
when gf clicked if <not (touching color <ground>)> change y by [-4] end end [/scratchhblocks]
Offline
mrdance62 wrote:
Ok, I did this script for the ball:
when gf clicked forever if (touching <player 1>) repeat until (key <space> pressed) or (touching <player 2> go to x position of player 1 + 25 and y position of player 1 end endOne problem, MY GRAVITY IS NOT WORKING! This is just problem after problem after problem. Here is my script for gravity:when gf clicked forever if <not<touching? [ground v]>> change y by [-4] end end
What is wrong with the gravity? My guess is that its going below that ground, right?
Also, about your script for the ball, It should work fine, what's happening wrong?
Regards,
CAA14
Last edited by CAA14 (2013-04-20 21:47:52)
Offline
Actually, I have resolved all of the problems. Thank you all, including CAA14, and everyone for helping me out. I am thankful for experienced scratchers who are willing to pass their knowledge down to one who is a rookie. I will upload my game shortly, and it will go out to all of you. Thank you again.
Offline
mrdance62 wrote:
Actually, I have resolved all of the problems. Thank you all, including CAA14, and everyone for helping me out. I am thankful for experienced scratchers who are willing to pass their knowledge down to one who is a rookie. I will upload my game shortly, and it will go out to all of you. Thank you again.
That's great, and no problem. Actually, i just started in January of this year, so i am just steadily learning.
Looking forward to playing your game.
Regards,
CAA14
Offline
CAA14 wrote:
mrdance62 wrote:
Actually, I have resolved all of the problems. Thank you all, including CAA14, and everyone for helping me out. I am thankful for experienced scratchers who are willing to pass their knowledge down to one who is a rookie. I will upload my game shortly, and it will go out to all of you. Thank you again.
That's great, and no problem. Actually, i just started in January of this year, so i am just steadily learning.
Looking forward to playing your game.
Regards,
CAA14
Should be up in a few days, CAA14. just have to make the finishing touches!
Offline