Android Question Logic (or math) problem..

Discussion in 'Android Questions' started by Beja, Apr 22, 2015.

  1. Beja

    Beja Expert Licensed User

    To all,

    To make the long story short.
    I have a timer, and I have to move an image and link the image speed by the ever increasing interval value of the timer.. but I must increase the timer interval value and not decrease it because I need the bigger value in another place that needs a positive change.

    Anyone has a clue?

    Thanks in advance.
  2. LucaMs

    LucaMs Expert Licensed User

    Non c'ho capito 'na mazza (how can I translate it? hehehe.)

    I did not understand very well, but if you have the need to have two inverse values between them I think you should use a subtraction.

    Incr = 75

    B = B + Incr

    C = MaxVal - Incr

    or something like this.
  3. Beja

    Beja Expert Licensed User

    Thank you Luca,
    it's a little tricky and I am getting old and can't collect my thoughts quickly..
    A progress bar value is from 1 to 120
    An image speed needs to be changed from timer interval 240(fastest) down to 10 (slowest) Step -10
    The problem: how can I map this to that?
    Are you young enough to solve this or I should call Klaus
    Last edited: Apr 22, 2015
  4. Beja

    Beja Expert Licensed User

    Remember I am using one timer.
  5. LucaMs

    LucaMs Expert Licensed User

    Is it a progress bar (1) or a view to set the speed (2)?

    1) PB.Progress = Timer1.Interval / 2 (PB values will be 120, 115, 110...5)

    2) Timer1.Interval = YourView.Value * 20


    I'm too old to understand :D
    lemonisdead and RandomCoder like this.
  6. Beja

    Beja Expert Licensed User

    sorry I am joking..

    It's like this.. now the images start very fast because the counter starts with "1". for PB this is a small value, but for image it is 1 millisecond so it goes very fast. besides upper and lower bounds are different. pls see the picture:

    sorry mistake:
    img 240 to 10 (step -10)

    Attached Files:

  7. Beja

    Beja Expert Licensed User

    Map (240 ~ 10 STEP -10) to (1 ~ 120)
  8. walterf25

    walterf25 Well-Known Member Licensed User

    I'm not sure i understand exactly what you are trying to do.
    From what you wrote, if the highest speed is 240 and the decrement step is -10 then, if you divide 240/10 you have 24 steps.
    In the timer, if the value of the progressbar is 1 then 1 = 240, 2 = 230.
    in other words you could do something like this

    dim val as int
    dim speed as int
    val = 
    speed = 
    240 - (val*10)
    End Sub
    I don't know maybe i'm hearing voices.

  9. MaFu

    MaFu Well-Known Member Licensed User

    My MFLib (see signature) contains a map function (MapInt) which does exactly what you need.
    DonManfred likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice