static void Main() { using (var game = new SnakeGame()) { game.Run(); } }
static void Main(string[] args) { SnakeGame Game = new SnakeGame(40, 20); Game.Run(100); Console.ReadLine(); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (SnakeGame game = new SnakeGame()) { game.Run(); } }
static void Main(string[] args) { Console.CursorVisible = false; SnakeGame oyun = new SnakeGame(_oyunAlaniGenislik, _oyunAlaniYükseklik); oyun.OyunBasliyor += new OyunBasliyorHandler(YilaniVeYemiCiz); oyun.YilanHareketEtti += new YilanHareketiHandler(yilan_HareketEtti); oyun.Baslat(); do { switch (Console.ReadKey().Key) { case ConsoleKey.UpArrow: oyun.YilaniHareketEttir(Direction.Up); break; case ConsoleKey.DownArrow: oyun.YilaniHareketEttir(Direction.Down); break; case ConsoleKey.RightArrow: oyun.YilaniHareketEttir(Direction.Right); break; case ConsoleKey.LeftArrow: oyun.YilaniHareketEttir(Direction.Left); break; } } while (true); }
private void playButton_Click(object sender, EventArgs e) { SnakeGame gameForm = new SnakeGame(); gameForm.FormClosed += new FormClosedEventHandler(gameFormClose); gameForm.Show(); this.Hide(); }
public GamePage() { this.InitializeComponent(); // Create the game. var launchArguments = string.Empty; _game = MonoGame.Framework.XamlGame <SnakeGame> .Create(launchArguments, Window.Current.CoreWindow, swapChainPanel); }
void StartGameClick(object sender, RoutedEventArgs e) { Menu.Visibility = Visibility.Collapsed; GameScreen.Visibility = Visibility.Visible; SnakeGame.StartGame(); Tick(); timer.Start(); }
// Constructor public GamePage() { InitializeComponent(); _game = XamlGame<SnakeGame>.Create("", this); // Sample code to localize the ApplicationBar //BuildLocalizedApplicationBar(); }
public static void MoveBodyLogic() { for (int i = GamePlay.Instance.mySnake.Count - 1; i >= 0; i--) //mutare punct cu punct, cap+corp { //daca capul este activ if (i == 0) { switch (GamePlay.Instance.direction)//mut fiecare parte a corpului, cf directiei data de cap { case Direction.Right: GamePlay.Instance.mySnake[i].x++; //punctul curent din sarpe break; case Direction.Left: GamePlay.Instance.mySnake[i].x--; break; case Direction.Up: GamePlay.Instance.mySnake[i].y--; break; case Direction.Down: GamePlay.Instance.mySnake[i].y++; break; } //limitez sarpele la screen, spatiul de joc //GamePlay.Instance.maxX = screen.Size.Width / GamePlay.Instance.Width;//pozitia max x si y //GamePlay.Instance.maxY = screen.Size.Height / GamePlay.Instance.Height; if (GamePlay.Instance.mySnake[i].x < 0 || GamePlay.Instance.mySnake[i].y < 0 || GamePlay.Instance.mySnake[i].x >= GamePlay.Instance.maxX || GamePlay.Instance.mySnake[i].y >= GamePlay.Instance.maxY) {//la fiecare coleziune cu peretii, die SnakeGame.Die(); } for (int j = 1; j < GamePlay.Instance.mySnake.Count; j++)//coleziunea cu corpul { if (GamePlay.Instance.mySnake[i].x == GamePlay.Instance.mySnake[j].x && GamePlay.Instance.mySnake[i].y == GamePlay.Instance.mySnake[j].y) { SnakeGame.Die(); } } //detecteaza coleziunea cu mancarea if (GamePlay.Instance.mySnake[0].x == GamePlay.Instance.food.x && GamePlay.Instance.mySnake[0].y == GamePlay.Instance.food.y) { Food.EatLogic(); } } else { //daca nu apare niciun obstacol, Move body GamePlay.Instance.mySnake[i].x = GamePlay.Instance.mySnake[i - 1].x;//muta urmatorul cerc conform cercului de dinainte, va apara ca sarpele se afla intr-o miscare continua GamePlay.Instance.mySnake[i].y = GamePlay.Instance.mySnake[i - 1].y; } } }
public MainWindow() { InitializeComponent(); GameAreaGrid.SizeChanged += HandleSizeChange; KeyDown += new KeyEventHandler(OnButtonKeyDown); SnakeGame.Initialise(); GenerateCanvasCells(); timer = InitTimer(new TimeSpan(0, 0, 0, 0, 300)); }
public static void Action() { if (cursorx == (Console.WindowWidth / 2) - 8) { Console.Clear(); SnakeGame.Start(); } else if (cursorx == (Console.WindowWidth / 2) + 4) { Console.Clear(); } }
static void Main(string[] args) { #if !MACOS Game = new SnakeGame(); Game.Run(); #else NSApplication.Init (); using (var p = new NSAutoreleasePool ()) { NSApplication.SharedApplication.Delegate = new AppDelegate (); NSApplication.Main (args); } #endif }
static void Main(string[] args) { #if !MACOS Game = new SnakeGame(); Game.Run(); #else NSApplication.Init(); using (var p = new NSAutoreleasePool()) { NSApplication.SharedApplication.Delegate = new AppDelegate(); NSApplication.Main(args); } #endif }
void Tick() { bool shouldEndGame = !SnakeGame.HandleSnakeLogic(GameState.currentSnakeDirection); if (shouldEndGame) { EndGame(); } PaintGrid(); PaintSnake(); DisplayScore(); GameState.directionWasUpdatedInThisTickTime = false; }
public static void Main() { Debug.Print(Resources.GetString(Resources.StringResources.String1)); Initialize(); graphics.DrawText(0, 0, "Snake!!"); graphics.Show(); Thread.Sleep(500); game = new SnakeGame(84, 48); StartGameLoop(); }
public static void Action() { if (cursory == (Console.WindowHeight / 2) - 8) { Console.Clear(); SnakeGame.Start(); } else if (cursory == (Console.WindowHeight / 2) - 7) { Console.Clear(); SnakeGame2P.Start(); } else if (cursory == (Console.WindowHeight / 2) - 6) { Program.Quit = true; } }
static void Main() { // AI Controller var neuralNetwork = NeuralNetwork.CreateFromFile(SnakeNeuralNetworkSpecification.Specification, @"Content\snakeWeights.json"); var aiController = new SnakeAiController(1, neuralNetwork); // Keyboard Controller var keyboardController = new SnakeKeyboardController(1); // Change value of selectedController to play game with keyboard var selectedController = aiController; using (var game = new SnakeGame(new List <ISnakeController> { selectedController })) game.Run(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); this.MakeFullScreen(); View game_view; if (MainActivity.Game == null) { SnakeGame.Vibrator = (Vibrator)this.ApplicationContext.GetSystemService(Context.VibratorService); var g = new SnakeGame(); game_view = (View)g.Services.GetService(typeof(View)); g.ExitEvent += () => this.MoveTaskToBack(true); g.Run(); MainActivity.Game = g; } else { game_view = (View)MainActivity.Game.Services.GetService(typeof(View)); ViewGroup parent = (ViewGroup)game_view.Parent; if (parent != null) { parent.RemoveView(game_view); } } #if ADS var layout = new FrameLayout(this); layout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); layout.AddView(game_view); SetContentView(layout); AndroidAds.Context = this; AndroidAds.ViewGroup = layout; #else this.SetContentView(game_view); #endif }
private static void Main(string[] args) { Task.Factory.StartNew(() => { while (true) { if (_currentGame != null) { _currentGame.PendingTurn = Console.ReadKey().Key.ToDirection(); } } }); while (true) { _currentGame = new SnakeGame(); while (_currentGame.Tick()) { Thread.Sleep(300); } Thread.Sleep(2000); } }
public static void Main() { snakeGame = new SnakeGame(); snakeGame.Run(); }
private void snakeUpdate() { try { //new head position - snake move Point newPosition = new Point( snake[0].X + snakeDirection.X, snake[0].Y + snakeDirection.Y); snake.Insert(0, newPosition); snake.RemoveAt(snake.Count - 1); //eating if (snake[0].X == food.X && snake[0].Y == food.Y) { snake.Add(new Point(food.X, food.Y)); score++; SnakeGame.ActiveForm.Text = "Snake score " + score; generateFood(); } //eating bad food if (snake[0].X == badFood.X && snake[0].Y == badFood.Y) { score--; SnakeGame.ActiveForm.Text = "Snake score " + score; snake.RemoveAt(snake.Count - 1); } //collid with body for (int i = 1; i < snake.Count - 1; i++) { if (snake[0].X == snake[i].X && snake[0].Y == snake[i].Y) { timer.Stop(); MessageBox.Show("You have collided with your body! Play again.\nScore: " + score); SnakeGame snakeGame = new SnakeGame(); snakeGame.Show(); this.Dispose(false); } } //leave the map field if (snake[0].X > this.ClientSize.Width - 10 || snake[0].X <0 || snake[0].Y> this.ClientSize.Height - 10 || snake[0].Y < 0) { timer.Stop(); MessageBox.Show("You left the map field! Play again.\nScore: " + score); SnakeGame snakeGame = new SnakeGame(); snakeGame.Show(); this.Dispose(false); } } catch (ArgumentException) { //eating bad food first to kill snake timer.Stop(); MessageBox.Show("You ate bad food by accident! The Snake is dead. Play again.\nScore: " + score); SnakeGame snakeGame = new SnakeGame(); snakeGame.Show(); this.Dispose(false); } }
static void Main() { using (var game = new SnakeGame()) game.Run(); }
public void SnakeEat() { SnakeGame s = new SnakeGame(); //s.Eat(); }
public void Turn(Turns turnsTo) { SnakeGame s = new SnakeGame(); //s.MoveBody(); //s.MoveTurnHead(turnsTo); }
public void MoveForward() { SnakeGame s = new SnakeGame(); //s.MoveForward(); //s.MoveBody(); }
/// <summary> /// Initialise the form and game of Snake, passing in the PictureBox to display the game in /// </summary> public MainForm() { InitializeComponent(); game = new SnakeGame(Canvas); }