Ejemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            updateInput();

            if (man.XPosition < 50)
            {
                if (screenCounter > 0)
                {
                    screenCounter      -= 1;
                    belowScreenCounter -= 1;
                    if (edibleWalls.Count > 0)
                    {
                        man.XPosition = 740;
                    }
                    else
                    {
                        man.XPosition = 680;
                    }
                    clearAll();
                    if (belowMoon)
                    {
                        graphicsMan.configureEnemies(belowScreenCounter);
                    }
                }
                else
                {
                    screenCounter       = 15;
                    belowScreenCounter += 15;
                    man.XPosition       = 740;
                    clearAll();
                    if (belowMoon)
                    {
                        graphicsMan.configureEnemies(belowScreenCounter);
                    }
                }
            }

            if (man.XPosition > 750)
            {
                if (screenCounter < 15)
                {
                    screenCounter      += 1;
                    belowScreenCounter += 1;
                    man.XPosition       = 55;
                    clearAll();
                    graphicsMan.configureEnemies(belowScreenCounter);
                }
                else
                {
                    screenCounter       = 0;
                    belowScreenCounter -= 15;
                    man.XPosition       = 55;
                    clearAll();
                    graphicsMan.configureEnemies(belowScreenCounter);
                }
            }

            gameSpritesRect = new Rectangle((int)currentFrame * spriteWidth, (int)0, spriteWidth, spriteHeight);
            mainSpritesRect = new Rectangle((int)man.XPosition, (int)man.YPosition, spriteWidth, spriteHeight);
            heartBeatRect   = new Rectangle((int)heartBeatFrame * spriteWidth, (int)9 * spriteHeight, spriteWidth, spriteHeight);
            groundRect      = new Rectangle((int)10 * unGroTileWidth, (int)0, unGroTileWidth, unGroTileHeight);

            test = new Rectangle((int)0, (int)0, (int)40, (int)30);

            heartBeatTimer += elapsedSecs;
            if (heartBeatTimer > 0.4)
            {
                heartBeatTimer = 0;
                heartBeatFrame++;
            }
            if (heartBeatFrame >= 6)
            {
                heartBeatFrame = 0;
            }

            if (belowMoon && man.Falling)
            {
                if (man.YPosition < 12)
                {
                    graphicsMan.configureEnemies(belowScreenCounter);
                }
                man.YPosition += 2;
                if (man.YPosition >= 425)
                {
                    man.YPosition       = 20;
                    man.WalkingOnFloor  = false;
                    belowScreenCounter += 16;
                    clearAll();
                    graphicsMan.configureEnemies(belowScreenCounter);
                }

                if (man.YPosition <= 15 && belowScreenCounter > 15)
                {
                    man.YPosition       = 400;
                    belowScreenCounter -= 16;
                    man.Jump            = false;
                    clearAll();
                }
            }

            if (belowMoon && !man.Falling)
            {
                // Allow us to jump out from under the moon surface....
                if (man.YPosition <= 30 && belowScreenCounter < 15)
                {
                    man.Falling        = false;
                    man.WalkingOnFloor = false;
                    belowMoon          = false;
                    man.YPosition      = 250;
                    clearAll();
                    belowScreenCounter = 0;
                    graphicsMan.configureEnemies(belowScreenCounter);
                }
                if (man.YPosition <= 15 && belowScreenCounter > 15)
                {
                    man.YPosition       = 400;
                    belowScreenCounter -= 16;
                    man.Jump            = false;
                    clearAll();
                }
            }


            if (belowMoon)
            {
                foreach (Enemy en in enemies)
                {
                    if (en is Alf)
                    {
                        Alf alf = (Alf)en;
                        alf.Update(gameTime);
                    }
                    if (en is Bird)
                    {
                        Bird bird = (Bird)en;
                        bird.Update(gameTime);
                    }
                    if (en is BlueThingy)
                    {
                        BlueThingy bluething = (BlueThingy)en;
                        bluething.Update(gameTime);
                    }
                    if (en is Caterpillar)
                    {
                        Caterpillar caterpillar = (Caterpillar)en;
                        caterpillar.Update(gameTime);
                    }
                    if (en is ChasingEnemy)
                    {
                        ChasingEnemy enem = (ChasingEnemy)en;
                        enem.Update(gameTime, new Vector2(man.XPosition, man.YPosition));
                    }
                    if (en is SpringBear)
                    {
                        SpringBear springbear = (SpringBear)en;
                        springbear.Update(gameTime);
                    }
                    if (en is Fire)
                    {
                        Fire fire = (Fire)en;
                        fire.Update(gameTime);
                    }
                    if (en is Fish)
                    {
                        Fish fish = (Fish)en;
                        fish.Update(gameTime);
                    }
                    if (en is GreenMeanie)
                    {
                        GreenMeanie greenie = (GreenMeanie)en;
                        greenie.Update(gameTime);
                    }
                    if (en is Plant)
                    {
                        Plant plant = (Plant)en;
                        plant.Update(gameTime);
                    }
                    if (en is RedSpaceman)
                    {
                        RedSpaceman redspace = (RedSpaceman)en;
                        redspace.Update(gameTime);
                    }
                    if (en is WhirlWind)
                    {
                        WhirlWind whirlWind = (WhirlWind)en;
                        whirlWind.Update(gameTime);
                    }
                    if (en is WoodLouse)
                    {
                        WoodLouse woodLouse = (WoodLouse)en;
                        woodLouse.Update(gameTime);
                    }
                }
            }

            if (moleManAlive)
            {
                mole.Update(gameTime, belowScreenCounter);
            }

            man.Update(tempY, jumpRight, belowMoon, trip, belowScreenCounter);
            rocket.Update(gameTime);
            if (!belowMoon)
            {
                earth.Update(gameTime);
            }

            seconds = (int)gameTime.ElapsedGameTime.Seconds;
            minutes = (int)gameTime.ElapsedGameTime.Minutes;

            base.Update(gameTime);
        }
Ejemplo n.º 2
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin();

            if (gameOn == false)
            {
                spriteBatch.Draw(frontScreen, new Vector2(0, 0), Color.White);
                Vector2 textLocation = new Vector2(10, 10);
                spriteBatch.DrawString(hudFont, "XNA NODES OF YESOD REMAKE ", textLocation + new Vector2(295.0f, 020.0f), Color.Yellow);
                spriteBatch.DrawString(hudFont, "Start", textLocation + new Vector2(480.0f, 100.0f), Color.Yellow);
                spriteBatch.DrawString(hudFont, "Instructions", textLocation + new Vector2(480.0f, 120.0f), Color.Yellow);
                spriteBatch.DrawString(hudFont, "Define Keys ", textLocation + new Vector2(480.0f, 140.0f), Color.Yellow);
                spriteBatch.DrawString(hudFont, "Exit", textLocation + new Vector2(480.0f, 160.0f), Color.Yellow);
                spriteBatch.DrawString(hudFont, "Hit X to Start ", textLocation + new Vector2(480.0f, 240.0f), Color.Yellow);
            }

            else
            {
                if (!belowMoon)
                {
                    if (rocket.RocketScreen == screenCounter)
                    {
                        rocket.Draw(spriteBatch);
                    }

                    for (int j = 0; j < 8; j++)
                    {
                        moonRocksRect = new Rectangle((int)(graphicsMan.UpperRockArray[screenCounter, j] * rockWidth),
                                                      (int)0, rockWidth, rockHeight);
                        spriteBatch.Draw(MoonRocks,
                                         new Rectangle((j * rockWidth),
                                                       170,
                                                       rockWidth, rockHeight),
                                         moonRocksRect,
                                         Color.White);
                    }

                    moundRect = new Rectangle((int)(graphicsMan.MoundArray[screenCounter, 0] * lowerRockWidth), (int)300, lowerRockWidth, lowerRockHeight);

                    if (graphicsMan.HoleArray0[screenCounter, 0] == 0)
                    {
                        man.colTileRect0 = new Rectangle((int)340, (int)415, 20, 18);
                        holeRect0        = new Rectangle((int)(graphicsMan.HoleArray0[screenCounter, 0] * lowerRockWidth), (int)300, lowerRockWidth, lowerRockHeight);
                        spriteBatch.Draw(MoonRocks, new Vector2(hole0X, holesY), holeRect0, Color.White);
                        spriteBatch.Draw(collisionTile, new Vector2(hole0X + 20.0f, holesY + 15.0f), man.colTileRect0, Color.White);
                    }

                    if (graphicsMan.HoleArray0[screenCounter, 0] != 0)
                    {
                        man.colTileRect0 = new Rectangle((int)340, (int)0, 20, 18);
                    }

                    if (graphicsMan.HoleArray1[screenCounter, 0] == 0)
                    {
                        man.colTileRect1 = new Rectangle((int)540, (int)415, 20, 18);
                        holeRect1        = new Rectangle((int)(graphicsMan.HoleArray1[screenCounter, 0] * lowerRockWidth), (int)300, lowerRockWidth, lowerRockHeight);
                        spriteBatch.Draw(MoonRocks, new Vector2(hole1X, holesY), holeRect1, Color.White);
                        spriteBatch.Draw(collisionTile, new Vector2(hole1X + 20.0f, holesY + 15.0f), man.colTileRect1, Color.White);
                    }
                    if (graphicsMan.HoleArray1[screenCounter, 0] != 0)
                    {
                        man.colTileRect1 = new Rectangle((int)340, (int)0, 20, 18);
                    }

                    spriteBatch.Draw(MoonRocks, new Vector2(100.0f, 300.0f), moundRect, Color.White);
                    spriteBatch.Draw(MoonRocks, new Vector2(600.0f, 300.0f), moundRect, Color.White);

                    for (int l = 0; l < 8; l++)
                    {
                        lowMoonRocksRect = new Rectangle((int)(graphicsMan.LowerRockArray[screenCounter, l] * lowerRockWidth), (int)170, lowerRockWidth, lowerRockHeight);

                        spriteBatch.Draw(MoonRocks,
                                         new Rectangle((l * lowerRockWidth),
                                                       470,
                                                       lowerRockWidth, lowerRockHeight),
                                         lowMoonRocksRect,
                                         Color.White);
                    }
                    earth.Draw(spriteBatch);
                }

                else if (belowMoon)
                {
                    rects.Clear();
                    walls.Clear();
                    platform.Clear();
                    edibleWalls.Clear();
                    alchiems.Clear();
                    testList.Clear();
                    if (roof.Count > 0)
                    {
                        roof.Clear();
                    }

                    int textureY = 0;
                    int textureX = 0;

                    for (int ii = 0; ii < 10; ii++)
                    {
                        for (int jj = 0; jj < 13; jj++)
                        {
                            // Iterate through the array & point to the start position of the texture to be grabbed by the wallRect
                            platforms = (graphicsMan.ToTheUnderGround[(belowScreenCounter * 10) + ii, jj]);

                            if (platforms < 19)
                            {
                                textureY = 0;
                                textureX = (0 * unGroTileWidth);
                            }

                            // If the image is greater than 19 then point to the next line in the texture
                            if (platforms >= 19 && platforms < 38)
                            {
                                textureY = (unGroTileHeight * 1);
                                textureX = (19 * unGroTileWidth);
                            }

                            // If the image is greater than 38 then point to the next line in the texture
                            if (platforms >= 38 && platforms < 57)
                            {
                                textureY = (unGroTileHeight * 2);
                                textureX = (38 * unGroTileWidth);
                            }

                            // If the image is greater than 57 then point to the next line in the texture
                            if (platforms >= 57 && platforms < 76)
                            {
                                textureY = (unGroTileHeight * 3);
                                textureX = (57 * unGroTileWidth);
                            }

                            //Grab the rectangle texture from the underground graphics.png
                            wallRect = new Rectangle((int)(platforms * unGroTileWidth) - textureX,
                                                     (int)textureY, unGroTileWidth, unGroTileHeight);

                            spriteBatch.Draw(unGroundLedges, new Rectangle((jj * unGroTileWidth),
                                                                           ii * 48, 62, 48), wallRect, Color.White);

                            collisionRects = new Rectangle((jj * unGroTileWidth), ii * 48, 62, 48);

                            // Store the tiles to collide with in a List of Rectangles
                            // Check if floor tiles exist & only 1 screen high (i!)

                            // Alchiems
                            if (platforms == 19 || platforms == 20 || platforms == 21 || platforms == 22)
                            {
                                alchiems.Add(collisionRects);
                            }
                            // Mole edible wall textures
                            if (platforms == 15 || platforms == 16 || platforms == 17 || platforms == 18)
                            {
                                edibleWalls.Add(collisionRects);
                            }
                            // Floor textures
                            if (platforms == 5 || platforms == 6 || platforms == 7 || platforms == 8 ||
                                platforms == 24 || platforms == 25 || platforms == 26 ||
                                platforms == 43 || platforms == 44)
                            {
                                rects.Add(collisionRects);
                            }
                            // Platforms & Ledges
                            if (platforms == 9 || platforms == 10 || platforms == 11 || platforms == 13 ||
                                platforms == 14 || platforms == 28 || platforms == 29 ||
                                platforms == 47 || platforms == 48)
                            {
                                platform.Add(collisionRects);

                                //Copy the x,y co-ord from the platform into the test
                                test.Location = collisionRects.Location;
                                testList.Add(test);
                            }
                            // Wall textures
                            if (platforms == 0 || platforms == 1 || platforms == 2 || platforms == 3)
                            {
                                walls.Add(collisionRects);
                            }
                            // Roof textures
                            if (platforms >= 57 && platforms < 76)
                            {
                                roof.Add(collisionRects);
                            }
                        }
                    }

                    foreach (Enemy en in enemies)
                    {
                        if (en is Alf)
                        {
                            Alf alf = (Alf)en;
                            alf.Draw(spriteBatch);
                        }
                        if (en is Bird)
                        {
                            Bird bird = (Bird)en;
                            bird.Draw(spriteBatch);
                        }
                        if (en is BlueThingy)
                        {
                            BlueThingy bluething = (BlueThingy)en;
                            bluething.Draw(spriteBatch);
                        }
                        if (en is Caterpillar)
                        {
                            Caterpillar caterpillar = (Caterpillar)en;
                            caterpillar.Draw(spriteBatch);
                        }
                        if (en is ChasingEnemy)
                        {
                            ChasingEnemy chasingEnemy = (ChasingEnemy)en;
                            chasingEnemy.Draw(spriteBatch);
                        }

                        if (en is SpringBear)
                        {
                            SpringBear springbear = (SpringBear)en;
                            springbear.Draw(spriteBatch);
                        }

                        if (en is Fire)
                        {
                            Fire fire = (Fire)en;
                            fire.Draw(spriteBatch);
                        }
                        if (en is Fish)
                        {
                            Fish fish = (Fish)en;
                            fish.Draw(spriteBatch);
                        }
                        if (en is GreenMeanie)
                        {
                            GreenMeanie greenie = (GreenMeanie)en;
                            greenie.Draw(spriteBatch);
                        }
                        if (en is Plant)
                        {
                            Plant plant = (Plant)en;
                            plant.Draw(spriteBatch);
                        }
                        if (en is RedSpaceman)
                        {
                            RedSpaceman redspace = (RedSpaceman)en;
                            redspace.Draw(spriteBatch);
                        }
                        if (en is WhirlWind)
                        {
                            WhirlWind whirlWind = (WhirlWind)en;
                            whirlWind.Draw(spriteBatch);
                        }
                        if (en is WoodLouse)
                        {
                            WoodLouse woodLouse = (WoodLouse)en;
                            woodLouse.Draw(spriteBatch);
                        }
                    }
                }

                if (moleManAlive)
                {
                    mole.Draw(spriteBatch);
                }

                if (!man.summerSaultJump)
                {
                    man.Draw(spriteBatch, gameSpritesRect);
                }
                else
                {
                    man.Draw(spriteBatch, gameSpritesRect);
                }


                spriteBatch.Draw(panel, new Vector2(30, 550), Color.White);
                spriteBatch.Draw(gameSprites, new Vector2(390.0f, 535.0f), heartBeatRect, Color.White);
                spriteBatch.DrawString(hudFont, "" + alchiem, new Vector2(250.0f, 555.0f), Color.White);
                spriteBatch.DrawString(hudFont, "" + man.Lives, new Vector2(395.0f, 555.0f), Color.White);


                string fps = string.Format("{0}", seconds);

                if (seconds < 10 && minutes == 0)
                {
                    spriteBatch.DrawString(hudFont, "00:0" + seconds, new Vector2(635.0f, 555.0f), Color.White);
                }
                else if (seconds >= 10 && minutes == 0)
                {
                    spriteBatch.DrawString(hudFont, "00:" + seconds, new Vector2(635.0f, 555.0f), Color.White);
                }
                if (seconds < 10 && minutes > 0)
                {
                    spriteBatch.DrawString(hudFont, "0" + minutes + ":0" + seconds, new Vector2(635.0f, 555.0f), Color.White);
                }
                else if (seconds >= 10 && minutes > 0)
                {
                    spriteBatch.DrawString(hudFont, "0" + minutes + ":" + seconds, new Vector2(635.0f, 555.0f), Color.White);
                }
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }
Ejemplo n.º 3
0
        public void configureEnemies(int belowScreenCounter)
        {
            int index;
            int floatingEnemies;

            for (int i = 0; i < 3; i++)
            {
                index = ToTheEnemes[belowScreenCounter, i];
                switch (index)
                {
                case 1:      //a
                    mEnemies.Add(alf = (new Alf(300.0f, 366.0f, 1.0f, mSprites, mWalls)));
                    break;

                case 2:      //b
                    mEnemies.Add(bird = new Bird(300.0f, 366.0f, 1.0f, mSprites, mWalls));
                    break;

                case 3:      //c
                    mEnemies.Add(caterpillar = new Caterpillar(300.0f, 366.0f, 1.0f, mSprites, mWalls));
                    break;

                case 4:      //d
                    mEnemies.Add(greenMeanie = (new GreenMeanie((float)rand.Next(100, 400), 366.0f, 1.0f, mSprites, mWalls)));
                    break;

                case 5:      //e
                    mEnemies.Add(fire = (new Fire(300.0f, 372.0f, 1.0f, mSprites, mWalls)));
                    break;

                case 6:      //f
                    mEnemies.Add(fish = new Fish(300.0f, 300.0f, 1.0f, 1.0f, mSprites, mWalls));
                    break;

                case 7:      //g
                    mEnemies.Add(plant = new Plant(300.0f, 300.0f, 1.0f, 1.0f, mSprites, mWalls));
                    break;

                case 8:      //h
                    mEnemies.Add(whirlWind = new WhirlWind((float)rand.Next(100, 400), (float)rand.Next(100, 400), 1.0f, 1.0f, mSprites, mWalls));
                    break;

                case 9:      //i
                    mEnemies.Add(woodLouse = new WoodLouse(300.0f, 300.0f, 1.0f, mSprites, mWalls));
                    break;

                case 10:
                    mEnemies.Add(redSpaceMan = (new RedSpaceman((float)rand.Next(100, 400), (float)rand.Next(100, 400), 1.0f, 1.0f, mSprites, mWalls)));
                    break;

                case 11:
                    break;

                case 12:
                    break;

                case 13:
                    break;
                }
            }
            for (int j = 0; j < 3; j++)
            {
                floatingEnemies = rand.Next(1, 6);
                switch (floatingEnemies)
                {
                case 1:
                    mEnemies.Add(springBear = (new SpringBear((float)rand.Next(100, 400), (float)rand.Next(100, 400), 1.0f, 1.0f, mSprites, mWalls, mPlatforms)));
                    break;

                case 2:
                    mEnemies.Add(blueThingy = (new BlueThingy((float)rand.Next(100, 400), (float)rand.Next(100, 400), 1.0f, 1.0f, mSprites, mWalls, mPlatforms)));
                    break;

                case 3:
                    mEnemies.Add(cloud = new ChasingEnemy(300.0f, 300.0f, 1.0f, 1.0f, mSprites, mWalls));
                    break;

                case 4:
                    mEnemies.Add(springBear = (new SpringBear((float)rand.Next(100, 400), (float)rand.Next(100, 400), 1.0f, 1.0f, mSprites, mWalls, mPlatforms)));
                    break;

                case 5:
                    mEnemies.Add(blueThingy = (new BlueThingy((float)rand.Next(100, 400), (float)rand.Next(100, 400), 1.0f, 1.0f, mSprites, mWalls, mPlatforms)));
                    break;

                case 6:
                    mEnemies.Add(cloud = new ChasingEnemy(300.0f, 300.0f, 1.0f, 1.0f, mSprites, mWalls));
                    break;
                }
            }
        }