//=====================================================================================================
 public static void StartShake(float start_radius = 5.0f, float min_shake_radius = 1.0f, float dimin_factor = 0.925f)
 {
     shaking            = true;
     m_CurrentCenterPos = m_DefaultCenter;
     //m_Offset = new Vector2f(0.0f, 0.0f);
     m_CurrentAngle   = (float)AppRandom.GetRandomNumber(0, 360);
     m_CurrentRadius  = start_radius;
     m_MinShakeRadius = min_shake_radius;
     m_DiminishFactor = dimin_factor;
 }
Example #2
0
        public cWaterNode(Vector2f pos, float start_Y)
        {
            position      = pos;
            lastPosition  = position;
            startPosition = new Vector2f(pos.X, start_Y);
            //Random r = new Random();
            /* factor = (float)random.Next(-10, 10);*/
            velocity     = new Vector2f(0.0f, 0.0f);
            force        = new Vector2f();
            acceleration = new Vector2f();

            SPEED = AppRandom.GetRandomNumber(40, 300);
        }
Example #3
0
        public void AppRandomTest()
        {
            var appRandom = new AppRandom();
            var array     = new int[10];

            for (var i = 0; i < 1000; i++)
            {
                var id = appRandom.Next(10);
                array[id]++;
            }

            for (var id = 0; id < 10; id++)
            {
                Assert.IsTrue(array[id] > 0, "array[id] == 0");
            }
        }
        public static void Update()
        {
            if (shaking)
            {
                m_CurrentRadius *= m_DiminishFactor;                                                                     //diminish radius each frame
                m_CurrentAngle  += (150.0f + AppRandom.GetRandomNumber(0, 60));                                          //pick new angle
                float rad = (float)AppMath.DegressToRadian(m_CurrentAngle);
                m_Offset = new Vector2f((float)Math.Sin(rad) * m_CurrentRadius, (float)Math.Cos(rad) * m_CurrentRadius); //create offset 2d vector

                m_CurrentCenterPos = m_DefaultCenter + m_Offset;
                //set centre of viewport

                if (m_CurrentRadius < m_MinShakeRadius) //2.0f
                {
                    StopShake();
                }
            }
        }
Example #5
0
        public void Init()
        {
            vertices.Clear();

            //Color col = new Color(0, 140, 186); //a víz felső színe  new Color(239,28,57);
            //Color col2 = new Color(20, 92, 147);  // alsó színe  new Color(217,37,50);

            //Color col = new Color(239,28,57);
            //Color col2 = new Color(217,37,50);

            Color col  = new Color(15, 151, 219);
            Color col2 = new Color(11, 115, 163);

            int bottomY = (int)area.rightBottom.Y;

            Vector2f[] points = new Vector2f[DIVISION + 1];


            points[0]        = new Vector2f(area.topLeft.X, area.topLeft.Y);
            points[DIVISION] = new Vector2f(area.rightBottom.X, area.topLeft.Y);

            for (int i = 1; i < points.Length - 1; i++)
            {
                int add = AppRandom.GetRandomNumber(MIN_OFFSET_Y, MAX_OFFSET_Y);
                points[i] = new Vector2f(area.topLeft.X + i * unitLength, area.topLeft.Y + add);
            }

            vertices.Append(new Vertex(points[0], col));

            //mindig kettőt adunk hozzá: az alsót és a következő felsőt
            for (int i = 0; i < points.Length - 1; i++)
            {
                //bottom
                vertices.Append(new Vertex(new Vector2f(points[i].X, bottomY), col2));

                //következő
                vertices.Append(new Vertex(points[i + 1], col));

                //Itt adunk hozzá egy waternode-ot
                waterNodes.Add(new cWaterNode(points[i + 1], area.topLeft.Y));
            }

            vertices.Append(new Vertex(new Vector2f(area.rightBottom.X, bottomY), col2));
        }
        private void empower(Particle particle)
        {
            particle.Pos      = particle.StartPos;
            particle.LastPos  = particle.Pos;
            particle.ViewPos  = particle.Pos;
            particle.MaxSpeed = AppMath.GetRandomNumber(30, 50); //200,400 | 700, 900 | (400, 600); //3, 8//Math->GetRandomNumber(510, 800); // 2000.0f

            //------------------------------------------------------------------------------------------------
            float angle = (float)AppMath.DegressToRadian(AppMath.GetRandomNumber(0, 360));//sDivisions * m_Angles;

            particle.Rotation = angle;

            // Vector2f dirUnit = cAppMath.GetRandomUnitVec();
            Vector2f dirUnit = AppMath.GetRandomVecBySpread(new Vector2f(0.0f, -1.0f), AppMath.DegressToRadian(6));

            particle.Vel = dirUnit * particle.MaxSpeed;
            //------------------------------------------------------------------------------------------------
            //------------------------------------------------------------------------------------------------

            //particle.m_Vel = sf::Vector2f(Math->GetRandomClamped() * particle.m_MaxSpeed, Math->GetRandomClamped() *particle.m_MaxSpeed);
            particle.SlowDown = 1.0f; //0.92f;
                                      //particle.m_SlowDown = (float)Math->GetRandomDoubleInRange(0.55, 0.7); //0.6f;
                                      //phs->AddForce( sf::Vector2f(Math->GetRandomClamped() * phs->MaxSpeed, Math->GetRandomClamped() * phs->MaxSpeed) );

            Vector2u uSize = this.renderStates.Texture.Size;

            particle.Scale = (float)AppMath.GetRandomDoubleInRange(this.minScale, this.maxScale);

            particle.Dims = new Vector2f(uSize.X * particle.Scale, uSize.Y * particle.Scale);

            particle.ScaleSpeed = (float)AppMath.GetRandomNumber(15, 25) / 100.0f;

            particle.Color   = Utils.GetRandomColor(250, 250, 1, 160, 0, 0); // GetRandomRedColor();
            particle.Opacity = 255.0f;
            particle.Fade    = AppRandom.GetRandomNumber(10, 40);

            particle.Life = 15.0f;

            particle.Intersects = false;
        }