Exemplo n.º 1
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            space = new Space();
            space.ForceUpdater.Gravity = new Vector3(0, -3.711f, 0); //-3.711 is the gravity for mars,changed this

            children.Add(new StarsSphere());                         //Create the stars for the sky,added myself
            terrain = new MarsTerrain();                             //Create the terrain,added myself
            children.Add(terrain);
            rover = new MarsRover();                                 //Create the rover,added myself
            children.Add(rover);

            foreach (GameEntity child in children)
            {
                child.LoadContent();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            float         timeDelta  = (float)gameTime.ElapsedGameTime.TotalSeconds;
            KeyboardState keyState   = Keyboard.GetState();
            MouseState    mouseState = Mouse.GetState();

            if (keyState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }
            if (keyState.IsKeyDown(Keys.R))//Suppose to reset game, not working correctly,added myself
            {
                rover.UnloadContent();
                children.Remove(rover);
                rover = new MarsRover();
                children.Add(rover);
            }


            if (mouseState.LeftButton == ButtonState.Pressed & lastFired > 0.25f)
            {
                fireBall();
                lastFired = 0.0f;
            }
            lastFired += timeDelta;

            for (int i = 0; i < children.Count; i++)
            {
                children[i].Update(gameTime);
            }

            space.Update(timeDelta);

            base.Update(gameTime);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            float timeDelta = (float)gameTime.ElapsedGameTime.TotalSeconds;
            KeyboardState keyState = Keyboard.GetState();
            MouseState mouseState = Mouse.GetState();
            if (keyState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }
            if(keyState.IsKeyDown(Keys.R))//Suppose to reset game, not working correctly,added myself
            {
                rover.UnloadContent();
                children.Remove(rover);
                rover = new MarsRover();
                children.Add(rover);
            }

            if (mouseState.LeftButton == ButtonState.Pressed & lastFired > 0.25f)
            {
                fireBall();
                lastFired = 0.0f;
            }
            lastFired += timeDelta;

            for (int i = 0; i < children.Count; i++)
            {
                children[i].Update(gameTime);
            }

            space.Update(timeDelta);

            base.Update(gameTime);
        }
Exemplo n.º 4
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            space = new Space();
            space.ForceUpdater.Gravity = new Vector3(0, -3.711f, 0);//-3.711 is the gravity for mars,changed this

            children.Add(new StarsSphere());//Create the stars for the sky,added myself
            terrain = new MarsTerrain();//Create the terrain,added myself
            children.Add(terrain);
            rover = new MarsRover();//Create the rover,added myself
            children.Add(rover);

            foreach (GameEntity child in children)
            {
                child.LoadContent();
            }
        }