0

I'M reading this tutorial at http://www.tuxradar.com/beginnerscode at all I have done thus far is enough for an empty game window built with two small .cs files.

Here are the error messages.

Line=15, Column=72, Type=Error, Priority=Normal, Description=An object reference is required to access non-static member TroutWars.MainClass.Quit(object, SdlDotNet.Core.QuitEventArgs)'(CS0120)]

&

Description=`System.EventArgs' does not contain a definition for `Run'(CS0117)]

Here are the files

Main.cs

using System;
using SdlDotNet;
using SdlDotNet.Core;
using SdlDotNet.Graphics;
using System.Drawing;

namespace TroutWars
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			TroutWars game = new TroutWars();
			Video.SetVideoMode(1024, 768);
			Events.Quit += new EventHandler<QuitEventArgs>(Quit);
			EventArgs.Run();
		}
		
		void Quit(object sender, QuitEventArgs e)
		{
			Events.QuitApplication();
		}
	}
}

TroutWars.cs

using System;
using SdlDotNet;
using SdlDotNet.Core;
using SdlDotNet.Graphics;
using System.Drawing;

namespace TroutWars
{
	
	
	public class TroutWars
	{
		
		public TroutWars()
		{
			Console.WriteLine("Hello World!");
		}
	}
}

Any help would be greatly appreciated, thanks.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by lewashby
1

The error means that on line 16 of your first code, the class EventArgs does not contain a method Run
I looked at the link you gave: change line 16 to Events.Run().

0

The error means that on line 16 of your first code, the class EventArgs does not contain a method Run
I looked at the link you gave: change line 16 to Events.Run().

Thanks, that took away one error message, but now I'M getting this one.

[Task:File=/home/developer/Projects/TroutWars/TroutWars/Main.cs, Line=15, Column=72, Type=Error, Priority=Normal, Description=

An object reference is required to access non-static member `TroutWars.MainClass.Quit(object, SdlDotNet.Core.QuitEventArgs)'(CS0120)]

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.