/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); this.Text = "Stickario"; this.Width = 1024; this.Height = 800; this.DoubleBuffered = true; // basic green background var controller = new Controller(); var world = new World( controller.GetConfiguration(), controller.GetPlayers(), controller.GetObjects(), controller.GetBackground() ); controller.World = world; controller.Stickario.OnApplyForce += (player, percentage) => world.ApplyForce(player, Forces.X, percentage); world.OnBeforeKeyPressed += controller.BeforeKeyPressed; world.OnContact += controller.ObjectContact; UI = new UIHookup(this, world); // call right before controls enters the game loop controller.Setup(); }
public shootMup() { InitializeComponent(); try { SuspendLayout(); // initial setup AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F); AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; ClientSize = new System.Drawing.Size(1484, 1075); Name = "shootMup"; Text = "shootMup"; DoubleBuffered = true; // generate players var human = new ShootMPlayer() { Name = "You" }; var players = new Player[100]; for (int i = 0; i < players.Length; i++) { players[i] = new SimpleAI() { Name = string.Format("ai{0}", i) } } ; // generate the world World = WorldGenerator.Generate(WorldType.Random, PlayerPlacement.Borders, human, ref players); // if we are training for AI, then capture telemetry World.OnBeforeAction += AITraining.CaptureBefore; World.OnAfterAction += AITraining.CaptureAfter; World.OnDeath += (elem) => { if (elem is Player) { var winners = new List <string>(); // capture the winners foreach (var player in players) { winners.Add(string.Format("{0} [{1}]", player.Name, player.Kills)); } AITraining.CaptureWinners(winners); } }; UI = new UIHookup(this, World); } finally { ResumeLayout(false); } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.SuspendLayout(); // // moo // this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1500, 800); this.Name = "moo"; this.Text = "moo"; this.ResumeLayout(false); this.DoubleBuffered = true; var generator = new MooWorld(); int width = 0; int height = 0; var players = generator.GetPlayers(); var obstacles = generator.GetObstacles(out width, out height); var background = new MooBackground(width, height) { GroundColor = new RGBA { R = 100, G = 255, B = 100, A = 255 } }; var world = new World(new WorldConfiguration() { Width = width, Height = height, CenterIndicator = false, StartMenu = new MooStartMenu(), EnableZoom = true, DisplayStats = true, HUD = new MooHud(players[0] as MooPlayer) }, players, obstacles, background ); generator.World = world; world.OnAttack += generator.Contact; world.OnBeforeKeyPressed += generator.TakeAction; UI = new UIHookup(this, world); }
public TypeOrDie() { // winforms init InitializeComponent(); this.Width = 800; this.Height = 512; this.Text = "Cats Hate Typings Mistakes"; var icons = engine.Common.Embedded.LoadResource <Icon>(System.Reflection.Assembly.GetExecutingAssembly()); if (icons.TryGetValue("full", out var icon)) { this.Icon = icon; } // setting a double buffer eliminates the flicker this.DoubleBuffered = true; // game init Game = new TypeOrDieGame(this.Width, this.Height); // link to this control UI = new UIHookup(this, Game.Board); }
public BilleteDeTren() { InitializeComponent(); this.Width = 1024; this.Height = 800; this.Text = "Billete De Tren"; // setting a double buffer eliminates the flicker this.DoubleBuffered = true; // create dimensions BdtBoardGenerator.Generate(Width, Height, numPlayers: 2, out BdtBoard, out Cells); // creat the new board Board = new engine.Common.Board(new BoardConfiguration() { Width = Width, Height = Height, Rows = 1, Columns = Cells.Length, EdgeAngle = 30, Background = RGBA.White, Cells = Cells }); Board.OnCellClicked += Board_OnCellClicked; // link to this control UI = new UIHookup(this, Board); // paint the board for (int row = 0; row < Cells.Length; row++) { for (int col = 0; col < Cells[row].Length; col++) { UpdateCell(row, col); } } }
// // Init // private void Initialize(int width, int height) { // init control DoubleBuffered = true; Height = height; Width = width; // init Rand = new Random(); // setup board Board = new Board( new BoardConfiguration() { Height = Height, Width = Width, Columns = BoatEgoBoard.Columns, Rows = BoatEgoBoard.Rows, Background = new RGBA() { R = 51, G = 158, B = 247, A = 255 } } ); Board.OnCellClicked += Board_OnCellClicked; // init UI UI = new UIHookup(this, Board); // load images var images = Resources.LoadImages(System.Reflection.Assembly.GetExecutingAssembly()); // mark them all as transparent foreach (var kvp in images) { kvp.Value.MakeTransparent(RGBA.White); } // store some for quick access // artifacts BorderImage = images["border"]; IslandImage = images["island"]; EdgeImage = images["edge"]; ScrollImages = new IImage[] { images["scroll"], images["scrolllong"] }; WinImage = images["win"]; LostImage = images["lost"]; TitleImage = images["title"]; // waves WavesImages = new IImage[] { images["waves1"], images["waves2"], images["waves3"], }; // bases BaseImages = new IImage[2]; BaseImages[(int)Player.Red] = images["redbase"]; BaseImages[(int)Player.Blue] = images["bluebase"]; // pieces (not visible) NotshowingPieceImages = new IImage[2]; NotshowingPieceImages[(int)Player.Red] = images["redpiece"]; NotshowingPieceImages[(int)Player.Blue] = images["bluepiece"]; // pieces (visible) PieceImages = new IImage[BoatEgoBoard.NumberOfPieces]; PieceImages[(int)Piece.Spy] = images["diver"]; PieceImages[(int)Piece._1] = images["floaty"]; PieceImages[(int)Piece._2] = images["duck"]; PieceImages[(int)Piece.BombSquad] = images["rov"]; PieceImages[(int)Piece._4] = images["turtle"]; PieceImages[(int)Piece._5] = images["rowboat"]; PieceImages[(int)Piece._6] = images["sailboat"]; PieceImages[(int)Piece._7] = images["squid"]; PieceImages[(int)Piece._8] = images["shark"]; PieceImages[(int)Piece._9] = images["submarine"]; PieceImages[(int)Piece._10] = images["ironclad"]; PieceImages[(int)Piece.Bomb] = images["bomb"]; PieceImages[(int)Piece.Flag] = images["chest"]; // init the game engine Game = new BoatEgoBoard(); Game.OnCellUpdate += Game_OnCellUpdate; Game.OnNotify += Game_OnNotify; // paint the full board for (int r = 0; r < BoatEgoBoard.Rows; r++) { for (int c = 0; c < BoatEgoBoard.Columns; c++) { UpdateCell(Game[r, c]); } } // add an overlay to the user to start placing pieces IsTuturial = true; AddOverlay("Start placing your pieces"); }