Exemple #1
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            BackgroundScrollable backgroundScrollable = (BackgroundScrollable)this.background;

            backgroundScrollable.Draw(gameTime, spriteBatch);

            spriteBatch.DrawString(game.arialFont, "Visited:" + visited / listPlanets.Count, Vector2.Zero, Color.Red);

            Rectangle currRectangle;
            Animation animation;
            Point     topLeftBG = backgroundScrollable.GetTopLeftCoordinate();

            foreach (Planet planet in listPlanets)
            {
                animation     = planet.animation;
                currRectangle = new Rectangle(planet.centerX - animation.displayWidth / 2, planet.centerY - animation.displayHeight / 2, animation.displayWidth, animation.displayHeight);
                if (backgroundScrollable.IsRectangleWithinVisibility(currRectangle))
                {
                    planet.Draw(gameTime, spriteBatch, (int)topLeftBG.X, (int)topLeftBG.Y, backgroundScrollable.scale);
                    if (planet.Intersects(rocket, topLeftBG.X, topLeftBG.Y, backgroundScrollable.scale))
                    {
                        buttonEnterPlanet.Draw(gameTime, spriteBatch);
                    }
                }
            }

            rocket.Draw(gameTime, spriteBatch);
        }
Exemple #2
0
        public override void Update(GameTime gameTime, TouchCollection touchCollection)
        {
            ProcessTouch(gameTime, touchCollection);
            BackgroundScrollable bgs = (BackgroundScrollable)this.background;
            Point topLeftBG          = bgs.GetTopLeftCoordinate();

            foreach (Planet planet in listPlanets)
            {
                if (planet.Intersects(rocket, (int)topLeftBG.X, (int)topLeftBG.Y, bgs.scale))
                {
                    if (touchCollection.Count > 0)
                    {
                        TouchLocation touch = touchCollection[0];
                        if (touch.State == TouchLocationState.Pressed)
                        {
                            if (buttonEnterPlanet.IsPressed((int)touch.Position.X, (int)touch.Position.Y))
                            {
                                if (!planet.isVisited)
                                {
                                    visited++;
                                    planet.isVisited = true;
                                }
                                if (planet.name.Equals("Mercury"))
                                {
                                    NextScreen = game.GetNewScreenMercury();
                                }
                                else if (planet.name.Equals("Venus"))
                                {
                                    NextScreen = game.GetNewScreenVenus();
                                }
                                else if (planet.name.Equals("Earth"))
                                {
                                    NextScreen = game.GetNewScreenEarth();
                                }
                                else if (planet.name.Equals("Mars"))
                                {
                                    NextScreen = game.GetNewScreenMars();
                                }
                                else if (planet.name.Equals("Jupiter"))
                                {
                                    NextScreen = game.GetNewScreenJupiter();
                                }
                                else if (planet.name.Equals("Saturn"))
                                {
                                    NextScreen = game.GetNewScreenSaturn();
                                }
                                else if (planet.name.Equals("Uranus"))
                                {
                                    NextScreen = game.GetNewScreenUranus();
                                }
                                else if (planet.name.Equals("Neptune"))
                                {
                                    NextScreen = game.GetNewScreenNeptune();
                                }
                            }
                        }
                    }
                }
            }
        }
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            BackgroundScrollable backgroundScrollable = (BackgroundScrollable)this.background;

            backgroundScrollable.Draw(gameTime, spriteBatch);
            rocket.Draw(gameTime, spriteBatch);

            Rectangle currRectangle;
            Animation animation;
            Point     topLeftBG = backgroundScrollable.GetTopLeftCoordinate();

            foreach (Planet planet in listPlanets)
            {
                animation     = planet.animation;
                currRectangle = new Rectangle(planet.centerX - animation.displayWidth / 2, planet.centerY - animation.displayHeight / 2, animation.displayWidth, animation.displayHeight);
                if (backgroundScrollable.IsRectangleWithinVisibility(currRectangle))
                {
                    planet.Draw(gameTime, spriteBatch, (int)topLeftBG.X, (int)topLeftBG.Y, backgroundScrollable.scale);
                }
            }
        }