Example #1
0
        private void timer_Tick(object sender, EventArgs e)
        {
            var now     = DateTime.Now;
            var elapsed = now - previousTime;

            previousTime = now;
            var msec = (int)elapsed.TotalMilliseconds;

            if (!active)
            {
                return;
            }

            bg1Offset -= bg1Speed * msec / 1000;
            if (bg1Offset < -800)
            {
                bg1Offset += 1400;
            }
            bg2Offset -= bg2Speed * msec / 1000;
            if (bg2Offset < -261)
            {
                bg2Offset += 261;
            }
            bg3Offset -= bg3Speed * msec / 1000;
            if (bg3Offset < -261)
            {
                bg3Offset += 261;
            }

            floor.update(msec);
            //player.updateFrame(msec);
            player.updateFrame(msec);

            int tag = floor.checkCollision(player);

            if (tag == Floor.TAG_CROCODILE)
            {
                //active = false;
            }

            //coin.updateFrame(msec);
            //crocodile.updateFrame(msec);

            //player.index++;
            //playerFrameIndex = (playerFrameIndex + 1) % 40;
            //if (++playerFrameIndex >= 4) {
            //    playerFrameIndex = 0;
            //}
            Invalidate();
        }