scripting question

Game Editor comments and discussion.

scripting question

Postby vertex78 » Tue May 29, 2007 3:13 am

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?
vertex78
 
Posts: 1
Joined: Tue May 29, 2007 2:11 am
Score: 0 Give a positive score

Postby pixelpoop » Tue May 29, 2007 7:37 am

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.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby d-soldier » Tue May 29, 2007 7:54 am

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.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron