Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 26
  1. #11
    Join Date
    Jan 2012
    Location
    Denmark
    Posts
    66
    Hallo again
    Know I got to "Knowledge Review 6" and are at part 3, but I have absolutely no idea of what I am gonna do.
    The challenge is abourt the bouncing X pogram and where I have to make the char switch color after a certened amount of health is gone. I can't use if-satements and I have to make a list for the colors so if there are 3 colors in the list the color will switch 3 times, if there are 4 colors, 4 times and so on.
    I've used 3 hours to try and find a solution but I am out of luck.
    Any ideas on how to get me back on track without say the solution so I still have to think?

    //Alpo

  2. #12
    Join Date
    Jan 2007
    Posts
    216
    again, you're stuck on the math part:

    Since you can't use if- or switch- statements you will need to create a function that turns health % into numbers from 0..3, or how many segments of health you have.

  3. #13
    Join Date
    Jan 2012
    Location
    Denmark
    Posts
    66
    I did get that far by myself but I don't know how to make the list with colors. I did get so far to "list.Count + 1 / 100" to get 1% of the list but I can't get further from there

  4. #14
    Join Date
    Jan 2007
    Posts
    216
    This is how you build a list
    Code:
    List<Color> colors = new List<Color>();
    colors.add(Color.Red);
    ...
    (list.Count +1) /100 is a start, but you need to in cooperate the health the player has in there.

  5. #15
    Join Date
    Jan 2012
    Location
    Denmark
    Posts
    66
    Well I did you so far. But how do I get the color inside the list out and able to use?

  6. #16
    Join Date
    Jan 2007
    Posts
    216
    same as an array:

    colors[0] will get you the first element, colors[1] the next one and so on.

  7. #17
    Join Date
    Jan 2012
    Location
    Denmark
    Posts
    66
    But even with all this I can't se how I can make it happen when I can't use if-statemens

  8. #18
    Join Date
    Jan 2007
    Posts
    216
    I can't think of any hints to give you without solving it, sorry

  9. #19
    Join Date
    Jan 2012
    Location
    Denmark
    Posts
    66
    okay. I guess the task is about thinking around the if-statements :i But thanks anyway I will try sleep on it :P

  10. #20
    Join Date
    Aug 2007
    Location
    Montreal, Canada
    Posts
    618
    I watched that video to see what your question is.

    (As a side note Buzz makes a mistake at 38:42 when he writes 66.3 for 2/3 of 100)

    I didn't look at the way they did it but I would use the Math.Floor function

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •