Page 1 of 1

scripting question

PostPosted: Tue May 29, 2007 3:13 am
by vertex78
I am new to this program and I am trying to make the ever popular pong game to break me in. I am setting it up with a paddle on top that the ai will control and a paddle on bottom that the player controls with the mouse. I have the mouse movement set up fine and the ball movement setup fine, but I am having trouble with a simple script statement that seems should work for moving the top paddle. I figure for the top paddle I will keep it simple until I have basic movement being controlled with script. So all I am trying to do is match the top paddle's xpos with the ball's xpos. So here is what I did

Code: Select all
right clicked top paddle
actor control
add event
create actor
add action
script editor

x = ball.x;

ok
immediate action
close

I thought this would set the paddles xposition to the balls xposition but it does not.

Any help?

PostPosted: Tue May 29, 2007 7:37 am
by pixelpoop
It looks like you put the script on the create actor event. This means the code only executes when the actor is created. You should have it on the draw actor event, this will make the script execute every frame.

PostPosted: Tue May 29, 2007 7:54 am
by d-soldier
Yep, use it on the draw actor event... Or you could use a draw-actor event, move-to ball (set only on the x-axis) and play with the velocity setting to make the computer player easier or more difficult to beat.