Need help with basketball game.

Game Editor comments and discussion.

Need help with basketball game.

Postby 4erv' » Sat May 24, 2008 5:26 pm

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:
Attachments
ex.JPG
example
Gold Basketball 2008 - the first basketball game made with game editor.

User avatar
4erv'
 
Posts: 188
Joined: Sat Jul 07, 2007 10:52 am
Location: in Recycle Bin
Score: 10 Give a positive score

Re: Need help with basketball game.

Postby DST » Sat Jun 07, 2008 5:30 am

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.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Need help with basketball game.

Postby 4erv' » Mon Jun 09, 2008 9:18 pm

Thanks DST! :D
Just 1 problem:
everytime the ball reaches the end, error apears:
ball -> Collision(Any side of point), line1: READ attempted beyond allowed access area
is there any solution? :mrgreen:
Gold Basketball 2008 - the first basketball game made with game editor.

User avatar
4erv'
 
Posts: 188
Joined: Sat Jul 07, 2007 10:52 am
Location: in Recycle Bin
Score: 10 Give a positive score

Re: Need help with basketball game.

Postby DST » Tue Jun 10, 2008 3:11 am

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.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Need help with basketball game.

Postby 4erv' » Tue Jun 10, 2008 11:30 am

Thanks again! :D
It works perfect.
Gold Basketball 2008 - the first basketball game made with game editor.

User avatar
4erv'
 
Posts: 188
Joined: Sat Jul 07, 2007 10:52 am
Location: in Recycle Bin
Score: 10 Give a positive score

Re: Need help with basketball game.

Postby DST » Tue Jun 10, 2008 1:35 pm

:D
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron