Chris27

Members
  • Content count

    92
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Chris27

  • Rank
    Member
  1. This isn't related to games, but I hope someone can help. I'm making a forms application with C# and I use a lot of the visual tools because it speeds things up and I have less code to worry about. I would like to know if there is anyway to catch exceptions that occur from visual tools. Normally if your right the code yourself you just make a try catch block, but with the visual tools you can't see the code and can't put a try catch block around it. Here is my problem. I have a typed dataset and a instance of that dataset created by the tools in the toolbox. I then use a bindingsource from the toolbox and attach it to the dataset. The primary key needs to be unique. When you put in the same data in one row as there is in another row and navigate to another row it throws an exception that the value must be unique. The problem is I don't know how to catch the exception for this. There is no code to put a try catch and it crashes the program. If the only recourse it to create the dataset and binding source in code that sucks IMO. Thanks
  2. [.net] .NET forms.timer

    Ok I will try the system.threading.timer and see if it works any better. Thank you
  3. [.net] .NET forms.timer

    I don't believe that is the issue as the timer stops if I start it via a button. It has something to do with starting the timer from anther timer. Try it out for yourself in a C# form. Create two visual timer controls and set one to execute something under a certain condition. If the condition is true start the timer. Then call timer.stop in the second timer event. It wont stop even if there is no messagebox. You can test this using a breakpoint. On the otherhand the timer.stop will work if the timer is started via a button control.
  4. [.net] .NET forms.timer

    If you want to know the intervals I set tmrTest to execute every five seconds 5000, and tmrExecuteTime to execute every second 1000.
  5. [.net] .NET forms.timer

    That is basically the code. namespace TimerTesting { public partial class frmMain : Form { private const string strExecuteTime = "11:27 AM"; public frmMain() { InitializeComponent(); } private void btnTest_Click(object sender, EventArgs e) { tmrTest.Start(); } private void tmrTest_Tick(object sender, EventArgs e) { MessageBox.Show("Testing"); tmrTest.Stop(); } private void tmrCheckTime_Tick(object sender, EventArgs e) { if (DateTime.Now.ToShortTimeString() == strExecuteTime) { tmrTest.Start(); } } } }
  6. Is it possible to have two windows forms timers and start one from the other? I seem to be having a problem with getting the second timer to stop after it is started by the first based on a condition. Timer1 Timer1 tick event if(datetime.now.toshorttime() == "10:00 PM") Timer2.start() Timer2 tick event messagebox.show("Success") Timer2.stop() Timer2 will start, but it will not stop. This is not the case if I Enable Timer2 from a button control. In that case it will output the message once and then stop like it is supposed to. I have a feeling it has something to do with threads, but I know nothing about them. Thanks
  7. Source code for games?

    It shounds like you are interested in C and C++, but there are a bunch of starter kits for XNA game studio. There was a recent one that was RPG starter kit, but there are ones for FPS type games as well.
  8. window creation using windows api

    DirectX http://www.directxtutorial.com/ Win32 http://www.functionx.com/win32/index.htm I think these are decent tutorials considering they are not made by proffesionals.
  9. window creation using windows api

    That doesn't sound like a good idea to me. They should at least explain what each funtion used in creating a Window does and how Windows messages/events works. I honestly think creating a Window using Win32 API is pretty confusing and if you don't understand it how can you make effective use of DirectX with it.
  10. Class, Methods, Assemblies, Oh my

    I agree with that. All the basics in C# can be learned in the default class that is created. Just write all your code in main() and you should be fine. If you are using a Windows Form you should try and learn how event based programming works. Basically event based means something happens on the form which causes code on the form to execute. For instance if you click on a button the code under that botton executes and something happens. This is probably the most imporant thing to understand for a new programmer working with Forms applications.
  11. Class, Methods, Assemblies, Oh my

    I don't understand why the book would go into those topics early on. Personally I would put those things in the back of my mind until you encounter object oriented programming later in the book. The first things you need to learn are Variables, data Types, Evaluations, Loops, and Methods. If your book doesn't start with these then I would get a new book. After you get these down the book should start devling into object oriented programming.
  12. c# form array. Drawing a map?

    Okay I have experimented and it is the same as a console application. \n string[,] text1 = {{"test", "for", "array"}, {"test2", "for", "array"}}; label1.Text = text1[0, 2] + "\n" + text1[0, 1] + "\n" + text1[1, 0];
  13. c# form array. Drawing a map?

    My bad it's a label so I'm not sure whats wrong. I think you could achieve the same thing using picture boxes and it might look better. There are also dawn methods you can use to draw on the form.
  14. Creating a text-based game,

    I've actually never written a text based game, but I was thinking of how one could be done and came up with this as a beggining to creating an invisible game board in my mind. It's not a game yet, but it has the basic structure for a game I think. I'm sure someone else could have done a lot better job. #include <iostream> using std::cin; using std::cout; using std::endl; // Shows current player board position void ShowPosition(int X, int Y); // Outputs message when you are at the end of the board void EndOfBoard(); int main() { // end of board const int lrMax = 4; // beggining of board const int lrMin = 1; // top of board const int udMax = 5; // bottum of board const int udMin = 1; // board position int boardPosition[2] = {1, 1}; // keyboard input choice char getKey; cout << "Welcome to Game Board Example!" << endl << " press n to quit" << endl; do { cout << "Which direction would would you like to go?" << endl << "1 left, 2 right, 3 up, 4 down" << endl; cin >> getKey; switch(static_cast<int>(getKey)) { case static_cast<int>('1'): // if greater then beggining move left if(boardPosition[0] > lrMin) { boardPosition[0] -= 1; ShowPosition(boardPosition[0], boardPosition[1]); }else EndOfBoard(); break; case static_cast<int>('2'): // if less then end move right if(boardPosition[0] < lrMax) { boardPosition[0] += 1; ShowPosition(boardPosition[0], boardPosition[1]); }else EndOfBoard(); break; case static_cast<int>('3'): // if less then top move up if(boardPosition[1] < udMax) { boardPosition[1] += 1; ShowPosition(boardPosition[0], boardPosition[1]); }else EndOfBoard(); break; case static_cast<int>('4'): // if greater then bottum move down if(boardPosition[1] > udMin) { boardPosition[1] -= 1; ShowPosition(boardPosition[0], boardPosition[1]); }else EndOfBoard(); break; case static_cast<int>('n'): // end of game message cout << "Goodbye" << endl; break; default: // error for wrong input from keyboard cout << "Please enter 1, 2, 3, or 4" << endl; } // if you are at this board position you are dead! game over if(boardPosition[0] == 1 && boardPosition[1] == 3) { cout << "Trap triggered! You are dead!" << endl; getKey = static_cast<int>('n'); } // exit the game game if n is pushed }while(static_cast<int>(getKey) != static_cast<int>('n')); //system("pause"); return 0; } void ShowPosition(int X, int Y) { cout << "Current board position = [" << X << "] [" << Y << "]" << endl; } void EndOfBoard() { cout << "You are at the end of the board!" << endl; }
  15. Complete Noob with Questions

    I should also add there is the advantage of learning event driven programming right off the bat and being able to create a Windows application right away. For those who don't have a lot of patience they can get tired of having to learn C++ using procedural DOS programs. It takes a lot of knowledge in C++ before you can get a Win32 applicaiton up and running. Personally it helped me a lot to learn how event driven programming worked using Windows Forms.