public void Draw(CanvasContext2D ctx, Matrix3d wvp)
        {
            Vector3d a = wvp.Transform(A.Position);
            Vector3d b = wvp.Transform(B.Position);
            Vector3d c = wvp.Transform(C.Position);

            if (CheckBackface(a, b, c) != CullInside)
            {
                TrianglesCulled++;
                return;
            }

            TrianglesRendered++;

            bool rendered;
            if (factor == 1.0)
            {
                rendered = DrawTriangle(ctx, texture, (a.X + .5) * Width, (-a.Y + .5) * Height, (b.X + .5) * Width, (-b.Y + .5) * Height, (c.X + .5) * Width, (-c.Y + .5) * Height, A.Tu * 256.0, A.Tv * 256.0, B.Tu * 256.1, B.Tv * 256.0, C.Tu * 256.0, C.Tv * 256.0);
            }
            else
            {
                rendered = DrawTriangle(ctx, texture, (a.X * factor + .5) * Width, (-a.Y * factor + .5) * Height, (b.X * factor + .5) * Width, (-b.Y * factor + .5) * Height, (c.X * factor + .5) * Width, (-c.Y * factor + .5) * Height, A.Tu * 255, A.Tv * 255, B.Tu * 255, B.Tv * 255, C.Tu * 255, C.Tv * 255);
            }
            if (rendered)
            {
                TrianglesRendered++;
            }
            else
            {
                TrianglesCulled++;
            }
        }
Beispiel #2
0
        public void Run()
        {
            _backgroundImageElement = Document.GetElementById("backgroundImage").As<ImageElement>();
            _imageStripElement = Document.GetElementById("imageStrip").As<ImageElement>();
            _tankCanvas = Document.GetElementById("fishTankCanvas").As<CanvasElement>();
            _fishesCanvas = Document.GetElementById("fishesCanvas").As<CanvasElement>();

            Debug.Assert(_backgroundImageElement != null);
            Debug.Assert(_imageStripElement != null);
            Debug.Assert(_tankCanvas != null);
            Debug.Assert(_fishesCanvas != null);

            _tankCanvasContext = (CanvasContext2D)_tankCanvas.GetContext(Rendering.Render2D);
            _fishesCanvasContext = (CanvasContext2D)_fishesCanvas.GetContext(Rendering.Render2D);

            _fishes = new List<Fish>();
            for (int i = 0; i < FishTank.FishCount; i++) {
                double x = Math.Floor(Math.Random() * (_width - FishTank.FishWidth) + FishTank.FishWidth / 2);
                double y = Math.Floor(Math.Random() * (_height - FishTank.FishHeight) + FishTank.FishHeight / 2);
                double z = Math.Floor(Math.Random() * (FishTank.ZFar - FishTank.ZNear));

                _fishes.Add(new Fish(this, x, y, z, _imageStripElement, _fishesCanvasContext));
            }

            OnWindowResize(null);
            Window.AddEventListener("resize", OnWindowResize, false);

            _tickHandler = OnTick;
            QueueUpdate();
        }
Beispiel #3
0
        public Fish(FishTank tank, double x, double y, double z, ImageElement fishStrip, CanvasContext2D context) {
            _tank = tank;

            _x = x;
            _y = y;
            _z = z;
            _zFactor = 1;
            _species = Math.Floor(Math.Random() * FishTank.FishSpecies);
            _cellIndex = Math.Floor(Math.Random() * (FishTank.CellsInFishStrip - 1));
            _cellReverse = -1;

            _angle = 2 * Math.PI * Math.Random();
            _xAngle = Math.Cos(_angle);
            _yAngle = Math.Sin(_angle);
            _zAngle = 1 - 2 * Math.Round(Math.Random());
            _scale = 0.1;
            _flip = 1;
            _velocity = 100;

            // Stop fish from swimming straight up or down
            if ((_angle > Math.PI * 4 / 3) && (_angle < Math.PI * 5 / 3) ||
                (_angle > Math.PI * 1 / 3) && (_angle < Math.PI * 2 / 3)) {
                _angle = Math.PI * 1 / 3 * Math.Random();
                _xAngle = Math.Cos(_angle);
                _yAngle = Math.Sin(_angle);
            }

            // Face the fish the right way if angle is between 6 o'clock and 12 o'clock
            if ((_angle > Math.PI / 2) && (_angle < Math.PI / 2 * 3)) {
                _flip = -1;
            }

            _fishStrip = fishStrip;
            _context = context;
        }
Beispiel #4
0
 public WriteableBitmap(int width, int height)
 {
     this.PixelWidth = width;
     this.PixelHeight = height;
     this.canvas = (CanvasElement)Document.GetElementById("gameCanvas");
     this.context = (CanvasContext2D)this.canvas.GetContext(Rendering.Render2D);
 }
Beispiel #5
0
        public override void Draw(CanvasContext2D canv)
        {
            if (!Visible) return;
            UpdatePosition(TotalX, TotalY);

            base.Draw(canv);
        }
        public override void Draw(CanvasContext2D canv)
        {
            Width = (int) (double) CellWidth;
            Height = (int) (double) CellHeight;

            base.Draw(canv);
        }
        public void Draw(CanvasContext2D ctx, Matrix3d wvp)
        {
            if (ctx == null)
            {
                return;
            }

            wvp.TransformTo(A.Position, ta);
            wvp.TransformTo(B.Position, tb);
            wvp.TransformTo(C.Position, tc);

            if (CheckBackface() == CullInside)
            {
                TrianglesCulled++;
                return;
            }

            //TrianglesRendered++;

            DrawTriangle(ctx, texture, ta.X, ta.Y, tb.X, tb.Y, tc.X, tc.Y, A.Tu, A.Tv, B.Tu, B.Tv, C.Tu, C.Tv);

            //if (rendered)
            //{
            //    TrianglesRendered++;
            //}
            //else
            //{
            //    TrianglesCulled++;
            //}
        }
Beispiel #8
0
 public override void Draw(CanvasContext2D context)
 {
     context.Save();
     context.FillStyle = "blue";
     context.FillRect(X - 13, Y - 13, 26, 26);
     context.Restore();
 }
        public override void Update(CanvasContext2D context)
        {
            while (_objectIndex < _objects.Length && _objects[_objectIndex].Distance < _level.Position) _objectIndex++;

            for (int i = _objects.Length - 1; i >= _objectIndex; i--)
            {
                RoadObject roadObject = _objects[i];
                roadObject.GameObject.Visible = false;
                float distance = roadObject.Distance - _level.Position;

                if (distance > _level.DistanceTable[RaceLevel.Lines]) continue;

                float scale = 1;
                if (distance != 0) scale = 3500 / distance;

                float y = 600 + (1000000 / distance) - 300;
                float x = 425 + roadObject.X * scale + _level.Shifts[Math.Floor(600 - y)];

                if (Number.IsNaN(x)) continue;

                roadObject.GameObject.Location = new Vector3D(x, y, roadObject.Distance);
                roadObject.GameObject.Scale = scale;
                roadObject.GameObject.Visible = true;

                if (distance < 4500 && Math.Abs(roadObject.GameObject.Location.X - _level.CarSystem.CarObject.Location.X) < 85)
                {
                    _level.Crash();
                }
            }
        }
Beispiel #10
0
        public override void Update(CanvasContext2D context)
        {
            context.Save();
            context.BeginPath();
            context.Rect(0, 0, 800, 320);
            context.ClosePath();
            context.Clip();

            float speed = -(_level.Curve * _level.Speed * 50);
            if (_level.Left && _level.Speed > 0) speed += 1;
            if (_level.Right && _level.Speed > 0) speed -= 1;

            UpdateExplosions(context, speed);

            UpdateFlak(context, speed);

            foreach (Cloud cloud in _clouds)
            {
                float scale = (400 - cloud.Y) / 400;

                cloud.X = (cloud.X - (0.3f - speed) * scale + 2400) % 2400;

                context.DrawImage(
                    _cloudImage,
                    cloud.X - 1200,
                    cloud.Y - (_cloudImage.NaturalHeight / 2) * scale,
                    _cloudImage.NaturalWidth * scale,
                    _cloudImage.NaturalHeight * scale);
            }
            context.Restore();
        }
Beispiel #11
0
        public Renderer(Game game)
        {
            this.game = game;

            CanvasElement can = Document.GetElementById("canvas").As<CanvasElement>();
            this.ctx = (CanvasContext2D)can.GetContext(Rendering.Render2D);
            this.initializeMinimap();
        }
Beispiel #12
0
 protected override void Update(CanvasContext2D context)
 {
     context.ClearRect(0, 0, 800, 600);
     if (!_finished)
     {
         _textElement.InnerHTML += GetNextLetter();
     }
 }
 public void Draw(CanvasContext2D context, int x, int y)
 {
     foreach (var particleSystem in systems) {
         particleSystem.Render(context);
     }
     /*            system.Position.X = x;
                 system.Position.Y = y;*/
 }
Beispiel #14
0
 protected override void Update(CanvasContext2D context)
 {
     context.ClearRect(0, 0, 800, 600);
     if (!_finished && (_nextLetter < Ticks || _keyPressed))
     {
         _textElement.InnerHTML += GetNextLetter();
         if (_nextLetter == 0 || _keyPressed) _nextLetter = Ticks + 100;
         else _nextLetter += 100;
     }
 }
        public void Draw(CanvasContext2D context, int x, int y)
        {
            system.Position.X = x;
            system.Position.Y = y;
            //     system.Render(context);

            foreach (var particleSystem in projectiles) {
                particleSystem.Render(context);
            }
        }
        public void Draw(CanvasContext2D context, int wX, int wY, int wWidth, int wHeight)
        {
            context.Save();

            wWidth = Math.Min(wWidth, myTotalRegionWidth);
            wHeight = Math.Min(wHeight, myTotalRegionHeight);

            foreach (var gameMapLayout in GameMapLayouts) {
                ( (DrawGameMap) gameMapLayout.GameMap ).Draw(context, gameMapLayout.X + wX, gameMapLayout.Y + wY, wWidth, wHeight);
            }

            context.Restore();
        }
        public void Draw(CanvasContext2D context, int tileX, int tileY, int wWidth, int wHeight)
        {
            context.Save();

            for (int x = tileX; x < wWidth; x++) {
                for (int y = tileY; y < wHeight; y++) {
                    DrawTile tile = (DrawTile) TileMap.GetSafe(x, y);
                    if (tile == null)
                        continue;
                    tile.Draw(context, tileX, tileY, x, y);
                }
            }
            context.Restore();
        }
Beispiel #18
0
        public static void DrawObjects(CanvasContext2D context)
        {
            _visibleObjects = new List<GameObject>();

            foreach (GameObject gameObject in Objects)
            {
                if (!gameObject.Visible) continue;
                _visibleObjects.Add(gameObject);
            }

            _visibleObjects.Sort(Compare);

            foreach (GameObject gameObject in _visibleObjects) gameObject.Draw(context);
        }
        public override void Update(CanvasContext2D context)
        {
            List<PlasmaBall> garbage = new List<PlasmaBall>();
            foreach (PlasmaBall plasmaBall in _plasmaBalls)
            {
                plasmaBall.Update();
                if (!plasmaBall.Intersect(0, 0, 900, 600) || plasmaBall.Destroyed) garbage.Add(plasmaBall);
            }

            foreach (PlasmaBall junk in garbage)
            {
                GameObject.Remove(junk);
                _plasmaBalls.Remove(junk);
            }
        }
Beispiel #20
0
        public override void Draw(CanvasContext2D context)
        {
            context.FillStyle = "red";
            context.FillRect(100, 100, 200, 200);

            context.DrawImage(someImage, 250, 250);
            context.DrawImage(someImage, 350, 350, 100, 100, 200, 200, 100, 100);

            for (int i = 0; i < DebugText.Length; i++) {
                if (DebugText[i].Truthy()) {
                    context.Save();
                    context.StrokeStyle = "white";
                    context.StrokeText(DebugText[i].ToString(), Screen.Width - 120, i * 20 + 150);
                    context.Restore();
                }
            }
        }
        public void Draw(CanvasContext2D context)
        {
            context.Save();
            switch (GameMode) {
                case GameMode.TileEdit:

                    break;
                case GameMode.Play:
                    screenOffset.X = Game.Screen.Width / 2 - WindowManager.Width * Scale.X / 2;
                    screenOffset.Y = Game.Screen.Height / 2 - WindowManager.Height * Scale.Y / 2;
                    context.Translate(screenOffset.X, screenOffset.Y);

                    playDraw(context);

                    break;
            }

            context.Restore();
        }
Beispiel #22
0
        public override void Draw(CanvasContext2D canv)
        {
            if (!Visible) return;
            string txt = Text;

            if (canv.Font != Font)
                canv.Font = Font;

            //var w = canv.MeasureText(txt).Width;
            //var h = int.Parse(canv.Font.Split("pt")[0]);

            //   canv.fillStyle = "rgba(255,255,255,0.78)";
            // var pad = 3;
            //     canv.fillRect(this.parent.x + this.x - pad, this.parent.y + this.y - h - pad, w + (pad * 2), h + (pad * 2));

            canv.FillStyle = Color;

            canv.FillText(txt, TotalX, TotalY);
        }
Beispiel #23
0
        public void Draw(CanvasContext2D context, int _x, int _y, int mapX, int mapY)
        {
            context.Save();
            context.Translate(_x + mapX * ZombieGameConfig.TileSize, _y + mapY * ZombieGameConfig.TileSize);

            /*
            context.Translate(ZombieGameConfig.TileSize / 2, ZombieGameConfig.TileSize / 2);
            //context.Rotate(fm);
            context.Translate(-ZombieGameConfig.TileSize / 2, -ZombieGameConfig.TileSize / 2);
            */
            context.DrawImage((CanvasElement) Image.Canvas, 0, 0);
            /*
            context.StrokeStyle = "red";
            context.StrokeRect(0, 0, ZombieGameConfig.TileSize, ZombieGameConfig.TileSize);

            switch (Collision) {
                case CollisionType.Full:
                    context.FillStyle = "rgba(233,12,22,0.6)";
                    context.FillRect(0, 0, ZombieGameConfig.TileSize, ZombieGameConfig.TileSize);
                    break;
                case CollisionType.RightHalf:
                    context.FillStyle = "rgba(233,12,22,0.6)";
                    context.FillRect(ZombieGameConfig.TileSize / 2, 0, ZombieGameConfig.TileSize / 2, ZombieGameConfig.TileSize);
                    break;
                case CollisionType.TopHalf:
                    context.FillStyle = "rgba(233,12,22,0.6)";
                    context.FillRect(0, 0, ZombieGameConfig.TileSize, ZombieGameConfig.TileSize / 2);
                    break;
                case CollisionType.LeftHalf:
                    context.FillStyle = "rgba(233,12,22,0.6)";
                    context.FillRect(0, 0, ZombieGameConfig.TileSize / 2, ZombieGameConfig.TileSize);
                    break;
                case CollisionType.BottomHalf:
                    context.FillStyle = "rgba(233,12,22,0.6)";
                    context.FillRect(0, ZombieGameConfig.TileSize / 2, ZombieGameConfig.TileSize, ZombieGameConfig.TileSize / 2);
                    break;
            }
            */ //todo enable when some sort of edit mode is enabled

            context.Restore();
        }
Beispiel #24
0
        public override void Update(CanvasContext2D context)
        {
            RoadEvent roadEvent = null;
            int trackIndex = 0;
            while (trackIndex < _events.Length && _events[trackIndex].Distance <= _level.Position)
            {
                roadEvent = _events[trackIndex];
                trackIndex++;
            }

            float shift = 0;
            float curve = 0;

            for (int i = 0; i < RaceLevel.Lines; i++)
            {
                float distance = _level.Position + _level.DistanceTable[i];
                while ((trackIndex < _events.Length) && (_events[trackIndex].Distance <= distance))
                {
                    roadEvent = _events[trackIndex];
                    trackIndex++;
                }

                if (trackIndex < _events.Length)
                {
                    RoadEvent nextEvent = _events[trackIndex];

                    curve = (nextEvent.Curve - roadEvent.Curve) * (distance - roadEvent.Distance) / (nextEvent.Distance - roadEvent.Distance) + roadEvent.Curve;
                }

                long index = Math.Round(distance / 2000) % 2;

                if (i > 0) shift += curve * (_level.DistanceTable[i + 1] - _level.DistanceTable[i]);

                _level.Curves[i] = curve;
                _level.Shifts[i] = Math.Round(((299 - i) * _level.Shift) / RaceLevel.Lines) - 25 + shift;

                context.DrawImage(_road[index], 0, 299 - i, 850, 1, _level.Shifts[i], 599 - i, 850, 1);

                if (i == 0) _level.Curve = curve;
            }
        }
Beispiel #25
0
 public static void RoundRect(CanvasContext2D ctx, int x, int y, int width, int height, int radius = 5, bool fill = true, bool stroke = false)
 {
     ctx.Save();
     ctx.LineWidth = 3;
     ctx.BeginPath();
     ctx.MoveTo(x + radius, y);
     ctx.LineTo(x + width, y);
     //ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
     ctx.LineTo(x + width, y + height);
     // ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
     ctx.LineTo(x, y + height);
     // ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
     ctx.LineTo(x, y + radius);
     ctx.QuadraticCurveTo(x, y, x + radius, y);
     ctx.ClosePath();
     if (stroke)
         ctx.Stroke();
     if (fill)
         ctx.Fill();
     ctx.Restore();
 }
Beispiel #26
0
        public override void Update(CanvasContext2D context)
        {
            foreach(Npc npc in _npcs)
            {
                npc.Object.Visible = false;
                npc.Distance += npc.Speed * _level.DeltaTime;

                float distance = npc.Distance - _level.Position;

                if (distance <= 0 || distance > _level.DistanceTable[RaceLevel.Lines]) continue;

                float scale = 3500 / distance;

                float y = 600 + (1000000 / distance) - 300;
                float x = 425 + npc.X * scale + _level.Shifts[Math.Floor(600 - y)];

                if (Number.IsNaN(x)) continue;

                int index = 3;
                if (distance < 30000)
                {
                    int angle = Math.Floor(_level.Shifts[Math.Floor(600 - y)] + (npc.X * 3500) / distance);
                    index = Math.Floor(Math.Abs(angle) / 60);
                    if (index > 3) index = 3;
                    index = 3 + index * (angle / Math.Abs(angle));
                    if (Number.IsNaN(index)) index = 3;
                }

                npc.Object.Update();
                npc.Object.Visible = true;
                npc.Object.Location = new Vector3D(x, y, npc.Distance);
                npc.Object.Scale = scale;
                npc.Object.CurrentFrame = index;

                if (distance < 4500 && Math.Abs(npc.Object.Location.X - _level.CarSystem.CarObject.Location.X) < 100)
                {
                    _level.Crash();
                }
            }
        }
Beispiel #27
0
        public override void Update(CanvasContext2D context)
        {
            if (_level.Status != RaceStatus.Running && _level.Status != RaceStatus.Crashing) return;

            switch (_engineStatus)
            {
                case EngineStatus.Low:
                    if (_level.Up)
                    {
                        _engineStatus = EngineStatus.Up;
                        _engine.CurrentTime = EngineUpStart;
                    }
                    break;

                case EngineStatus.Up:
                    if (!_level.Up)
                    {
                        _engine.CurrentTime = EngineDownStart + (EngineUpEnd - _engine.CurrentTime);

                        _engineStatus = EngineStatus.Down;
                    }
                    break;

                case EngineStatus.Down:
                    if (_level.Up)
                    {
                        _engine.CurrentTime = EngineUpStart + (EngineDownEnd - _engine.CurrentTime);
                        _engineStatus = EngineStatus.Up;
                    }
                    break;

                case EngineStatus.High:
                    if (!_level.Up)
                    {
                        _engineStatus = EngineStatus.Down;
                        _engine.CurrentTime = EngineDownStart;
                    }
                    break;
            }
        }
Beispiel #28
0
        protected override void Update(CanvasContext2D context)
        {
            if (Status != RaceStatus.Fail && Status != RaceStatus.Win)
            {
                context.DrawImage(_timeLeftFrame, 308, 10);

                Type.SetField(context, "textAlign", "right");
                context.FillStyle = "#00AD11";

                if (TimeLeft > 10000 || Math.Floor((TimeLeft / 300) % 2) != 0)
                {
                    if (TimeLeft < 0) TimeLeft = 0;
                    context.Font = "110px Digital";
                    context.FillText(Math.Floor(TimeLeft / 1000).ToString(), 475, 105);
                }

                if (Speed > 0)
                {
                    context.Save();
                    context.Scale(-1, 1);
                    long width = Math.Floor((10 * Speed) / MaxSpeed) * 22;
                    if (width > 0) context.DrawImage(_meterImage, 220 - width, 0, width, 102, -561 - width, 20, width, 102);
                    context.Restore();
                }

                context.Font = "30px Digital";
                context.FillText(Math.Floor(Speed * 5) + " Km/h", 780, 120);

                int rpmWidth = Math.Floor(_rpm / 500) * 22 + 22;

                context.DrawImage(_meterImage, 220 - rpmWidth, 0, rpmWidth, 102, 240 - rpmWidth, 20, rpmWidth, 102);
                context.FillText(Math.Floor(_rpm) + " RPM", 130, 120);

                context.BeginPath();
                context.LineWidth = 3;
                context.StrokeStyle = "#00AD11";
                context.MoveTo(5, 150);
                float x = 5 + Math.Min(Position * 735 / RoadLength, 735);
                context.LineTo(x, 150);
                context.Stroke();
                context.ClosePath();

                context.BeginPath();
                context.StrokeStyle = "#006808";
                context.MoveTo(x, 150);
                context.LineTo(790, 150);
                context.Stroke();
                context.ClosePath();
                context.DrawImage(_markerImage, x, 142);
            }

            if (Status == RaceStatus.Running)
            {
                TimeLeft -= DeltaTime;

                if (TimeLeft < 0)
                {
                    _music.Pause();
                    CarSystem.CarObject.CurrentAnimation = "Forward";
                    Status = RaceStatus.Fail;
                    ShowMessage(_failMessage);
                    RemoveSystem(_engineSoundSystem);
                    RemoveSystem(_npcSystem);
                    pendingTimers.Add(Window.SetTimeout(delegate()
                    {
                        UpdateMessage("<p>Press a key to continue.</p>");
                    }, 3000));
                }
            }
        }
Beispiel #29
0
        protected override void PreUpdate(CanvasContext2D context)
        {
            // Draw background
            context.DrawImage(_backgroundImage, 0, 0);

            switch (Status)
            {
                case RaceStatus.Running:
                    // Handle left and right turns
                    if (Speed > 0)
                    {
                        float increment = (60 - Math.Max(Speed, 20)) / 80;

                        if (Left)
                        {
                            Shift += increment * DeltaTime;
                            CarSystem.CarObject.CurrentAnimation = Down ? "b-Left" : "Left";
                        }
                        if (Right)
                        {
                            Shift -= increment * DeltaTime;
                            CarSystem.CarObject.CurrentAnimation = Down ? "b-Right" : "Right";
                        }
                    }

                    if (!(Left ^ Right)) CarSystem.CarObject.CurrentAnimation = Down ? "b-Forward" : "Forward";

                    // Handle acceleration, braking and inertia
                    if (Down) Speed -= 0.4f;
                    else if (Up) Speed += 0.3f;
                    else Speed -= 0.1f;

                    if (Up) _rpm += 40;
                    else _rpm -= 40;
                    if (_rpm > 4500) _rpm = 4500;
                    else if (_rpm < 200) _rpm = 200;

                    // When driving off the road
                    if (Math.Abs(Shift) > 350)
                    {
                        Speed *= 0.95f;

                        if (Math.Abs(Shift) > 450)
                            Shift = (Shift / Math.Abs(Shift)) * 450;
                    }
                    break;

                case RaceStatus.Win:
                case RaceStatus.Fail:
                    Speed -= 1;
                    _rpm -= 40;
                    break;

                case RaceStatus.Crashing:
                    Speed -= 0.3f;
                    Shift -= Shift * DeltaTime / 1000;
                    break;
            }

            // Speed capping
            if (Speed > MaxSpeed) Speed = MaxSpeed;
            if (Speed < 0) Speed = 0;

            // Calculating new position
            Position += Speed * DeltaTime;

            // Drift in turns
            Shift += Curve * Speed * 150;

            if (Position >= RoadLength && Status == RaceStatus.Running)
            {
                _music.Pause();
                Status = RaceStatus.Win;
                CarSystem.CarObject.StartAnimation("Skid");
                ShowMessage(_winMessage);
                RemoveSystem(_engineSoundSystem);
                RemoveSystem(_npcSystem);

                int timeLeft = Math.Floor(TimeLeft / 1000);
                CurrentGame.Score += 1000 + timeLeft * 500;

                //if (!_practice)
                //{
                //    pendingTimers.Add(
                //    Window.SetTimeout(delegate()
                //    {
                //        UpdateMessage("<p>Time Left: " + timeLeft + "</p>");
                //    }, 1500));

                //    pendingTimers.Add(
                //    Window.SetTimeout(delegate()
                //    {
                //        UpdateMessage("<p>Score: " + CurrentGame.Score + "</p>");
                //    }, 2500));
                //}

                pendingTimers.Add(
                Window.SetTimeout(delegate()
                {
                    UpdateMessage("<p>Press a key to continue.</p>");
                }, 3000));
            }
        }
        public void Draw(CanvasContext2D canvas)
        {
            canvas.Save();

            foreach (var are in canvasDepths) {
                are.Draw(canvas);
            }

            if (true /*DEBUGs*/) {
                for (var i = 0; i < messages.Count; i++) {
                    canvas.FillText(messages[i], 10, 25 + i * 30);
                }
            }

            canvas.Restore();
        }