Here is my script for defining the position in C# (with XNA)

public void PositionDefinierer(int v)
        {
            positionCheck = true;

            if (v == 1)
            {
                v *= 0;
                positionCheck = false;
            }
            else
            {   
            if (v < 11)
            {
                v *= 50;
            }
            else
            {
                if (v < 21)
                {
                    position.Y += 50;
                    v -= 10;
                    v *= 50;
                    
                }
                else
                {
                    if (v < 31)
                    {
                        position.Y += 100;
                        v -= 20;
                        v *= 50;
                    }
                    else
                    {
                        if (v < 41)
                        {
                            position.Y += 150;
                            v -= 30;
                            v *= 50;
                        }
                        else
                        {
                            if (v < 51)
                            {
                                position.Y += 200;
                                v -= 40;
                                v *= 50;
                            }
                            else
                            {
                                if (v < 61)
                                {
                                    position.Y += 250;
                                    v -= 50;
                                    v *= 50;
                                }
                                else
                                {
                                    if (v < 71)
                                    {
                                        position.Y += 300;
                                        v -= 60;
                                        v *= 50;
                                    }
                                    else
                                    {
                                        if (v < 81)
                                        {
                                            position.Y += 350;
                                            v -= 70;
                                            v *= 50;
                                        }
                                        else
                                        {
                                            if (v < 91)
                                            {
                                                position.Y += 400;
                                                v -= 80;
                                                v *= 50;
                                            }
                                            else
                                            {
                                                if (v < 101)
                                                {
                                                    position.Y += 450;
                                                    v -= 90;
                                                    v *= 50;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }




            if (positionCheck == true)
            {
                v -= 50;
            }


            
            position.X += v;
        }

I need help. O want to make this up too 1000. Is there any algorhythm to make this easyer. Thanks a lot.

Recommended Answers

All 3 Replies

if (v < 11) {
    if (v == 1) {
        v = 0;
        positioncheck = false;
    } else {
        v *= 50;
    }
} else {
    int n = v / 10 - 1;
    position.Y += 50 * n;
    v -= 10 * n;
    v *= 50;
}

thx a lot.
Could you also explain what this do, pls.

Lol. Momeraths code does exactly what your code does. Essentially you are asking what YOUR code does. Because that is what his code does. Actually, I am curious. What is the purpose of this hard-coded nightmare of a function?

Here's my crack at it:

positioncheck = (v == 1);
if (v < 11 && v > 1)
   v = 0;
else
{
   int n = v / 10 - 1;
   Position.Y += 50 * n;
   v -= 10 * n;
}
v *= 50;
if (positioncheck)
    v -= 50;
position.X += v;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.