Exemplo n.º 1
0
 public void ResetGame()
 {
     Player1  = new SnakePlayer(this);
     FoodMngr = new FoodManager(GameCanvas.Width, GameCanvas.Height);
     FoodMngr.AddRandomFood(10);
     score = 0;
 }
Exemplo n.º 2
0
 public void ResetGame()
 {
     FoodMngr = new FoodManager(GameCanvas.Width, GameCanvas.Height);
     FoodMngr.AddRandomFood();
     Player1 = new SnakePlayer(GameCanvas.Size, FoodMngr);
     score   = 0;
     Input.Clear();
 }
Exemplo n.º 3
0
 public Snake()
 {
     InitializeComponent();
     Application.AddMessageFilter(this);
     Player1  = new SnakePlayer(this);
     FoodMngr = new FoodManager(GameCanvas.Width, GameCanvas.Height);
     FoodMngr.AddRandomFood(10);
     ScoreTxtBox.Text = score.ToString();
 }
Exemplo n.º 4
0
 public SnakeForm()
 {
     InitializeComponent();
     Application.AddMessageFilter(this);
     this.FormClosed += (s, e) => Application.RemoveMessageFilter(this);
     Player1          = new SnakePlayer(this);
     FoodMngr         = new FoodManager(GameCanvas.Width, GameCanvas.Height);
     FoodMngr.AddRandomFood(10);
     scoreText.Text = score.ToString();
 }
Exemplo n.º 5
0
        public void ResetGame()
        {
            homeForm.Show();
            homeForm.GameOver();

            player      = new SnakePlayer(this);
            foodManager = new FoodManager(GameCanvas.Width, GameCanvas.Height);
            foodManager.AddRandomFood(10);
            score = 0;
        }
Exemplo n.º 6
0
 public Snake()
 {
     InitializeComponent();
     Application.AddMessageFilter(this);
     player      = new SnakePlayer(this);
     foodManager = new FoodManager(GameCanvas.Width, GameCanvas.Height);
     foodManager.AddRandomFood(10);
     ScoreTxtBox.Text   = score.ToString();
     DifficultyChanged += SetTimer;
 }
Exemplo n.º 7
0
        public void ResetGame()
        {
            gameHasEnded = false;
            gameInAction = true;
            ToggleGame();
            SnakeSetup();

            FoodMngr = new FoodManager(GameCanvas.Width, GameCanvas.Height);
            FoodMngr.AddRandomFood(10);

            DisplaySetup();
            GameTimer.Enabled = true;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Object constructor
        /// </summary>
        public SnakePlayer(Size gameSize, FoodManager foodManager)
        {
            // Add 3 body parts to the snake because the snake begins small
            m_SnakeParts.Add(new BodyPart(100, 100, Direction.Right));
            m_SnakeParts.Add(new BodyPart(80, 100, Direction.Right));
            m_SnakeParts.Add(new BodyPart(60, 100, Direction.Right));

            // Need to give an initial direction
            m_MoveDirection = Direction.Right;

            // Currently no body parts queued to be added
            m_PendingSegments = 0;

            // set game size
            _gameSize    = gameSize;
            _foodManager = foodManager;
        }
Exemplo n.º 9
0
        public void ResetGame()
        {
            String name, display;

            if (score != 0)
            {
                GameTimer.Enabled = false;
                display           = "Score : " + score.ToString();
                name = Interaction.InputBox(display, "High Scores", "Name", -1, -1);
                String line = name + "          " + score.ToString() + Environment.NewLine;
                System.IO.File.AppendAllText(@"C:\Project\Snake\Score.txt", line);
                GameTimer.Enabled = true;
            }
            Player1  = new SnakePlayer(this);
            FoodMngr = new FoodManager(GameCanvas.Width, GameCanvas.Height);
            FoodMngr.AddRandomFood(10);
            score = 0;
        }
Exemplo n.º 10
0
 public SnakeForm()
 {
     InitializeComponent();
     Application.AddMessageFilter(this);
     this.FormClosed += (s, e) => Application.RemoveMessageFilter(this);
     Player1          = new SnakePlayer(this);
     FoodMngr         = new FoodManager(GameCanvas.Width, GameCanvas.Height);
     FoodMngr.AddRandomFood(10);
     ScoreTxtBox.Text = score.ToString();
     try
     {
         ArduinoInput = new ArduinoInput("COM5");
         ArduinoInput.SerialPort.DataReceived += ProcessArduinoInput;
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 11
0
        public SnakeForm(Startscreen menu, bool twoPlayer)
        {
            InitializeComponent();

            //xxx
            PauseTimer       = new Timer();
            PauseTimer.Tick += PauseTimer_Tick;
            PauseTimer.Start();
            GameTimer       = new Timer();
            GameTimer.Tick += GameTimer_Tick;
            Application.AddMessageFilter(this);
            this.FormClosed += (s, e) => Application.RemoveMessageFilter(this);


            //set link to form's parent
            mainmenu = menu;
            //update the game's player state
            is2Player = twoPlayer;
            //set the name of the current Game window
            this.Text = "Welcome to Snake: " + (is2Player?"Two":"Single") + " Player Mode";
            //set the brush visuals
            BuildBrush();
            //Build Players and update the visuals
            SnakeSetup();
            DisplaySetup();

            //Food initialization and execution
            FoodMngr = new FoodManager(GameCanvas.Width, GameCanvas.Height);
            FoodMngr.AddRandomFood(10);

            //apply exit message
            this.FormClosing += SnakeForm1_FormClosing;

            //initial start
            CheckForCollisions();
            //GameTimer.Enabled = true;
        }