Hi,
Some of you may know that I am making a basketball game. I am trying to make the cpu player go for the basketball. I tried doing this.
[scratchblocks]
when gf clicked
forever
point in direction <sprite 1>
move <10> steps
end
The problem is that it starts to go in the air and keeps spinning around. What should I do to program the cpu player to follow the ball while staying on the ground?
Offline
Hmmm.... Well, for one, i am assuming that this game is a side-view game? Meaning you are looking at the side of the players, not the top? If so, then you need to go to the left of the name of your cpu and click the "<->" button, this will keep it from spinning.
Next, i need to know something, can the cpu jump? Other than throwing the ball? If not, then just say this:
when i receive [gameStart v] repeat until < < (gameOver?) = [yes] > or < (holdingBall?) = [yes] > > if < ([x position v] of [ball v]) < (x position)> change x by [-3] else change x by [3]This is of course, without any velocity, but that should work as long as the cpu is always at the same y position. Also, you can add any other conditional variables that you want, but the ones i added are the ones you will probably need.
Last edited by CAA14 (2013-04-17 13:42:22)
Offline
CAA14 wrote:
Hmmm.... Well, for one, i am assuming that this game is a side-view game? Meaning you are looking at the side of the players, not the top? If so, then you need to go to the left of the name of your cpu and click the "<->" button, this will keep it from spinning.
Next, i need to know something, can the cpu jump? Other than throwing the ball? If not, then just say this:when i receive [gameStart v] repeat until < < (gameOver?) = [yes] > or < (holdingBall?) = [yes] > if <([x position v] of [ball v]) > (x position)> change x by [-3] else change x by [3]This is of course, without any velocity, but that should work as long as the cpu is always at the same y position. Also, you can add any other conditional variables that you want, but the ones i added are the ones you will probably need.
Regards,
CAA14
when i receive [gameStart v] repeat until < < (gameOver?) = [yes] > or < (holdingBall?) = [yes] >> if <([x position v] of [ball v]) > (x position) > change x by [-3] else change x by [3]Fixed the scratch-blocks for you
Last edited by topazdragonlord (2013-04-17 13:40:09)
Offline
topazdragonlord wrote:
CAA14 wrote:
Hmmm.... Well, for one, i am assuming that this game is a side-view game? Meaning you are looking at the side of the players, not the top? If so, then you need to go to the left of the name of your cpu and click the "<->" button, this will keep it from spinning.
Next, i need to know something, can the cpu jump? Other than throwing the ball? If not, then just say this:when i receive [gameStart v] repeat until < < (gameOver?) = [yes] > or < (holdingBall?) = [yes] > if < [x position v] of [ball v] > (x position) > change x by [-3] else change x by [3]This is of course, without any velocity, but that should work as long as the cpu is always at the same y position. Also, you can add any other conditional variables that you want, but the ones i added are the ones you will probably need.
Regards,
CAA14when i receive [gameStart v] repeat until < < (gameOver?) = [yes] > or < (holdingBall?) = [yes] >> if < [x position v] of [ball v] > (x position) > change x by [-3] else change x by [3]Fixed the scratch-blocks for you
-topazdragonlord
Thanks, but i was editing it, check it now.
Well, it doesn't like "<"...
Regards,
CAA14
Last edited by CAA14 (2013-04-17 13:40:22)
Offline
CAA14 wrote:
topazdragonlord wrote:
CAA14 wrote:
Hmmm.... Well, for one, i am assuming that this game is a side-view game? Meaning you are looking at the side of the players, not the top? If so, then you need to go to the left of the name of your cpu and click the "<->" button, this will keep it from spinning.
Next, i need to know something, can the cpu jump? Other than throwing the ball? If not, then just say this:when i receive [gameStart v] repeat until < < (gameOver?) = [yes] > or < (holdingBall?) = [yes] > if < [x position v] of [ball v] > (x position) > change x by [-3] else change x by [3]This is of course, without any velocity, but that should work as long as the cpu is always at the same y position. Also, you can add any other conditional variables that you want, but the ones i added are the ones you will probably need.
Regards,
CAA14when i receive [gameStart v] repeat until < < (gameOver?) = [yes] > or < (holdingBall?) = [yes] >> if < [x position v] of [ball v] > (x position) > change x by [-3] else change x by [3]Fixed the scratch-blocks for you
-topazdragonlordThanks, but i was editing it, check it now.
Well, it doesn't like "<"...
Regards,
CAA14
lol - btw IU fixed the "<"
-topazdragonlord
Offline
topazdragonlord wrote:
CAA14 wrote:
topazdragonlord wrote:
when i receive [gameStart v] repeat until < < (gameOver?) = [yes] > or < (holdingBall?) = [yes] >> if < [x position v] of [ball v] > (x position) > change x by [-3] else change x by [3]Fixed the scratch-blocks for you
-topazdragonlordThanks, but i was editing it, check it now.
Well, it doesn't like "<"...
Regards,
CAA14lol - btw I fixed the "<"
-topazdragonlord
Thanks, man that is annoying when it does that.
Regards,
CAA14
Offline
CAA14 wrote:
topazdragonlord wrote:
CAA14 wrote:
Thanks, but i was editing it, check it now.
Well, it doesn't like "<"...
Regards,
CAA14lol - btw I fixed the "<"
-topazdragonlordThanks, man that is annoying when it does that.
Regards,
CAA14
Your welcome
-topazdragonlord
Offline
mrdance62 wrote:
The cpu cannot throw the ball or jump, unfortunately.
Okay, then that should work.
Regards,
CAA14
Offline