bobo cent

bobo cent

  • NA
  • 1
  • 0

Space Invaders Project

Nov 19 2009 3:24 PM
Hi iam doing a project for my games class which is to produce a space invaders game (a very basic one) for C# in a windows form. My one problem is that i cant quite get how to make the alien move to the end of the row and then move down,then move to the left, then move down,etc. My code so far for this part is this, which makes the alien go along then down, left but then goes back up and starts again. How can i change my code to make it move as it is supposed to? bear in mind it has to be very basic coding or else my lecturer may start to wonder how i know these advance codes.


int speed = 1, playerx = 253, playery = 460, bulletx = 253, bullety = 460, alienx = 0, alieny = 0;
        double score = 0;
        bool fire = false;



        private void tmrgo_Tick(object sender, EventArgs e)
        {
            if (alienx <= 500 && alieny <= 0)
            {
                alienx += 5;
                alieny = 0;
                hit();
            }

            if (alienx >= 500 && alieny <= 50)
            {
                alieny += 5;
                alienx = 500;
                hit();
            }

            if (alienx >= 0 && alieny >= 50)
                alienx -= 5;
            hit();


            if (alienx <= 0 && alieny <= 50)
                alieny -= 5;
            hit();

            if (alienx <= 0 && alieny <= 0)
            {
                speed += 5;
                hit();
            }
            if (speed >= 500)
                speed = 9;
            hit();



            picalien.Location = new Point(alienx, alieny);

        }

Answers (1)