|
3
|
Other Software / Developer's Corner / Re: Writing a simple driving game (help!!)
|
on: October 09, 2007, 12:14:39 PM
|
Excellent! Nothing better than the feeling one gets after solving a brain-buster.
Now that you have the thing working (grin) it's time to rip it all out and replace it with this:
I've found that performance can be enhanced greatly in these kinds of games by precalculating all the SIN/COS values for each possible direction of movement and storing them in lookup tables. RAM is cheap, the data we're talking about is not huge (assuming something like 5 or 10-degree increments), and the performance improvements can be breathtaking. Integer lookups are nearly instantaneous, unlike SIN/COS calculations.
And yes, my motto really is "fix it even if it's not broken". :-)
I'm writing a simple driving game, no proper physics or anything, so performance isn't really an issue :p And whatever you posted, I can't see it 
|
|
|
|
|
6
|
Other Software / Developer's Corner / Writing a simple driving game (help!!)
|
on: October 09, 2007, 09:50:25 AM
|
|
Right, so I'm trying my best to write a simple driving game in XNA (that's not important). Basically, it's a 2D top down game, but I'm struggling to get the vehicle to move in the direction it is facing. Does anybody have a formula that would give me the new coordinates based on the source position, rotation, and the distance to travel? I did try:
X = distance * cos(rotation) Y = distance * sin(rotation)
but I just ended up with a vehicle that would rotate around the point, and sometimes it might just travel in the direction it was facing :p
|
|
|
|
|
7
|
Other Software / Developer's Corner / ASP.NET Issues
|
on: May 18, 2007, 11:04:49 AM
|
I've been asked to code a form for a website. The form contains 40 or so textboxes, so I just wrote some really long INSERT query (if there is a better way, please suggest it) to insert them in. Now, I keep getting "Object reference not set to an instance of an object" on the following code [ copy or print] OleDbCommand theCommand = new OleDbCommand(); theCommand.Connection = theConnection; theCommand.CommandText = @"INSERT INTO [SQLserverSQL].[dbo].[Records] ([computerName] ,[operatingSystem] ,[serialNumber] ,[hardwareManufacturer] ,[modelType] ,[warrantyExpiration] ,[serverFunction] ,[retailCorporate] ,[dcenterStoreLocation] ,[rackNumber] ,[supportGroup] ,[cellNumber] ,[Product Number] ,[localAdminID] ,[localAdminPW] ,[cpuNumber] ,[cpuType] ,[cpuSpeed] ,[networkAdapters] ,[speedDuplex] ,[primaryIP] ,[secondaryIP] ,[riloName] ,[riloIP] ,[totalMemory] ,[totalDiskSpace] ,[C_OS] ,[D_Data] ,[E_Apps] ,[networkCableID] ,[power] ,[changeWindow] ,[appName] ,[businessOwner] ,[appVendor] ,[appSupportGroup] ,[appFunction] ,[appCode] ,[specialRequirements]) VALUES (" + computerName.ToString() + "," + operatingSystem.SelectedIndex.ToString() + "," + serialNumber.ToString() + "," + hardwareManufacturer.SelectedIndex.ToString() + "," + modelType.SelectedIndex.ToString() + "," + warrantyExpiration.ToString() + "," + serverFunction.SelectedItem.ToString() + "," + retailCorporate.SelectedItem.ToString() + "," + dCenterStoreLocation.SelectedItem.ToString() + "," + gridLocation.SelectedItem.ToString() + "," + supportGrp.ToString() + "," + cellPagerNumber.ToString() + "," + productNumber.ToString() + "," + localAdminID.ToString() + "," + localAdminPW.ToString() + "," + cpuNumber.SelectedItem.ToString() + "," + cpuType.SelectedItem.ToString() + "," + cpuSpeed.SelectedItem.ToString() + "," + netAdapters.SelectedItem.ToString() + "," + speedDuplex.SelectedItem.ToString() + "," + primaryIP.ToString() + "," + secondaryIP.ToString() + "," + riloName.ToString() + "," + riloIP.ToString() + "," + totalMemory.ToString() + "," + totalDiskSpace.ToString() + "," + C_OS.SelectedItem.ToString() + "," + D_Data.SelectedItem.ToString() + "," + E_Apps.SelectedItem.ToString() + "," + netCableID.ToString() + "," + power.ToString() + "," + changeWindow.ToString() + "," + appName.ToString() + "," + businessOwner.ToString() + "," + appVendor.ToString() + "," + appSupportGrp.ToString() + "," + appFunc.ToString() + "," + appCode.ToString() + "," + specReq.ToString() + ")"; It occurs on the third line, but I don't know what's causing it, as this is the way I've always done it before. Any ideas?
|
|
|
|
|
11
|
Other Software / Developer's Corner / Re: grr SQL and C#
|
on: February 28, 2007, 03:21:58 AM
|
|
HAHA I finally did it. It was a combination of me trying to check one field type in the code, with a totally different type in the DB itself. For some reason I was using Long Date Strings, but they are never displayed to the user, so they don't actually provide any visual advantages, and they just become a major pain during the coding side.
Thanks for the help guys.
|
|
|
|
|
12
|
Other Software / Developer's Corner / Re: Best Programming Music
|
on: February 27, 2007, 02:11:06 PM
|
I listen to XFM (local-ish radio station), or if im at college, whatever music I have loaded onto my phone. Although recently ive been listening to ChristianRock.net (im not even religious or owt  ), but I can't at college, because of the damn firewall of dooom.
|
|
|
|
|
13
|
Other Software / Developer's Corner / grr SQL and C#
|
on: February 27, 2007, 12:10:51 PM
|
So I have this code [ copy or print] string scope = null; try { OleDbCommand tableSearch = connection.CreateCommand(); tableSearch.CommandText = "SELECT * FROM coursework WHERE DateDue BETWEEN '" + System.DateTime.Now.Date.ToString() + "' AND '" + scope+ "'";//sql command //OleDbParameter todaysDate = new OleDbParameter(); //tableSearch.Parameters.Add(todaysDate); //OleDbParameter dateDue = new OleDbParameter(); //tableSearch.Parameters.Add(dateDue);//add a parameter //todaysDate.Value = System.DateTime.Now; if (whatScope == "week") { //dateDue.Value = System.DateTime.Now.AddDays(7).ToLongDateString();//give the parameter a value } else if (whatScope == "month") { //dateDue.Value = System.DateTime.Now.AddMonths(1).ToLongDateString(); } else if (whatScope == "today") { //dateDue.Value = System.DateTime.Now.ToLongDateString(); scope = System.DateTime.Now.Date.ToString(); } OleDbDataReader reader = tableSearch.ExecuteReader(); assignmentList.Items.Clear(); while (reader.Read()) assignmentList.Items.Add(reader.GetString(0)); reader.Close(); } catch (OleDbException ex) { MessageBox.Show(ex.ToString()); } Im trying to get it so that it retrieves values from the DB between Today and X. The column DateDue is a Long Date column, but no matter what I try and put in the SQL query, I always get "Data Type Mismatch In Criteria Expression". Any ideas?
|
|
|
|
|
14
|
DonationCoder.com Software / Post New Requests Here / Re: MOVEALLTO C:\OLDDATA
|
on: February 13, 2007, 05:57:45 AM
|
done http://chedabob.com/moveall.batyoud be surprised how simple it was  before you run it, be aware, i cannot be held responsible if it goes nuts up. I shouldnt see why it would, but please, test it on some files that aren't critcal. It successfully moves c:\ati to c:\bleh on my machine, but I dont have enough space to test it on my machine edit1: just tested it on my other drive. It worked fine.
|
|
|
|
|
22
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA Text file of Folder contents
|
on: January 20, 2007, 12:35:48 PM
|
|
Right, its practically finished. It just needs drag N drop adding (which is a being a pain in the arse) and sorting out a small bug with file creation. At the moment, you enter the directory in one text box*, and the output file in the bottom, then you click "Lets Go!", but the main problem is if the output file does not exists, it is created, but the program holds it in memory, so when I come to write it, it can't, because its already in use. If anybody can shed some light on this, id be ever so grateful.
* I hope to change this so that it is just a small icon that remains onscreen, and when you drop a folder on it, it does its thing, and creates a file called output.txt in the same folder.
|
|
|
|
|
23
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA: monitor folder for max MB and get message
|
on: January 20, 2007, 12:31:51 PM
|
I could try this, don't think it would be too hard. Gimme half an hour, and Ill have a look EDIT: Actually, might take a little longer than expected, I gotta get my head around this silly size method. EDIT2: So, this is my code so far. Its not tidy or anything, but it works slightly. Could somebody explain why it gives me some stupid value? Like for My Pictures, it gives 1180, when in fact, the closest value it could be is 876kb (the actual value according to windows explorer). [ copy or print] private void button1_Click(object sender, EventArgs e) { string input = textBox1.Text.ToString(); string [] directorylist = null; string [] filelist = null; directorylist = Directory.GetDirectories(input); int counterD = 0; int counterF = 0; double size = 0; if (Directory.Exists(input) == true) { do { filelist = Directory.GetFiles(directorylist[counterD]); do { size = size + filelist[counterF].Length; counterF++; } while (counterF <= filelist.Length - 1); counterF = 0; counterD++; } while (counterD <= directorylist.Length - 1); MessageBox.Show(size.ToString()); } else { MessageBox.Show("No such Directory. Check path and try again!"); } }
|
|
|
|
|
24
|
DonationCoder.com Software / Post New Requests Here / Re: IDEA Text file of Folder contents
|
on: January 18, 2007, 03:37:11 PM
|
I could try this. Luckily I have my C# Textbook with me XD Edit: Actually, earliest I could get it done is Monday. I left my usb thumb drive in a computer at college, then the building got evacuated (the roof blew off), and I can't get my stuff back till monday. It just so happens that the only copy of the source code for my program that handles text files, is on that drive, and the code is also in my bag (also at college  )
|
|
|
|
|