I presume you are not using a control array since you just started, so I'll keep this down to the very basics. Put the following line in the Declarations portion of your code (at the top): dim AlienLeft as boolean This will control whether your aliens are moving left or right. Next, put a timer on your form. This will control the movement of your aliens. Under its properties, set it's interval to 250 (about a quarter of a second). Double click on the timer. Under the code window that pops up, put the following: if AlienLeft then 'This will detect if they are 'supposed to be moving left or not if Alien1.left <= 480 then 'Change "Alien1" to the name of your 'leftmost alien. This will detect if they 'need to start moving the other way or 'not. AlienLeft = False 'Tell the code that they need to move the 'other way. else 'If they still have room to move... Alien1.left = Alien1.left-360 'Moves the alien left 360 units. 'Copy this line and change "Alien1" 'to the name of each of your 'aliens. End If else 'If the aliens are supposed to be moving right... if (Alien10.left + Alien10.width) >= (form.width - 480) then 'Change "Alien10" to the name of your rightmost alien. This 'line detects if the aliens need to switch directions again. AlienLeft = True 'tell the code to start moving the aliens left. else 'if they still have room to move... Alien1.left = Alien1.left+360 'Move the aliens right 360 units. 'Copy this line and change "Alien1" 'to the name of each of your 'aliens. end if end if
This code is very rudimentary, and the numbers are probably off from what you want, but you can adjust them until you get there. If you need any other help, I'm glad to be of service when I can.
|