Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8294853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:22:24+00:00 2026-06-08T14:22:24+00:00

enum rocks { uno = 1, dos, tres } So i declare my enum

  • 0
    enum rocks
    {
        uno = 1,
        dos,
        tres 

    }

So i declare my enum at the top,

rocks[] values = {rocks.uno, rocks.dos, rocks.tres};
        Random random = new Random();
        rocks randomValue = values[random.Next(values.Length)];

Initialise my random number generator

private void drawUno(SpriteBatch spriteBatch)
    {
        spriteBatch.Draw(rock1, Vector2.Zero, Color.White);
    }

Have seperate methods to draw each rock

 public void drawRocks(SpriteBatch spriteBatch)
    {
        switch (Rocks)
        {
            case rocks.uno:
                drawUno(spriteBatch);
                break;
            case rocks.dos:
                drawDos(spriteBatch);
                break;
            case rocks.tres:
                drawTres(spriteBatch);
                break;
            default:
                break;
        }
    }

and a method to draw out whatever rock the random generates

I call back the drawRock in my main draw method but nothing comes up, what am i doing wrong?

Heres my whole class:

namespace PlanetDrill2
{
   public class UMA : Screen
    {


        background bgLayer1;
        background bgLayer2;
        background bgLayer3;


        Texture2D rock1;
        Texture2D rock2;
        Texture2D rock3;

        enum rocks
        {
            uno = 1,
            dos,
            tres 

        }


       rocks Rocks;


        public UMA(Game game, SpriteBatch batch, ChangeScreen changeScreen)
            : base(game, batch, changeScreen)
        {
            bgLayer1 = new background();
            bgLayer2 = new background();
            bgLayer3 = new background();

            player = new Player();

            Animation playerAnimation = new Animation();
            Texture2D playerTexture = content.Load<Texture2D>("shipAnim");
            playerAnimation.Initialize(playerTexture, Vector2.Zero, 80, 160, 5, 30, Color.White, 1f, true);

            Vector2 playerPosition = new Vector2(game.GraphicsDevice.Viewport.TitleSafeArea.X, game.GraphicsDevice.Viewport.TitleSafeArea.Y
            + game.GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
            player.Initialize(playerAnimation, playerPosition);

            rock1 = content.Load<Texture2D>("rocktexture1");
            rock2 = content.Load<Texture2D>("Hardrock");
            rock3 = content.Load<Texture2D>("rarerock");

            bgLayer1.Initialize(content, "scrollingrocks", game.GraphicsDevice.Viewport.Height, -10);
            bgLayer2.Initialize(content, "scrollingrocks2", game.GraphicsDevice.Viewport.Height, -6);
            bgLayer3.Initialize(content, "scrollingrocks3", game.GraphicsDevice.Viewport.Height, -4);

            float playerMoveSpeed;


            playerMoveSpeed = 8.0f;


            rocks[] values = {rocks.uno, rocks.dos, rocks.tres};
            Random random = new Random();
            rocks randomValue = values[random.Next(values.Length)];


        }





        private void drawUno(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(rock1, Vector2.Zero, Color.White);
        }

        private void drawDos(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(rock2, Vector2.Zero, Color.White);
        }

        private void drawTres(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(rock3, Vector2.Zero, Color.White);
        }



        public void drawRocks(SpriteBatch spriteBatch)
        {

            switch (Rocks)
            {
                case rocks.uno:
                    drawUno(spriteBatch);
                    break;
                case rocks.dos:
                    drawDos(spriteBatch);
                    break;
                case rocks.tres:
                    drawTres(spriteBatch);
                    break;
                default:
                    break;
            }
        }




        private void UpdatePlayer(GameTime gameTime)
        {
            player.Update(gameTime);

            TouchPanel.EnabledGestures = GestureType.FreeDrag;

            float positionChange = 0;
            float oldPosition = 0;
            while (TouchPanel.IsGestureAvailable)
            {
                GestureSample gesture = TouchPanel.ReadGesture();

                if (gesture.GestureType == GestureType.FreeDrag)
                {
                    float newposition = gesture.Position.X;
                    if (oldPosition != 0)
                    {


                        positionChange = newposition - oldPosition;
                        player.Position.X += positionChange;
                    }
                    oldPosition = newposition;

                }

            }



            // Make sure that the player does not go out of bounds
            player.Position.X = MathHelper.Clamp(player.Position.X, 0, game.GraphicsDevice.Viewport.Width - player.Width);
            player.Position.Y = MathHelper.Clamp(player.Position.Y, 0, game.GraphicsDevice.Viewport.Height - player.Height);



        }



        protected override void SetupInputs()
        {
            base.SetupInputs();
        }

        public override void Activate()
        {
            base.Activate();
        }

        protected override void LoadScreenContent(ContentManager content)
        {
            base.LoadScreenContent(content);
        }

        protected override void UpdateScreen(GameTime gameTime, DisplayOrientation screenOrientation)
        {
            bgLayer1.Update();
            bgLayer2.Update();
            bgLayer3.Update();
            UpdatePlayer(gameTime);

            base.UpdateScreen(gameTime, screenOrientation);
        }

        protected override void DrawScreen(SpriteBatch batch, DisplayOrientation screenOrientation)
        {
            bgLayer3.Draw(batch);
            bgLayer2.Draw(batch);
            bgLayer1.Draw(batch);

            player.Draw(batch);
            drawRocks(batch);

            base.DrawScreen(batch, screenOrientation);
        }



    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:22:26+00:00Added an answer on June 8, 2026 at 2:22 pm

    I think you forgot something. You’re picking a random rock:

    rocks randomValue = values[random.Next(values.Length)];
    

    Then you don’t use randomValue at all. Instead you’re using Rocks in your switch statement:

    switch (Rocks)
    {
        case rocks.uno:
            drawUno(spriteBatch);
            break;
        case rocks.dos:
            drawDos(spriteBatch);
            break;
        case rocks.tres:
            drawTres(spriteBatch);
            break;
        default:
            break;
    }
    

    So either use randomValue in your switch, or assign the random value to your Rocks property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public enum ProcessorFactory { A(ap) { Processor create() throws Exception { return new AProcessor();
How can I group Enum values? Assume I have an enum like public enum
My enum consists of the following values: private enum PublishStatusses{ NotCompleted, Completed, Error };
Enum is Comparable which means you can have NavigableSet<AccessMode> modes = new TreeSet<>(); NavigableMap<AccessMode,
Enum values can contain spaces on it? For example ENUM('item1','the item2','item 3'). It's allowed?
I have an enum public enum Number { ONE(one), TWO(two), THREE(three), FOUR(four); } i
Homework: Rock Paper Scissors game. I've created an enumeration: enum Gesture{ROCK,PAPER,SCISSORS}; from which I
Enum is in the java.lang.Enum , and Object is in the java.lang.Object . So,
enum Answer : int { Yes = 1, No = 2 } Answer answer
enum AccessSource { AccessSourceNull = 0x00000001, AccessSourceSec = 0x00000002, AccessSourceIpo = 0x00000004, AccessSourceSSA =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.