Trying to get my block program working
-
I get this message when I try to run my c# block code program. I'm hoping someone can suggest what I need to change or add to my prgram so it will work. Error CS1061 'Form1' does not contain a definition for 'Form1_Load' and no accessible extension method 'Form1_Load' accepting a first argument of type 'Form1' could be found (are you missing a using directive or an assembly reference?) TRIED TO FORMAT CODE USING ``` ``` using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace BlockGame { public partial class Form1 : Form { private Rectangle Goal = new Rectangle(350, 600, 50, 50); private Rectangle Player = new Rectangle(350, 0, 50, 50); private Rectangle Enemy1 = new Rectangle(0, 150, 75, 75); private Rectangle Enemy2 = new Rectangle(599, 350, 75, 75); public Form1() { InitializeComponent(); this.MaximumSize = new Size(750, 750); this.MinimumSize = new Size(750, 750); } private void Form1_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawRectangle(Pens.Red, Goal); e.Graphics.DrawRectangle(Pens.Blue, Player); e.Graphics.DrawRectangle(Pens.Red, Enemy1); e.Graphics.DrawRectangle(Pens.Red, Enemy2); } private void Form1_KeyDown(object sender, KeyEventArgs e) { int PlayerX = Player.Location.X; int PlayerY = Player.Location.Y; switch (e.KeyData) { case Keys.Up: Player.Location = new Point(PlayerX += 0, PlayerY -= 20); this.Refresh(); break; } } //detect if any rectangles hit each other public void HitDetect() { if (Player.IntersectsWith(Goal)) { MessageBox.Show("You Win!"); } int PlayerX = Player.Location.X; int PlayerY = Player.Location.X; if (Enemy1.IntersectsWith(Player)) { Player.Location = new Point(PlayerX = 350, PlayerY = 0); MessageBox.Show("You Lose!"); } if (Enemy2.IntersectsWith(Player)) { Player.Location = new Point(Pla
-
I get this message when I try to run my c# block code program. I'm hoping someone can suggest what I need to change or add to my prgram so it will work. Error CS1061 'Form1' does not contain a definition for 'Form1_Load' and no accessible extension method 'Form1_Load' accepting a first argument of type 'Form1' could be found (are you missing a using directive or an assembly reference?) TRIED TO FORMAT CODE USING ``` ``` using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace BlockGame { public partial class Form1 : Form { private Rectangle Goal = new Rectangle(350, 600, 50, 50); private Rectangle Player = new Rectangle(350, 0, 50, 50); private Rectangle Enemy1 = new Rectangle(0, 150, 75, 75); private Rectangle Enemy2 = new Rectangle(599, 350, 75, 75); public Form1() { InitializeComponent(); this.MaximumSize = new Size(750, 750); this.MinimumSize = new Size(750, 750); } private void Form1_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawRectangle(Pens.Red, Goal); e.Graphics.DrawRectangle(Pens.Blue, Player); e.Graphics.DrawRectangle(Pens.Red, Enemy1); e.Graphics.DrawRectangle(Pens.Red, Enemy2); } private void Form1_KeyDown(object sender, KeyEventArgs e) { int PlayerX = Player.Location.X; int PlayerY = Player.Location.Y; switch (e.KeyData) { case Keys.Up: Player.Location = new Point(PlayerX += 0, PlayerY -= 20); this.Refresh(); break; } } //detect if any rectangles hit each other public void HitDetect() { if (Player.IntersectsWith(Goal)) { MessageBox.Show("You Win!"); } int PlayerX = Player.Location.X; int PlayerY = Player.Location.X; if (Enemy1.IntersectsWith(Player)) { Player.Location = new Point(PlayerX = 350, PlayerY = 0); MessageBox.Show("You Lose!"); } if (Enemy2.IntersectsWith(Player)) { Player.Location = new Point(Pla
Somewhere in the designer you said you wanted to handle the "form load event", but you're missing the "handler." [How to: Create Event Handlers Using the Designer | Microsoft Docs](https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/zwwsdtbk(v=vs.100))
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food