public void ResetGame() { Player1 = new SnakePlayer(this); FoodMngr = new FoodManager(GameCanvas.Width, GameCanvas.Height); FoodMngr.AddRandomFood(10); score = 0; }
public void ResetGame() { FoodMngr = new FoodManager(GameCanvas.Width, GameCanvas.Height); FoodMngr.AddRandomFood(); Player1 = new SnakePlayer(GameCanvas.Size, FoodMngr); score = 0; Input.Clear(); }
public Snake() { InitializeComponent(); Application.AddMessageFilter(this); Player1 = new SnakePlayer(this); FoodMngr = new FoodManager(GameCanvas.Width, GameCanvas.Height); FoodMngr.AddRandomFood(10); ScoreTxtBox.Text = score.ToString(); }
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(); }
public void ResetGame() { homeForm.Show(); homeForm.GameOver(); player = new SnakePlayer(this); foodManager = new FoodManager(GameCanvas.Width, GameCanvas.Height); foodManager.AddRandomFood(10); score = 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; }
public void ResetGame() { gameHasEnded = false; gameInAction = true; ToggleGame(); SnakeSetup(); FoodMngr = new FoodManager(GameCanvas.Width, GameCanvas.Height); FoodMngr.AddRandomFood(10); DisplaySetup(); GameTimer.Enabled = true; }
/// <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; }
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; }
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) { } }
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; }