Rand x,y

Non-platform specific questions.

Rand x,y

Postby arcreamer » Sat Sep 01, 2007 4:53 am

im working on a game and when the ball hits the player i want the ball to go flying up on the x and y axis but i want the x and y to be rand so it will go anywhere up... how would i do that??
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Re: Rand x,y

Postby pixelpoop » Sat Sep 01, 2007 7:08 am

to use random use rand(number).
so x=rand(3);
this can make x equal 0, 1, or 2

If your game is topdown I would recomend using direction with directional velocity.
angle=rand(360);
Last edited by pixelpoop on Sun Sep 02, 2007 2:51 am, edited 1 time in total.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Re: Rand x,y

Postby arcreamer » Sat Sep 01, 2007 1:04 pm

ok ill try that thanks!
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Re: Rand x,y

Postby arcreamer » Sun Sep 02, 2007 1:01 am

what i want to do is have it so when a ball hits the player the ball goes in any direction just as long as it goes up how would i do that?
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Re: Rand x,y

Postby pixelpoop » Sun Sep 02, 2007 2:29 am

is the camera looking straight down? so the ball goes up towards the camera and a little off to the side?
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Re: Rand x,y

Postby arcreamer » Sun Sep 02, 2007 2:38 am

ill give u a scrn...
Attachments
scrnshot.jpg
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Re: Rand x,y

Postby pixelpoop » Sun Sep 02, 2007 2:51 am

So what I think you need is an extra animation of the ball getting bigger. So when the ball collides with the player the ball looks like it is rising towards the camera, then reverse that animation so it looks like it is falling back towards the ground. When it collides with the player you want a collision event that sets the directional_velocity, and angle.
directional_velocity=3;
angle=rand(360);

oooooops... I just realized I told you to set the direction is a previous post, but I should have told you to set the angle. Direction is read only. I will go back and edit my post.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Re: Rand x,y

Postby arcreamer » Sun Sep 02, 2007 3:28 am

nevermind i got everything working right
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest