Beispiel #1
0
        //Write your own Update&Draw Action in here

        public static void EatApple()
        {
            Score    += 10;
            speed    += 0.1f;
            apple.Pos = new Point(StandAlone.Random(0, StandAlone.FullScreen.Width), StandAlone.Random(0, StandAlone.FullScreen.Height));
            //화면의 랜덤한 위치로 애플이 옮겨갑니다.
        }
Beispiel #2
0
        /// <summary>
        /// 리스트 아이템 중 한개를 랜덤하게 픽합니다.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Ts"></param>
        /// <returns></returns>
        public static T RandomPick <T>(List <T> Ts) //리스트 아이템 중 한개를 랜덤하게 픽합니다.
        {
            double r = StandAlone.Random();
            double m = 1.0 / Ts.Count;

            for (int i = 0; i < Ts.Count; i++)
            {
                if (r >= m * i && r < m * (i + 1))
                {
                    return(Ts[i]);
                }
            }
            return(Ts[0]);
        }