Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Trying to get my block program working

Trying to get my block program working

Scheduled Pinned Locked Moved C#
csharpgraphicslinqhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brian_TheLion
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • B Brian_TheLion

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups