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();
        }