Welcome to Phrogram Sign in | Join | Help


Re: How do the enemies in "Planes" work?

  •  11-09-2006, 9:09 PM

    Re: How do the enemies in "Planes" work?

    Here is an example of how to move targets from Right to left

    Hope this helps, Keep at it your doing great

      

    Program MoveTargetsExample

         

          Define Tlist As SpriteList

         

          Method Main()

     

                CreateTargets(20)

               

                While Not IsKeyDown("Escape")

               

                      MoveTargets(Tlist)

                End While

     

          End Method

     

          Method MoveTargets(Targets As SpriteList)      

               

                Define I As Integer

                // loop through the Target List and move each target

                For i = 1 To Tlist.Count

                      //Ramdomly pick target to move

                      If Random(1,2) = 1 Then

                            // Move targets a random amount each time,

                            // multiple the X axis by -1 To make it a negitive number so that it

                            // moves to the left

                            Tlist.Item(i).MoveTo( Tlist.Item(i).X + Random(1,2) * -1, Tlist.Item(i).Y)       

                      End If     

                      delay(.9)

                Next 

               

          End Method

     

          Method PositionTarget( Target As Sprite)

               

                Target.MoveTo( 460, Random( 50, ScreenHeight() - 50 ) )

               

          End Method

     

          Method CreateTargets( NumberOfTargets As Integer )

               

                Define I As Integer

                For i = 1 To NumberOfTargets

                      Define target As Sprite = LoadSprite( "Target" + I, "car1.gif" )

                      target.Visible = True

                      target.FlipHorizontal()

                      PositionTarget( target )

                      Tlist.Add( target )

                Next

               

          End Method

         

    End Program

    Thanks for the question, keep at it and have fun

    Filed under: , ,
View Complete Thread