Ejemplo n.º 1
0
 public DespawnApple(int x, int y, int millisecondsLife, CoreForm form) : base(x, y, form)
 {
     mainForm = form;
     // make the timer run end of life event (to delete apple)
     lifeTimer.Elapsed += new ElapsedEventHandler(EndLife);
     lifeTimer.Interval = millisecondsLife; // set interval to lifetime
 }
Ejemplo n.º 2
0
 public void Setup(PictureBox picBox, CoreForm form, int speed)
 {
     picBox.Size = new System.Drawing.Size(BodyPart.SIZE, BodyPart.SIZE);
     // moar setup here
     mainForm    = form;
     this.picBox = picBox;
     velocityMag = speed;
 }
Ejemplo n.º 3
0
 public Boss(PictureBox picBox, int interval, int lifetime, CoreForm form) // angle is average of all projectile velocity angles, interval is time between spawns
 {
     TargetTime      = interval;
     mainForm        = form;
     projectileLife  = lifetime;
     picBox.Image    = Properties.Resources.boss;
     picBox.SizeMode = PictureBoxSizeMode.StretchImage;
     this.picBox     = picBox;
 }
Ejemplo n.º 4
0
 public MysteryBoxSpawnPad(PictureBox pic, double probability, CoreForm form) // probability will be given in percents
 {
     picBox = pic;
     Bounds = picBox.Bounds;
     // make the picBox transparent
     picBox.Visible = false;
     this.engine    = form.engine;
     // get the probability based on probability density
     this.probability = probability;
 }
Ejemplo n.º 5
0
 public Apple(PictureBox pic, CoreForm form) : base(form)
 {
     Change = BodyPart.SIZE / 2; // size change when snake eats apple
     // setup the picturebox
     pic.Size     = new Size(BodyPart.SIZE, BodyPart.SIZE);
     pic.Image    = IMAGE;
     pic.SizeMode = PictureBoxSizeMode.StretchImage;
     // set picBox in food object
     picBox = pic;
 }
Ejemplo n.º 6
0
        public void Setup(PictureBox picBox, CoreForm form) // generic setup for this object
        {
            mainForm        = form;
            this.picBox     = picBox;
            picBox.SizeMode = PictureBoxSizeMode.StretchImage;
            picBox.Size     = new System.Drawing.Size(BodyPart.SIZE, BodyPart.SIZE);

            // load image into picturebox
            picBox.Image = Properties.Resources.question_mark;
        }
Ejemplo n.º 7
0
        public MysteryBox(int x, int y, CoreForm form)
        {
            PictureBox picBox = new PictureBox
            {
                Location = new System.Drawing.Point(x, y)
            };

            form.Controls.Add(picBox);
            Setup(picBox, form);
        }
Ejemplo n.º 8
0
        public EnemyFollower(int x, int y, int speed, CoreForm form)
        {
            PictureBox picBox = new PictureBox
            {
                Location = new System.Drawing.Point(x, y),
                SizeMode = PictureBoxSizeMode.StretchImage
            };

            // add it to the form
            form.Controls.Add(picBox);
            Setup(picBox, form, speed);
        }
Ejemplo n.º 9
0
        // temporary constructor
        public ContinuousSnake(int x, int y, CoreForm _mainForm, Vector _velocity, double size, bool red = false)
        {
            // assign all variables
            this.Size     = (int)size;
            this.mainForm = _mainForm;
            this.red      = red;
            // find angle to build the body in rads
            double angle = _velocity.Degrees * Math.PI / 180 + Math.PI; // add PI radians to flip the angle around

            // since the build must occur in opposite direction of velocity
            int[]       coords  = new int[] { x, y };                                         // coords in proper form to be used
            BodySegment segment = new BodySegment(0, 0, coords, _velocity.Clone(), mainForm); // set size to zero for now
            int         dx      = (int)(BodyPart.SIZE * size * Math.Cos(angle));              // get change in each direction for the new size
            int         dy      = (int)(BodyPart.SIZE * size * Math.Sin(angle));              // add negative because coords are reversed on screen

            // whichever is zero will be default width
            if (dx == 0)
            {
                dx = BodyPart.SIZE;
            }
            else
            {
                dy = BodyPart.SIZE;
            }
            segment.grow(dx, dy);
            if (_velocity.Degrees == 180 || _velocity.Degrees == 90) // make the snake head at proper coords
            {
                snakeHead = new BodyPart(segment.X, segment.Y, _velocity.Clone(), mainForm);
            }
            else if (_velocity.Degrees == 0)
            {
                snakeHead = new BodyPart((int)(segment.X + BodyPart.SIZE * size - BodyPart.SIZE), segment.Y, _velocity.Clone(), mainForm);
            }
            else if (_velocity.Degrees == 0)
            {
                snakeHead = new BodyPart(segment.X, (int)(segment.Y + BodyPart.SIZE * size - BodyPart.SIZE), _velocity.Clone(), mainForm);
            }
            FixHead(); // fix head orientation based on velocity
            // add the segment to the bodySegments list to keep track of it
            bodySegments.Add(segment);
            // set the timer event for preventing too fast player responses
            interval.Elapsed += new ElapsedEventHandler(intervalFunc);

            // do the red colour thing
            if (red)
            {
                // make the segment red if the red flag is set
                bodySegments[0].picBox.BackColor = Color.Red;
                bodySegments[0].picBox.Image     = null;
            }
        }
Ejemplo n.º 10
0
 public EnemyStationary(PictureBox picBox, int threshold, CoreForm form, Image img = null) // optional image to set for picBox
 {
     // assign internal vars for later use
     Bounds         = picBox;
     this.threshold = threshold;
     this.form      = form;
     // if image parameter was inputted, change the picturebox image to the inputted image
     if (img != null)
     {
         Bounds.Image = img;
     }
     // make animation display for a second (until enemy image returns to normal)
     animaTimer.Interval = 1000;
     animaTimer.Tick    += new EventHandler(resetImage);// set event for timer to reset image
 }
Ejemplo n.º 11
0
        public Projectile(PictureBox picBox, Vector velocity, int lifetime, CoreForm form)
        {
            picBox.Size     = new System.Drawing.Size(BodyPart.SIZE, BodyPart.SIZE);
            picBox.Image    = Properties.Resources.projectile;
            picBox.SizeMode = PictureBoxSizeMode.StretchImage;
            // above sets up the image for the projectile
            this.picBox   = picBox;
            mainForm      = form;
            this.velocity = velocity;

            // setup life timer to end life when inputted lifetime is over
            lifeTimer          = new Timer();
            lifeTimer.Interval = lifetime;
            lifeTimer.Tick    += new EventHandler(endLifeTick);
            lifeTimer.Start();
        }
Ejemplo n.º 12
0
 public BodySegment(int width, int height, int[] coords, Vector velocity, CoreForm form)
 {
     picBox = new PictureBox // new picture box for the visual part of this segment
     {
         Name     = "picBox",
         Size     = new Size(width, height),
         Location = new Point(coords[0], coords[1]),
         Image    = BodyPart.DEFAULT_IMAGE
     };
     picBox.SizeMode = PictureBoxSizeMode.StretchImage;                                       // make the picture scale the image
     form.Controls.Add(picBox);                                                               // add it to the form
     Bounds        = new Rectangle(new Point(coords[0], coords[1]), new Size(width, height)); // create the rectangle for collisions
     this.velocity = velocity;                                                                // save the velocity
     mainForm      = form;                                                                    // save the form for later
     mainForm.Controls.SetChildIndex(picBox, 20);                                             // set proper z order
 }
Ejemplo n.º 13
0
 public Apple(int x, int y, CoreForm form) : base(form)
 {
     // set size change when eaten by snake
     Change = BodyPart.SIZE / 2;
     // make picture box for the apple
     picBox = new PictureBox
     {
         Name     = "picBox",
         Size     = new Size(BodyPart.DEFAULT_SIZE, BodyPart.DEFAULT_SIZE),
         Location = new Point(x, y),
         Image    = IMAGE,
         SizeMode = PictureBoxSizeMode.StretchImage // make the image fit the picturebox
     };
     // add the image
     form.Controls.Add(picBox);
     form.Controls.SetChildIndex(picBox, 0);
     picBox.SendToBack();
 }
 public DespawnAppleSpawnPad(PictureBox picBox, double probability, int minLife, int maxLife, CoreForm form) : base(picBox, probability, form.engine)
 {
     mainForm     = form;
     this.minLife = minLife;
     this.maxLife = maxLife;
 }
Ejemplo n.º 15
0
 public MysteryBoxEngine(CoreForm form) : base(form)
 {
 }
Ejemplo n.º 16
0
 public MysteryBox(PictureBox picBox, CoreForm form)
 {
     Setup(picBox, form);
 }
Ejemplo n.º 17
0
 // constructor must take the custom form
 public GameEngine(CoreForm form)
 {
     mainForm = form;
 }
Ejemplo n.º 18
0
 public EnemyFollower(PictureBox picBox, int speed, CoreForm form)
 {
     Setup(picBox, form, speed);
 }