Selacius Posted May 15, 2007 Share Posted May 15, 2007 I'm making a map editor using C# for my online RPG game. Basically I have two loops which run through the x and y coordinates and get the values for each x,y coordinate. Some of the x,y coordinates in the various tables are empty because they relate to the base tiles for the map. For example, a world map would have a base tile of grass. Therefore in any world map table any tile which would have grass is empty. My first problem is I am trying to figure out is how to check in C# whether the row is present or empty. I'm using this as my mysql query: OdbcComm = new System.Data.Odbc.OdbcCommand("SELECT * FROM "+maptable.SelectedItem.ToString()+" WHERE xvalue='"+y+"' AND yvalue='"+x+"';", OdbcCon);OdbcDRm = OdbcComm.ExecuteReader(); Then I have while (OdbcDRm.Read()) { CODE HERE The second problem is, if an image tile isn't found (does not exist), I keep getting an error. I want to somehow make it so that if the tile does not exist at the current moment, that the image would be replaced with the default image does not exist image. I'm using this to get the image: Image tile = Image.FromFile(tileimg+".bmp"); The third problem I am forseeing is I figure out a way to make each tile clickable, so that I can click the tile and it sends some data to a form element (input boxes, etc). Link to comment Share on other sites More sharing options...
aspnetguy Posted May 15, 2007 Share Posted May 15, 2007 I don't fully understand your first problem. You can see if the query returned any rows with the OdbcDRm.HasRows boolean.For your second problem you could do something like this Image tile;try{ tile = Image.FromFile(tileimg+".bmp");}catch{ tile = Image.FromFile(DEFAULT_FILE+".bmp");} Is this a web app or a windows app? If it is a web app you will have to use the JavaScript onclick of the images and use AJAX to request and pass information.If this is a windows app you will probably have to set up global hooks to capture all mosue clicks http://www.codeproject.com/csharp/globalhook.asp Link to comment Share on other sites More sharing options...
Selacius Posted May 15, 2007 Author Share Posted May 15, 2007 Awesome thanks. Basically for the first problem, I wasn't too sure how and what code to use and where to put it. And it is a windows application so i would have to use mouse clicks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.