public SnakeHead(Game game, IRenderItemFactory factory) : base(game, factory, new Vector2I(0, 0)) { Direction = Game.Rules.SnakeStartDirection; direction = Direction; Position = Game.Rules.SnakeStartPosition; RenderItem = factory.CreateRenderItem(RenderItemType.SnakeHead); }
public MainWindow() { InitializeComponent(); game = new Game(this, this, new WPFInput()); timer.Tick += timer_Tick; timer.Interval = new TimeSpan(0, 0, 0, 0, 16); timer.Start(); }
public World(Game game, IRenderItemFactory factory, GameRules rules) { this.game = game; this.factory = factory; Head = new SnakeHead(game, factory); CreateWorld(game, factory, rules, rules.WorldSize); Random random = new Random(); Treat = new Treat(game, factory, new Vector2I(random.Next(1, rules.WorldSize.X - 1), random.Next(1, rules.WorldSize.Y - 1))); }
static void Main(string[] args) { try { Game game = new Game(); game.BeginGame(); } catch (Exception e) { Console.WriteLine(e.Message); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.SnakeGame = ((Snake.Game)(target)); return; case 2: this.gameCanvas = ((System.Windows.Controls.Canvas)(target)); return; case 3: this.txtMessage = ((System.Windows.Controls.TextBlock)(target)); return; } this._contentLoaded = true; }
static void Main(string[] args) { Console.SetWindowSize(WindowHeight, WindowWidth); Console.SetBufferSize(WindowHeight, WindowWidth); Console.BackgroundColor = ConsoleColor.DarkCyan; Console.ForegroundColor = ConsoleColor.Cyan; Console.CursorVisible = false; game = new Game(Console.BufferHeight - 1, Console.BufferWidth); Thread inputThread = new Thread(new ThreadStart(Control)); game.Start(); inputThread.Start(); while (game.IsRunning) { Console.SetCursorPosition(0, 0); Console.Write(game.MapToString()); game.UpdateSnake(); Console.Title = WindowTitle + " :: " + "[Skóre: " + game.Score + "]"; Thread.Sleep(100); } }
public void Clear_Level() { int level= mygame.game_level + 1; int game_height = mygame.game_height; int game_width = mygame.game_width; string sound = mygame.sound_control; MyGame_timer.Enabled = false; if(level > mygame.max_level) { level = 1; mygame.Finish_Game(); pictureBox1.Refresh(); mygame.game_status = "game_over"; } else { mygame.Clear_Level(); pictureBox1.Refresh(); mygame = new Game(game_height,game_width); mygame.game_status = "clear"; mygame.sound_control = sound; mygame.game_level = level; } }
public Field(Game game, IRenderItemFactory factory, Vector2I position) { Position = position; Game = game; Factory = factory; }
public Treat(Game game, IRenderItemFactory factory, Vector2I position) : base(game, factory, position) { RenderItem = factory.CreateRenderItem(RenderItemType.Treat); }
static void Main(string[] args) { Game game = new Game(); Console.ReadKey(); }
public SnakeBody(Game game, IRenderItemFactory factory, Vector2I position) : base(game, factory, position) { RenderItem = factory.CreateRenderItem(RenderItemType.SnakeBody); }
public SpeedPowerup(Game game, IRenderItemFactory factory, Vector2I position) : base(game, factory, position) { RenderItem = factory.CreateRenderItem(RenderItemType.SpeedPowerup); }
private void FormMain_Load(object sender, EventArgs e) { int width, height, size; width = height = 30; size = 20; this.pictureBox1.Width = width * size; this.pictureBox1.Height = height * size; // this.Width = pictureBox1.Width + 30; // this.Height = pictureBox1.Height + 60; G = new Game(width, height, size, Graphics.FromHwnd(this.pictureBox1.Handle)); }
//Create the game board again for changed size void Game_Create_Again() { string sound = mygame.sound_control; int h = mygame.game_height; int w = mygame.game_width; mygame = new Game(h,w); top_menu_panel.Size = new Size(w,top_menu_panel.Size.Height); mygame.sound_control = sound; MyGame_Form_Load(this,System.EventArgs.Empty); }
private void CreateWorld(Game game, IRenderItemFactory factory, GameRules rules, Vector2I size) { for (int x = 0; x < size.X; x++) for (int y = 0; y < size.Y; y++) if ((x == 0 || x == size.X - 1) || (y == 0 || y == size.Y - 1)) blocks.Add(new Block(game, factory, new Vector2I(x, y))); }