Need help with basketball game.

Posted:
Sat May 24, 2008 5:26 pm
by 4erv'
Hello everyone,
I need help with making a basketball game.
The instructions are simple: You set the points and when You press Enter (or somethiing else) the ball start moving, and moves along the points.But I can't make the ball to move from 1 point to second.
Here's the example:
Re: Need help with basketball game.

Posted:
Sat Jun 07, 2008 5:30 am
by DST
Use collision, cloneindex, and array.
make all points clones of point, then reference ball's xy from the clones.
Use an array: integer, global, Size = max# of points.
make two of them, pointx, and pointy.
On point>createactor or on mousebutton up (if you can drag them after placing them)
pointx[cloneindex]=x;
pointy[cloneindex]=y;
and on ball>collision with point
angle=direction(x, y, pointx[collide.cloneindex+1], pointy[collide.cloneindex+1]);
Now ball will always go for the next point's xy from the one its touching.
Re: Need help with basketball game.

Posted:
Mon Jun 09, 2008 9:18 pm
by 4erv'
Thanks DST!
Just 1 problem:
everytime the ball reaches the end, error apears:
ball -> Collision(Any side of point), line1: READ attempted beyond allowed access areais there any solution?

Re: Need help with basketball game.

Posted:
Tue Jun 10, 2008 3:11 am
by DST
oh sorry i forgot about that array overflow thing.
so add an array end and some gravity to the ball after hitting the last point, like this;
if (collide.cloneindex<ActorCount("point")-1){do the cloneindex array angle thing;}
else if (collide.cloneindex==ActorCount("point")-1){yvelocity+=gravity;}
Or something like that.
You could also have in the ball's draw actor
y+=gravity; and set gravity to 0 on start.
Then on that else if thing, just set gravity to 1. Now the ball would fall from the last point toward the basket(if they're any good) or to the floor if not, and the increasing yvelocity will change its angle from there on.
Hope it helps!
ps. i had to add the -1 to the actorcount because of course the first actor is 0, yet its count in actorcount would be 1, and you'd still have the overflow.