예제 #1
0
 public Sprite(ref Game game)
 { /* konstruktor */
     p_game          = game;
     p_position      = new PointF(0, 0);
     p_velocity      = new PointF(0, 0);
     p_size          = new Size(0, 0);
     p_bitmap        = null;
     p_alive         = true;
     p_columns       = 1;
     p_totalFrames   = 1;
     p_currentFrame  = 0;
     p_animationDir  = AnimateDir.FORWARD;
     p_animationWrap = AnimateWrap.WRAP;
     p_lastTime      = 0;
     p_animationRate = 30;
 }
예제 #2
0
 public Asset(ref GamePlay gamePlay)
 {
     p_gamePlay      = gamePlay;
     p_position      = new PointF(0, 0);
     p_velocity      = new PointF(0, 0);
     p_size          = new Size(0, 0);
     p_bitmap        = null;
     p_alive         = true;
     p_columns       = 1;
     p_totalFrames   = 1;
     p_currentFrame  = 0;
     p_animationDir  = AnimateDir.FORWARD;
     p_animationWrap = AnimateWrap.WRAP;
     p_lastTime      = 0;
     p_animationRate = 30;
 }
예제 #3
0
        public Sprite(ref Cipher cipher)
        {
            game = cipher;
            position = new PointF(0, 0);

            velocity = new PointF(0, 0);
            mSize = new Size(0, 0);
            bitmap = null;
            alive = true;
            colums = 1;
            totalFrames = 1;
            currentFrame = 0;
            animateDirection = AnimateDir.Forward;
            animateWrap = AnimateWrap.Wrap;
            lastTime = 0;
            animationRate = 30;
        }
예제 #4
0
        public void Animate(int startFrame, int endFrame)
        {
            //do we even need to animate?
            if (p_totalFrames <= 0)
            {
                return;
            }

            //check animation timing
            int time = Environment.TickCount;

            if (time > p_lastTime + p_animationRate)
            {
                p_lastTime = time;

                //go to next frame
                p_currentFrame += (int)p_animationDir;
                switch (p_animationWrap)
                {
                case AnimateWrap.WRAP:
                    if (p_currentFrame < startFrame)
                    {
                        p_currentFrame = endFrame;
                    }
                    else if (p_currentFrame > endFrame)
                    {
                        p_currentFrame = startFrame;
                    }
                    break;

                case AnimateWrap.BOUNCE:
                    if (p_currentFrame < startFrame)
                    {
                        p_currentFrame = startFrame;
                        p_animationDir = AnimateDir.FORWARD;
                    }
                    else if (p_currentFrame > endFrame)
                    {
                        p_currentFrame = endFrame;
                        p_animationDir = AnimateDir.BACKWARD;
                    }
                    break;
                }
            }
        }
예제 #5
0
        public void Animate(int startFrame, int endFrame)
        {
            //animujemy wtedy gdy podana liczba ramek > 0
            if (p_totalFrames <= 0)
            {
                return;
            }
            //sprawdź czas animacji
            int time = Environment.TickCount;

            if (time > p_lastTime + p_animationRate)
            {
                p_lastTime = time;
                //przejście do kolejnej ramki
                p_currentFrame += (int)p_animationDir;
                switch (p_animationWrap)
                {
                case AnimateWrap.WRAP:
                    if (p_currentFrame < startFrame)
                    {
                        p_currentFrame = endFrame;
                    }
                    else
                    if (p_currentFrame > endFrame)
                    {
                        p_currentFrame = startFrame;
                    }
                    break;

                case AnimateWrap.BOUNCE:
                    if (p_currentFrame < startFrame)
                    {
                        p_currentFrame = startFrame;
                        p_animationDir = AnimateDir.FORWARD;
                    }
                    else if (p_currentFrame > endFrame)
                    {
                        p_currentFrame = endFrame;
                        p_animationDir = AnimateDir.BACKWARD;
                    }
                    break;
                }
            }
        }
예제 #6
0
        public void Animate(int startFrame, int endFrame)
        {
            if (totalFrames <= 0)
            {
                return;
            }

            int time = Environment.TickCount;
            if (time > lastTime + animationRate)
            {
                lastTime = time;

                currentFrame += (int)animateDirection;
                switch (animateWrap)
                {
                    case AnimateWrap.Wrap:
                        {
                            if (currentFrame < startFrame)
                            {
                                currentFrame = endFrame;
                            }
                            else if (currentFrame > endFrame)
                            {
                                currentFrame = startFrame;
                            }
                            break;
                        }
                    case AnimateWrap.Bounce:
                        {
                            if (currentFrame < startFrame)
                            {
                                currentFrame = startFrame;
                                animateDirection = AnimateDir.Forward;
                            }
                            else if (currentFrame > endFrame)
                            {
                                currentFrame = endFrame;
                                animateDirection = AnimateDir.Backward;
                            }
                            break;
                        }
                }
            }
        }