Beispiel #1
0
        public string Update(GameTime gameTime, BoatClass bc, SharkClass ss)
        {
            pe.EmitterLocation = ss.pus;

            if (gameTime.ElapsedGameTime.TotalSeconds % 15 == 0)
            {
                BLOCK_FALL_SPEED = ran.Next(2, 5);
            }
            recName = null;
            BlockSpawner(bc, gameTime);
            BlockMover(ss, bc, gameTime);

            if (itemHit == true)
            {
                ScoreShower(gameTime);
                pe.Update();
            }

            if (expIsNow == true)
            {
                AnimateBomb(gameTime);
            }

            return(recName);
        }
Beispiel #2
0
        public void BlockMover(SharkClass ss, BoatClass bc, GameTime gt)
        {
            for (int x = 0; x < blockPositions.Count; x++)
            {
                blockPositions[x] = new Vector2(blockPositions[x].X, blockPositions[x].Y + BLOCK_FALL_SPEED);
                blockRec          = new Rectangle((int)blockPositions[x].X, (int)blockPositions[x].Y, theTestRec[x].Width, theTestRec[x].Height);

                if (blockPositions[x].Y > 800 + theTestRec[x].Height)
                {
                    blockPositions.RemoveAt(x);
                    theTestRec.RemoveAt(x);
                    x--;    //sad day for the Item
                    break;
                }

                if (blockRec.Intersects(new Rectangle((int)ss.pus.X, (int)ss.pus.Y, ss.sourceRec.Width * (int)ss.scale, ss.sourceRec.Height * (int)ss.scale)))
                {
                    switch (theTestRec[x].X)
                    {
                    case 429:
                    {
                        recName  = "bomb";
                        expPos   = new Vector2(ss.pus.X - ss.sourceRec.Width * ss.scale, ss.pus.Y - ss.sourceRec.Height);
                        expIsNow = true;
                    }
                    break;

                    case 126:
                    {
                        recName = "coke";
                        itemHit = true;
                    }
                    break;

                    case 140:
                    {
                        recName = "spag";
                        itemHit = true;
                    }
                    break;

                    case 154:
                    {
                        recName = "cookie";
                        itemHit = true;
                    }
                    break;

                    default:
                        recName = null;
                        break;
                    }
                    theTestRec.RemoveAt(x);
                    blockPositions.RemoveAt(x);
                    x--;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            hc = new HeartClass();

            graphics.PreferredBackBufferHeight = 800;
            graphics.PreferredBackBufferWidth  = 1280;
            graphics.ApplyChanges();
            sc   = new SharkClass();
            bc   = new BoatClass();
            menu = new MenuClass();

            itemSprite1 = new ItemSprite();


            base.Initialize();
        }
Beispiel #4
0
        //public bool CollideTest(Rectangle location, Rectangle newRec)
        //{
        //    float right1, right2, left1, left2, top1, top2, bot1, bot2;


        //    left1 = newRec.X;
        //    top1 = newRec.Y;
        //    right1 = newRec.X + newRec.Width;
        //    bot1 = newRec.Y + newRec.Height;

        //    Rectangle pizzRec = new Rectangle(int.Parse(left1.ToString()), int.Parse(top1.ToString()), int.Parse(right1.ToString()), int.Parse(bot1.ToString()));

        //    left2 = location.X; ;
        //    top2 = location.Y;
        //    right2 = location.X + location.Width;
        //    bot2 = location.Y + location.Height;

        //    Rectangle chestRec = new Rectangle(int.Parse(left2.ToString()), int.Parse(top2.ToString()), int.Parse(right2.ToString()), int.Parse(bot2.ToString()));



        //    if (((right1 > right2 && left1 < right2) || (right1 > left2 && left1 < left2)) && ((top1 < top2 && top2 < bot1) || (top2 < top1 && top1 < bot2)))
        //    {
        //        return true;
        //    }

        //    return false;
        //}

        public void BlockSpawner(BoatClass bc, GameTime gt)
        {
            timer += (float)gt.ElapsedGameTime.TotalSeconds;

            if (ran.NextDouble() < blockSpawnRate && timer > 1.5)
            {
                timer = 0;
                if (ran.Next() % 7 == 0)
                {
                    xSpawn = bc.pus.X;
                    ySpawn = bc.pus.Y;

                    blockPositions.Add(new Vector2(xSpawn + (sourceRec.Width / 2 * bc.scale), ySpawn + (sourceRec.Height / 2 * bc.scale)));
                    theTestRec.Add(new Rectangle(429, 302, 18, 18));
                }
                else if (ran.Next() % 5 == 0)
                {
                    xSpawn = bc.pus.X;
                    ySpawn = bc.pus.Y;

                    blockPositions.Add(new Vector2(xSpawn + (sourceRec.Width / 2 * bc.scale), ySpawn + (sourceRec.Height / 2 * bc.scale)));
                    theTestRec.Add(new Rectangle(126, 294, 14, 16));
                }
                else if (ran.Next() % 2 == 1)
                {
                    xSpawn = bc.pus.X;
                    ySpawn = bc.pus.Y;

                    blockPositions.Add(new Vector2(xSpawn + (sourceRec.Width / 2 * bc.scale), ySpawn + (sourceRec.Height / 2 * bc.scale)));
                    theTestRec.Add(new Rectangle(140, 294, 14, 16));
                }
                else if (ran.Next() % 2 == 0)
                {
                    xSpawn = bc.pus.X;
                    ySpawn = bc.pus.Y;

                    blockPositions.Add(new Vector2(xSpawn + (sourceRec.Width / 2 * bc.scale), ySpawn + (sourceRec.Height / 2 * bc.scale)));
                    theTestRec.Add(new Rectangle(154, 294, 14, 16));
                }
            }
        }