Example #1
0
        public void DrawDebugBoard(SpriteBatch b)
        {
            int w  = 25;
            int x1 = 10;
            int y1 = 10;
            int x2 = x1 + TiledSize.X * w;
            int y2 = y1 + TiledSize.Y * w;

            for (int i = 0; i <= TiledSize.Y; i++)
            {
                Utility.drawLineWithScreenCoordinates(x1, y1 + i * w, x2, y1 + i * w, b, Color.White);
            }

            for (int j = 0; j <= TiledSize.X; j++)
            {
                Utility.drawLineWithScreenCoordinates(x1 + j * w, y1, x1 + j * w, y2, b, Color.White);
            }

            int px = (int)(x1 + w / 2 + Player.GetBoxPosition().X *w);
            int py = (int)(y1 + w / 2 + Player.GetBoxPosition().Y *w);

            Utility.drawLineWithScreenCoordinates(px, py, (int)(Board.GetDrawPosition(Player.GetBoxPosition().toVector2(), Player.Size).X + (Player.Size.X / 2)), (int)(Board.GetDrawPosition(Player.GetBoxPosition().toVector2(), Player.Size).Y - (Player.Size.Y / 4) + Player.Size.Y), b, Color.White);

            if (Board.nextCollectible == null)
            {
                return;
            }

            int cx = (int)(x1 + w / 2 + Board.nextCollectible.position.X * w);
            int cy = (int)(y1 + w / 2 + Board.nextCollectible.position.Y * w);

            Utility.drawLineWithScreenCoordinates(cx, cy, (int)(Board.nextCollectible.Drawposition.X + Board.nextCollectible.Size.X / 2), (int)(Board.nextCollectible.Drawposition.Y - (Board.nextCollectible.Size.Y / 4) + Board.nextCollectible.Size.Y), b, Color.Yellow);
        }
Example #2
0
        public void receiveKeyPress(Keys k)
        {
            if (k.Equals(Keys.Left))
            {
                Player.Turn(Direction.LEFT);
            }
            if (k.Equals(Keys.Right))
            {
                Player.Turn(Direction.RIGHT);
            }
            if (k.Equals(Keys.Space))
            {
                if (Board.GameOver)
                {
                    StartGame();
                    Board.Paused = false;
                }
                else
                {
                    Board.Paused = !Board.Paused;
                }
            }
            if (k.Equals(Keys.Escape))
            {
                if (!Board.Paused)
                {
                    Board.Paused = true;
                }
                else
                {
                    ShouldQuit = true;
                }
            }

            if (k.Equals(Keys.Up) && debug)
            {
                SnakeMod.monitor.Log(Player.position.ToString() + ":" + Player.GetBoxPosition().ToString() + ":" + Board.nextCollectible.position.ToString());
            }
            if (k.Equals(Keys.Down) && debug)
            {
                Player.AddNewTailSegment();
            }
            if (k.Equals(Keys.F5))
            {
                debug = !debug;
            }
            if (k.Equals(Keys.F6))
            {
                hideObjects = !hideObjects;
            }
        }